git ssb

0+

cel / sslh



Commit bb4aeb446a72c7a279b9551e63e1c91a1a7f9553

Use default configuration filename

Yves Rutschle committed on 12/27/2014, 10:57:27 AM
Parent: 74de4f4fd22375fae4d21eeb920326fc6a905586

Files changed

ChangeLogchanged
sslh-main.cchanged
ChangeLogView
@@ -3,8 +3,14 @@
33
44 Transparant proxy support for FreeBSD.
55 (Ruben van Staveren)
66
7+ Using -F with no argument will try
8+ /etc/sslh/sslh.cfg and then /etc/sslh.cfg as
9+ configuration files. (argument to -F can no longer
10+ be separated from the option by a space, e.g. must
11+ be -Ffoo.cfg)
12+
713 Call setgroups() before setgid() (fixes potential
814 privilege escalation).
915 (Lars Vogdt)
1016
sslh-main.cView
@@ -62,18 +62,18 @@
6262 { "transparent", no_argument, &transparent, 1 },
6363 { "numeric", no_argument, &numeric, 1 },
6464 { "verbose", no_argument, &verbose, 1 },
6565 { "user", required_argument, 0, 'u' },
66- { "config", required_argument, 0, 'F' },
66+ { "config", optional_argument, 0, 'F' },
6767 { "pidfile", required_argument, 0, 'P' },
6868 { "timeout", required_argument, 0, 't' },
6969 { "on-timeout", required_argument, 0, OPT_ONTIMEOUT },
7070 { "listen", required_argument, 0, 'p' },
7171 {}
7272 };
7373 static struct option* all_options;
7474 static struct proto* builtins;
75-static const char *optstr = "vt:T:p:VP:F:";
75+static const char *optstr = "vt:T:p:VP:F::";
7676
7777
7878
7979 static void print_usage(void)
@@ -279,13 +279,16 @@
279279 const char* str;
280280
281281 config_init(&config);
282282 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",
284285 filename,
285286 config_error_line(&config),
286287 config_error_text(&config));
287- exit(1);
288+ exit(1);
289+ }
290+ return 1;
288291 }
289292
290293 config_lookup_bool(&config, "verbose", &verbose);
291294 config_lookup_bool(&config, "inetd", &inetd);
@@ -361,10 +364,20 @@
361364 opterr = 0; /* we're missing protocol options at this stage so don't output errors */
362365 while ((c = getopt_long_only(argc, argv, optstr, all_options, NULL)) != -1) {
363366 if (c == 'F') {
364367 config_filename = optarg;
365- /* find the end of the listen list */
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+ /* No configuration file specified -- try default file locations */
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+ }
367380 if (res)
368381 exit(4);
369382 break;
370383 }

Built with git-ssb-web