1
0
mirror of https://github.com/moparisthebest/sslh synced 2024-11-24 18:12:17 -05:00

Use default configuration filename

This commit is contained in:
Yves Rutschle 2014-12-27 11:57:27 +01:00
parent 74de4f4fd2
commit bb4aeb446a
2 changed files with 25 additions and 6 deletions

View File

@ -4,6 +4,12 @@ vNEXT:
Transparant proxy support for FreeBSD. Transparant proxy support for FreeBSD.
(Ruben van Staveren) (Ruben van Staveren)
Using -F with no argument will try
/etc/sslh/sslh.cfg and then /etc/sslh.cfg as
configuration files. (argument to -F can no longer
be separated from the option by a space, e.g. must
be -Ffoo.cfg)
Call setgroups() before setgid() (fixes potential Call setgroups() before setgid() (fixes potential
privilege escalation). privilege escalation).
(Lars Vogdt) (Lars Vogdt)

View File

@ -63,7 +63,7 @@ static struct option const_options[] = {
{ "numeric", no_argument, &numeric, 1 }, { "numeric", no_argument, &numeric, 1 },
{ "verbose", no_argument, &verbose, 1 }, { "verbose", no_argument, &verbose, 1 },
{ "user", required_argument, 0, 'u' }, { "user", required_argument, 0, 'u' },
{ "config", required_argument, 0, 'F' }, { "config", optional_argument, 0, 'F' },
{ "pidfile", required_argument, 0, 'P' }, { "pidfile", required_argument, 0, 'P' },
{ "timeout", required_argument, 0, 't' }, { "timeout", required_argument, 0, 't' },
{ "on-timeout", required_argument, 0, OPT_ONTIMEOUT }, { "on-timeout", required_argument, 0, OPT_ONTIMEOUT },
@ -72,7 +72,7 @@ static struct option const_options[] = {
}; };
static struct option* all_options; static struct option* all_options;
static struct proto* builtins; static struct proto* builtins;
static const char *optstr = "vt:T:p:VP:F:"; static const char *optstr = "vt:T:p:VP:F::";
@ -280,12 +280,15 @@ static int config_parse(char *filename, struct addrinfo **listen, struct proto *
config_init(&config); config_init(&config);
if (config_read_file(&config, filename) == CONFIG_FALSE) { if (config_read_file(&config, filename) == CONFIG_FALSE) {
if (config_error_type(&config) == CONFIG_ERR_PARSE) {
fprintf(stderr, "%s:%d:%s\n", fprintf(stderr, "%s:%d:%s\n",
filename, filename,
config_error_line(&config), config_error_line(&config),
config_error_text(&config)); config_error_text(&config));
exit(1); exit(1);
} }
return 1;
}
config_lookup_bool(&config, "verbose", &verbose); config_lookup_bool(&config, "verbose", &verbose);
config_lookup_bool(&config, "inetd", &inetd); config_lookup_bool(&config, "inetd", &inetd);
@ -362,8 +365,18 @@ static void cmdline_config(int argc, char* argv[], struct proto** prots)
while ((c = getopt_long_only(argc, argv, optstr, all_options, NULL)) != -1) { while ((c = getopt_long_only(argc, argv, optstr, all_options, NULL)) != -1) {
if (c == 'F') { if (c == 'F') {
config_filename = optarg; config_filename = optarg;
/* find the end of the listen list */ if (config_filename) {
fprintf(stderr, "config: %s\n", config_filename);
res = config_parse(config_filename, &addr_listen, prots); res = config_parse(config_filename, &addr_listen, prots);
} else {
/* No configuration file specified -- try default file locations */
res = config_parse("/etc/sslh/sslh.cfg", &addr_listen, prots);
if (!res && verbose) fprintf(stderr, "Using /etc/sslh/sslh.cfg\n");
if (res) {
res = config_parse("/etc/sslh.cfg", &addr_listen, prots);
if (!res && verbose) fprintf(stderr, "Using /etc/sslh.cfg\n");
}
}
if (res) if (res)
exit(4); exit(4);
break; break;