diff --git a/ChangeLog b/ChangeLog index 847bd41..38565b3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ + Added 'syslog_facility' configuration option to + specify where to log. + v1.18: 29MAR2016 Added USELIBPCRE to make use of regex engine optional. diff --git a/common.c b/common.c index 810a610..5cfa80d 100644 --- a/common.c +++ b/common.c @@ -4,6 +4,7 @@ * No code here should assume whether sockets are blocking or not. **/ +#define SYSLOG_NAMES #define _GNU_SOURCE #include #include @@ -39,7 +40,7 @@ int foreground = 0; int background = 0; int transparent = 0; int numeric = 0; -const char *user_name, *pid_file; +const char *user_name, *pid_file, *facility = "auth"; struct addrinfo *addr_listen = NULL; /* what addresses do we listen to? */ @@ -639,12 +640,21 @@ void setup_signals(void) * banner is made up of basename(bin_name)+"[pid]" */ void setup_syslog(const char* bin_name) { char *name1, *name2; - int res; + int res, fn; name1 = strdup(bin_name); res = asprintf(&name2, "%s[%d]", basename(name1), getpid()); CHECK_RES_DIE(res, "asprintf"); - openlog(name2, LOG_CONS, LOG_AUTH); + + for (fn = 0; facilitynames[fn].c_val != -1; fn++) + if (strcmp(facilitynames[fn].c_name, facility) == 0) + break; + if (fn == -1) { + fprintf(stderr, "Unknown facility %s\n", facility); + exit(1); + } + + openlog(name2, LOG_CONS, fn); free(name1); /* Don't free name2, as openlog(3) uses it (at least in glibc) */ diff --git a/common.h b/common.h index c83eb91..de96633 100644 --- a/common.h +++ b/common.h @@ -118,7 +118,7 @@ extern int probing_timeout, verbose, inetd, foreground, extern struct sockaddr_storage addr_ssl, addr_ssh, addr_openvpn; extern struct addrinfo *addr_listen; extern const char* USAGE_STRING; -extern const char* user_name, *pid_file; +extern const char* user_name, *pid_file, *facility; extern const char* server_type; /* sslh-fork.c */ diff --git a/example.cfg b/example.cfg index b5cb37a..999f9a3 100644 --- a/example.cfg +++ b/example.cfg @@ -12,6 +12,11 @@ timeout: 2; user: "nobody"; pidfile: "/var/run/sslh.pid"; +# Specify which syslog facility to use (names for your +# system are usually defined in /usr/include/*/sys/syslog.h +# or equivalent) +# Default is "auth" +syslog_facility: "auth"; # List of interfaces on which we should listen # Options: diff --git a/sslh-main.c b/sslh-main.c index 289562b..e2a4e34 100644 --- a/sslh-main.c +++ b/sslh-main.c @@ -392,6 +392,8 @@ static int config_parse(char *filename, struct addrinfo **listen, struct proto * config_lookup_string(&config, "user", &user_name); config_lookup_string(&config, "pidfile", &pid_file); + config_lookup_string(&config, "syslog_facility", &facility); + config_listen(&config, listen); config_protocols(&config, prots);