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:
parent
74de4f4fd2
commit
bb4aeb446a
@ -4,6 +4,12 @@ vNEXT:
|
||||
Transparant proxy support for FreeBSD.
|
||||
(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
|
||||
privilege escalation).
|
||||
(Lars Vogdt)
|
||||
|
19
sslh-main.c
19
sslh-main.c
@ -63,7 +63,7 @@ static struct option const_options[] = {
|
||||
{ "numeric", no_argument, &numeric, 1 },
|
||||
{ "verbose", no_argument, &verbose, 1 },
|
||||
{ "user", required_argument, 0, 'u' },
|
||||
{ "config", required_argument, 0, 'F' },
|
||||
{ "config", optional_argument, 0, 'F' },
|
||||
{ "pidfile", required_argument, 0, 'P' },
|
||||
{ "timeout", required_argument, 0, 't' },
|
||||
{ "on-timeout", required_argument, 0, OPT_ONTIMEOUT },
|
||||
@ -72,7 +72,7 @@ static struct option const_options[] = {
|
||||
};
|
||||
static struct option* all_options;
|
||||
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);
|
||||
if (config_read_file(&config, filename) == CONFIG_FALSE) {
|
||||
if (config_error_type(&config) == CONFIG_ERR_PARSE) {
|
||||
fprintf(stderr, "%s:%d:%s\n",
|
||||
filename,
|
||||
config_error_line(&config),
|
||||
config_error_text(&config));
|
||||
exit(1);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
config_lookup_bool(&config, "verbose", &verbose);
|
||||
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) {
|
||||
if (c == 'F') {
|
||||
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);
|
||||
} 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)
|
||||
exit(4);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user