sslh-main.cView |
---|
62 | 62 | { "transparent", no_argument, &transparent, 1 }, |
63 | 63 | { "numeric", no_argument, &numeric, 1 }, |
64 | 64 | { "verbose", no_argument, &verbose, 1 }, |
65 | 65 | { "user", required_argument, 0, 'u' }, |
66 | | - { "config", required_argument, 0, 'F' }, |
| 66 | + { "config", optional_argument, 0, 'F' }, |
67 | 67 | { "pidfile", required_argument, 0, 'P' }, |
68 | 68 | { "timeout", required_argument, 0, 't' }, |
69 | 69 | { "on-timeout", required_argument, 0, OPT_ONTIMEOUT }, |
70 | 70 | { "listen", required_argument, 0, 'p' }, |
71 | 71 | {} |
72 | 72 | }; |
73 | 73 | static struct option* all_options; |
74 | 74 | static struct proto* builtins; |
75 | | -static const char *optstr = "vt:T:p:VP:F:"; |
| 75 | +static const char *optstr = "vt:T:p:VP:F::"; |
76 | 76 | |
77 | 77 | |
78 | 78 | |
79 | 79 | static void print_usage(void) |
279 | 279 | const char* str; |
280 | 280 | |
281 | 281 | config_init(&config); |
282 | 282 | if (config_read_file(&config, filename) == CONFIG_FALSE) { |
283 | | - fprintf(stderr, "%s:%d:%s\n", |
| 283 | + if (config_error_type(&config) == CONFIG_ERR_PARSE) { |
| 284 | + fprintf(stderr, "%s:%d:%s\n", |
284 | 285 | filename, |
285 | 286 | config_error_line(&config), |
286 | 287 | config_error_text(&config)); |
287 | | - exit(1); |
| 288 | + exit(1); |
| 289 | + } |
| 290 | + return 1; |
288 | 291 | } |
289 | 292 | |
290 | 293 | config_lookup_bool(&config, "verbose", &verbose); |
291 | 294 | config_lookup_bool(&config, "inetd", &inetd); |
361 | 364 | opterr = 0; |
362 | 365 | while ((c = getopt_long_only(argc, argv, optstr, all_options, NULL)) != -1) { |
363 | 366 | if (c == 'F') { |
364 | 367 | config_filename = optarg; |
365 | | - |
366 | | - res = config_parse(config_filename, &addr_listen, prots); |
| 368 | + if (config_filename) { |
| 369 | + fprintf(stderr, "config: %s\n", config_filename); |
| 370 | + res = config_parse(config_filename, &addr_listen, prots); |
| 371 | + } else { |
| 372 | + |
| 373 | + res = config_parse("/etc/sslh/sslh.cfg", &addr_listen, prots); |
| 374 | + if (!res && verbose) fprintf(stderr, "Using /etc/sslh/sslh.cfg\n"); |
| 375 | + if (res) { |
| 376 | + res = config_parse("/etc/sslh.cfg", &addr_listen, prots); |
| 377 | + if (!res && verbose) fprintf(stderr, "Using /etc/sslh.cfg\n"); |
| 378 | + } |
| 379 | + } |
367 | 380 | if (res) |
368 | 381 | exit(4); |
369 | 382 | break; |
370 | 383 | } |