… | |
… | |
102 | parse_options (int argc, char **argv, char **envp) |
102 | parse_options (int argc, char **argv, char **envp) |
103 | { |
103 | { |
104 | int r; |
104 | int r; |
105 | int option_index = 0; |
105 | int option_index = 0; |
106 | |
106 | |
107 | while ((r = getopt_long (argc, argv, "-c:DLl:", long_options, &option_index)) != EOF) |
107 | while ((r = getopt_long (argc, argv, "c:DLl:", long_options, &option_index)) != EOF) |
108 | { |
108 | { |
109 | switch (r) |
109 | switch (r) |
110 | { |
110 | { |
111 | case 0: /* long option */ |
111 | case 0: /* long option */ |
112 | break; |
|
|
113 | |
|
|
114 | case 1: /* this node name */ |
|
|
115 | thisnode = strdup (optarg); |
|
|
116 | break; |
112 | break; |
117 | |
113 | |
118 | case 'c': /* config file */ |
114 | case 'c': /* config file */ |
119 | confbase = strdup (optarg); |
115 | confbase = strdup (optarg); |
120 | break; |
116 | break; |
… | |
… | |
197 | act.sa_flags = 0; |
193 | act.sa_flags = 0; |
198 | |
194 | |
199 | act.sa_handler = sighup_handler; sigaction (SIGHUP , &act, NULL); |
195 | act.sa_handler = sighup_handler; sigaction (SIGHUP , &act, NULL); |
200 | act.sa_handler = sigusr1_handler; sigaction (SIGUSR1, &act, NULL); |
196 | act.sa_handler = sigusr1_handler; sigaction (SIGUSR1, &act, NULL); |
201 | act.sa_handler = sigusr2_handler; sigaction (SIGUSR2, &act, NULL); |
197 | act.sa_handler = sigusr2_handler; sigaction (SIGUSR2, &act, NULL); |
202 | act.sa_handler = SIG_IGN; sigaction (SIGCHLD, &act, NULL); |
198 | // act.sa_handler = SIG_IGN; sigaction (SIGCHLD, &act, NULL); |
203 | act.sa_handler = SIG_IGN; sigaction (SIGPIPE, &act, NULL); |
199 | act.sa_handler = SIG_IGN; sigaction (SIGPIPE, &act, NULL); |
204 | act.sa_flags = SA_RESETHAND; |
200 | act.sa_flags = SA_RESETHAND; |
205 | act.sa_handler = sigterm_handler; sigaction (SIGINT , &act, NULL); |
201 | act.sa_handler = sigterm_handler; sigaction (SIGINT , &act, NULL); |
206 | act.sa_handler = sigterm_handler; sigaction (SIGTERM, &act, NULL); |
202 | act.sa_handler = sigterm_handler; sigaction (SIGTERM, &act, NULL); |
207 | } |
203 | } |
… | |
… | |
218 | setlocale (LC_ALL, ""); |
214 | setlocale (LC_ALL, ""); |
219 | bindtextdomain (PACKAGE, LOCALEDIR); |
215 | bindtextdomain (PACKAGE, LOCALEDIR); |
220 | textdomain (PACKAGE); |
216 | textdomain (PACKAGE); |
221 | |
217 | |
222 | parse_options (argc, argv, envp); |
218 | parse_options (argc, argv, envp); |
|
|
219 | |
|
|
220 | argc -= optind; |
|
|
221 | argv += optind; |
223 | |
222 | |
224 | if (show_version) |
223 | if (show_version) |
225 | { |
224 | { |
226 | printf (_("%s version %s (built %s %s, protocol %d.%d)\n"), get_identity (), |
225 | printf (_("%s version %s (built %s %s, protocol %d.%d)\n"), get_identity (), |
227 | VERSION, __DATE__, __TIME__, PROTOCOL_MAJOR, PROTOCOL_MINOR); |
226 | VERSION, __DATE__, __TIME__, PROTOCOL_MAJOR, PROTOCOL_MINOR); |
… | |
… | |
247 | if (do_mlock) |
246 | if (do_mlock) |
248 | if (mlockall (MCL_CURRENT | MCL_FUTURE)) |
247 | if (mlockall (MCL_CURRENT | MCL_FUTURE)) |
249 | slog (L_ERR, _("system call `%s' failed: %s"), "mlockall", strerror (errno)); |
248 | slog (L_ERR, _("system call `%s' failed: %s"), "mlockall", strerror (errno)); |
250 | #endif |
249 | #endif |
251 | |
250 | |
252 | conf.read_config (true); |
251 | if (argc >= 1) |
|
|
252 | { |
|
|
253 | thisnode = *argv++; |
|
|
254 | argc--; |
|
|
255 | } |
|
|
256 | |
|
|
257 | { |
|
|
258 | configuration_parser (conf, true, argc, argv); |
|
|
259 | } |
253 | |
260 | |
254 | set_loglevel (llevel != L_NONE ? llevel : conf.llevel); |
261 | set_loglevel (llevel != L_NONE ? llevel : conf.llevel); |
255 | |
262 | |
256 | RAND_load_file ("/dev/urandom", 1024); |
263 | RAND_load_file ("/dev/urandom", 1024); |
257 | |
264 | |