… | |
… | |
31 | #include <sys/types.h> |
31 | #include <sys/types.h> |
32 | #include <unistd.h> |
32 | #include <unistd.h> |
33 | #include <signal.h> |
33 | #include <signal.h> |
34 | #include <termios.h> |
34 | #include <termios.h> |
35 | |
35 | |
|
|
36 | #if HAVE_SYS_MMAN_H |
36 | #include <sys/mman.h> |
37 | # include <sys/mman.h> |
|
|
38 | #endif |
37 | |
39 | |
38 | #include <openssl/err.h> |
40 | #include <openssl/err.h> |
39 | #include <openssl/rand.h> |
41 | #include <openssl/rand.h> |
40 | |
42 | |
41 | #include "gettext.h" |
43 | #include "gettext.h" |
… | |
… | |
55 | static int show_help; |
57 | static int show_help; |
56 | |
58 | |
57 | /* If nonzero, print the version on standard output and exit. */ |
59 | /* If nonzero, print the version on standard output and exit. */ |
58 | static int show_version; |
60 | static int show_version; |
59 | |
61 | |
60 | #if HAVE_MLOCKALL |
|
|
61 | /* If nonzero, disable swapping for this process. */ |
62 | /* If nonzero, disable swapping for this process. */ |
62 | static int do_mlock = 0; |
63 | static int do_mlock = 0; |
63 | #endif |
|
|
64 | |
64 | |
65 | /* If zero, don't detach from the terminal. */ |
65 | /* If zero, don't detach from the terminal. */ |
66 | static int do_detach = 1; |
66 | static int do_detach = 1; |
67 | |
67 | |
68 | static struct option const long_options[] = |
68 | static struct option const long_options[] = |
… | |
… | |
70 | {"config", required_argument, NULL, 'c'}, |
70 | {"config", required_argument, NULL, 'c'}, |
71 | {"help", no_argument, &show_help, 1}, |
71 | {"help", no_argument, &show_help, 1}, |
72 | {"version", no_argument, &show_version, 1}, |
72 | {"version", no_argument, &show_version, 1}, |
73 | {"no-detach", no_argument, &do_detach, 0}, |
73 | {"no-detach", no_argument, &do_detach, 0}, |
74 | {"log-level", required_argument, NULL, 'l'}, |
74 | {"log-level", required_argument, NULL, 'l'}, |
75 | #if HAVE_MLOCKALL |
|
|
76 | {"mlock", no_argument, &do_mlock, 1}, |
75 | {"mlock", no_argument, &do_mlock, 1}, |
77 | #endif |
|
|
78 | {NULL, 0, NULL, 0} |
76 | {NULL, 0, NULL, 0} |
79 | }; |
77 | }; |
80 | |
78 | |
81 | static void |
79 | static void |
82 | usage (int status) |
80 | usage (int status) |
… | |
… | |
122 | |
120 | |
123 | case 'D': /* no detach */ |
121 | case 'D': /* no detach */ |
124 | do_detach = 0; |
122 | do_detach = 0; |
125 | break; |
123 | break; |
126 | |
124 | |
127 | #if HAVE_MLOCKALL |
|
|
128 | case 'L': /* lock into memory */ |
125 | case 'L': /* lock into memory */ |
129 | do_mlock = 1; |
126 | do_mlock = 1; |
130 | break; |
127 | break; |
131 | #endif |
|
|
132 | |
128 | |
133 | case 'l': /* inc debug level */ |
129 | case 'l': /* inc debug level */ |
134 | { |
130 | { |
135 | llevel = string_to_loglevel (optarg); |
131 | llevel = string_to_loglevel (optarg); |
136 | |
132 | |
… | |
… | |
243 | |
239 | |
244 | log_to (LOGTO_SYSLOG | LOGTO_STDERR); |
240 | log_to (LOGTO_SYSLOG | LOGTO_STDERR); |
245 | |
241 | |
246 | /* Lock all pages into memory if requested */ |
242 | /* Lock all pages into memory if requested */ |
247 | |
243 | |
248 | #if HAVE_MLOCKALL |
244 | #if HAVE_MLOCKALL && HAVE_SYS_MMAN_H |
249 | if (do_mlock) |
245 | if (do_mlock) |
250 | if (mlockall (MCL_CURRENT | MCL_FUTURE)) |
246 | if (mlockall (MCL_CURRENT | MCL_FUTURE)) |
251 | slog (L_ERR, _("system call `%s' failed: %s"), "mlockall", strerror (errno)); |
247 | slog (L_ERR, _("system call `%s' failed: %s"), "mlockall", strerror (errno)); |
252 | #endif |
248 | #endif |
253 | |
249 | |