added syslog_facility option

This commit is contained in:
Yves Rutschle 2017-07-21 22:46:24 +02:00
parent dd900ebf3e
commit aa06261d70
5 changed files with 24 additions and 4 deletions

View File

@ -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.

View File

@ -4,6 +4,7 @@
* No code here should assume whether sockets are blocking or not.
**/
#define SYSLOG_NAMES
#define _GNU_SOURCE
#include <stdarg.h>
#include <grp.h>
@ -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) */

View File

@ -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 */

View File

@ -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:

View File

@ -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);