Commit aa06261d70509eb5a571937d5e3d5c41e11f193d
added syslog_facility option
Yves Rutschle committed on 7/21/2017, 8:46:24 PMParent: dd900ebf3ec86a097f9cca945d6e95b62fa16a48
Files changed
ChangeLog | changed |
common.c | changed |
common.h | changed |
example.cfg | changed |
sslh-main.c | changed |
ChangeLog | ||
---|---|---|
@@ -1,4 +1,7 @@ | ||
1 | + Added 'syslog_facility' configuration option to | |
2 | + specify where to log. | |
3 | + | |
1 | 4 | v1.18: 29MAR2016 |
2 | 5 | Added USELIBPCRE to make use of regex engine |
3 | 6 | optional. |
4 | 7 |
common.c | ||
---|---|---|
@@ -3,8 +3,9 @@ | ||
3 | 3 | * |
4 | 4 | * No code here should assume whether sockets are blocking or not. |
5 | 5 | **/ |
6 | 6 | |
7 | + | |
7 | 8 | |
8 | 9 | |
9 | 10 | |
10 | 11 | |
@@ -38,9 +39,9 @@ | ||
38 | 39 | int foreground = 0; |
39 | 40 | int background = 0; |
40 | 41 | int transparent = 0; |
41 | 42 | int numeric = 0; |
42 | -const char *user_name, *pid_file; | |
43 | +const char *user_name, *pid_file, *facility = "auth"; | |
43 | 44 | |
44 | 45 | struct addrinfo *addr_listen = NULL; /* what addresses do we listen to? */ |
45 | 46 | |
46 | 47 | |
@@ -638,14 +639,23 @@ | ||
638 | 639 | /* Open syslog connection with appropriate banner; |
639 | 640 | * banner is made up of basename(bin_name)+"[pid]" */ |
640 | 641 | void setup_syslog(const char* bin_name) { |
641 | 642 | char *name1, *name2; |
642 | - int res; | |
643 | + int res, fn; | |
643 | 644 | |
644 | 645 | name1 = strdup(bin_name); |
645 | 646 | res = asprintf(&name2, "%s[%d]", basename(name1), getpid()); |
646 | 647 | 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); | |
648 | 658 | free(name1); |
649 | 659 | /* Don't free name2, as openlog(3) uses it (at least in glibc) */ |
650 | 660 | |
651 | 661 | log_message(LOG_INFO, "%s %s started\n", server_type, VERSION); |
common.h | ||
---|---|---|
@@ -117,9 +117,9 @@ | ||
117 | 117 | background, transparent, numeric; |
118 | 118 | extern struct sockaddr_storage addr_ssl, addr_ssh, addr_openvpn; |
119 | 119 | extern struct addrinfo *addr_listen; |
120 | 120 | extern const char* USAGE_STRING; |
121 | -extern const char* user_name, *pid_file; | |
121 | +extern const char* user_name, *pid_file, *facility; | |
122 | 122 | extern const char* server_type; |
123 | 123 | |
124 | 124 | /* sslh-fork.c */ |
125 | 125 | void start_shoveler(int); |
example.cfg | ||
---|---|---|
@@ -11,8 +11,13 @@ | ||
11 | 11 | timeout: 2; |
12 | 12 | user: "nobody"; |
13 | 13 | pidfile: "/var/run/sslh.pid"; |
14 | 14 | |
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"; | |
15 | 20 | |
16 | 21 | # List of interfaces on which we should listen |
17 | 22 | # Options: |
18 | 23 | listen: |
sslh-main.c | ||
---|---|---|
@@ -391,8 +391,10 @@ | ||
391 | 391 | |
392 | 392 | config_lookup_string(&config, "user", &user_name); |
393 | 393 | config_lookup_string(&config, "pidfile", &pid_file); |
394 | 394 | |
395 | + config_lookup_string(&config, "syslog_facility", &facility); | |
396 | + | |
395 | 397 | config_listen(&config, listen); |
396 | 398 | config_protocols(&config, prots); |
397 | 399 | |
398 | 400 | return 0; |
Built with git-ssb-web