git ssb

0+

cel / sslh



Commit aa06261d70509eb5a571937d5e3d5c41e11f193d

added syslog_facility option

Yves Rutschle committed on 7/21/2017, 8:46:24 PM
Parent: dd900ebf3ec86a097f9cca945d6e95b62fa16a48

Files changed

ChangeLogchanged
common.cchanged
common.hchanged
example.cfgchanged
sslh-main.cchanged
ChangeLogView
@@ -1,4 +1,7 @@
1+ Added 'syslog_facility' configuration option to
2+ specify where to log.
3+
14 v1.18: 29MAR2016
25 Added USELIBPCRE to make use of regex engine
36 optional.
47
common.cView
@@ -3,8 +3,9 @@
33 *
44 * No code here should assume whether sockets are blocking or not.
55 **/
66
7+#define SYSLOG_NAMES
78 #define _GNU_SOURCE
89 #include <stdarg.h>
910 #include <grp.h>
1011
@@ -38,9 +39,9 @@
3839 int foreground = 0;
3940 int background = 0;
4041 int transparent = 0;
4142 int numeric = 0;
42-const char *user_name, *pid_file;
43+const char *user_name, *pid_file, *facility = "auth";
4344
4445 struct addrinfo *addr_listen = NULL; /* what addresses do we listen to? */
4546
4647 #ifdef LIBWRAP
@@ -638,14 +639,23 @@
638639 /* Open syslog connection with appropriate banner;
639640 * banner is made up of basename(bin_name)+"[pid]" */
640641 void setup_syslog(const char* bin_name) {
641642 char *name1, *name2;
642- int res;
643+ int res, fn;
643644
644645 name1 = strdup(bin_name);
645646 res = asprintf(&name2, "%s[%d]", basename(name1), getpid());
646647 CHECK_RES_DIE(res, "asprintf");
647- openlog(name2, LOG_CONS, LOG_AUTH);
648+
649+ for (fn = 0; facilitynames[fn].c_val != -1; fn++)
650+ if (strcmp(facilitynames[fn].c_name, facility) == 0)
651+ break;
652+ if (fn == -1) {
653+ fprintf(stderr, "Unknown facility %s\n", facility);
654+ exit(1);
655+ }
656+
657+ openlog(name2, LOG_CONS, fn);
648658 free(name1);
649659 /* Don't free name2, as openlog(3) uses it (at least in glibc) */
650660
651661 log_message(LOG_INFO, "%s %s started\n", server_type, VERSION);
common.hView
@@ -117,9 +117,9 @@
117117 background, transparent, numeric;
118118 extern struct sockaddr_storage addr_ssl, addr_ssh, addr_openvpn;
119119 extern struct addrinfo *addr_listen;
120120 extern const char* USAGE_STRING;
121-extern const char* user_name, *pid_file;
121+extern const char* user_name, *pid_file, *facility;
122122 extern const char* server_type;
123123
124124 /* sslh-fork.c */
125125 void start_shoveler(int);
example.cfgView
@@ -11,8 +11,13 @@
1111 timeout: 2;
1212 user: "nobody";
1313 pidfile: "/var/run/sslh.pid";
1414
15+# Specify which syslog facility to use (names for your
16+# system are usually defined in /usr/include/*/sys/syslog.h
17+# or equivalent)
18+# Default is "auth"
19+syslog_facility: "auth";
1520
1621 # List of interfaces on which we should listen
1722 # Options:
1823 listen:
sslh-main.cView
@@ -391,8 +391,10 @@
391391
392392 config_lookup_string(&config, "user", &user_name);
393393 config_lookup_string(&config, "pidfile", &pid_file);
394394
395+ config_lookup_string(&config, "syslog_facility", &facility);
396+
395397 config_listen(&config, listen);
396398 config_protocols(&config, prots);
397399
398400 return 0;

Built with git-ssb-web