Commit 02d56db6 authored by venaas's avatar venaas Committed by venaas

Can now specifiy syslog facility

git-svn-id: https://svn.testnett.uninett.no/radsecproxy/trunk@73 e88ac4ed-0b26-0410-9574-a7f39faa03bf
parent e103487a
...@@ -38,7 +38,14 @@ uint8_t debug_get_level() { ...@@ -38,7 +38,14 @@ uint8_t debug_get_level() {
} }
int debug_set_destination(char *dest) { int debug_set_destination(char *dest) {
static const char *facstrings[] = { "LOG_DAEMON", "LOG_MAIL", "LOG_USER", "LOG_LOCAL0",
"LOG_LOCAL1", "LOG_LOCAL2", "LOG_LOCAL3", "LOG_LOCAL4",
"LOG_LOCAL5", "LOG_LOCAL6", "LOG_LOCAL7", NULL };
static const int facvals[] = { LOG_DAEMON, LOG_MAIL, LOG_USER, LOG_LOCAL0,
LOG_LOCAL1, LOG_LOCAL2, LOG_LOCAL3, LOG_LOCAL4,
LOG_LOCAL5, LOG_LOCAL6, LOG_LOCAL7 };
extern int errno; extern int errno;
int i;
if (!strncasecmp(dest, "file:///", 8)) { if (!strncasecmp(dest, "file:///", 8)) {
debug_file = fopen(dest + 7, "a"); debug_file = fopen(dest + 7, "a");
...@@ -48,12 +55,22 @@ int debug_set_destination(char *dest) { ...@@ -48,12 +55,22 @@ int debug_set_destination(char *dest) {
setvbuf(debug_file, NULL, _IONBF, 0); setvbuf(debug_file, NULL, _IONBF, 0);
return 1; return 1;
} }
if (!strcasecmp(dest, "x-syslog://")) { if (!strncasecmp(dest, "x-syslog://", 11)) {
debug_syslogfacility = LOG_DAEMON; dest += 11;
if (*dest) {
for (i = 0; facstrings[i]; i++)
if (!strcasecmp(dest, facstrings[i]))
break;
if (!facstrings[i])
debugx(1, DBG_ERR, "Unknown syslog facility %s", dest);
debug_syslogfacility = facvals[i];
} else
debug_syslogfacility = LOG_DAEMON;
openlog(debug_ident, LOG_PID, debug_syslogfacility); openlog(debug_ident, LOG_PID, debug_syslogfacility);
return 1; return 1;
} }
return 0; debug(DBG_ERR, "Unknown log destination, exiting %s", dest);
exit(1);
} }
void debug_logit(uint8_t level, const char *format, va_list ap) { void debug_logit(uint8_t level, const char *format, va_list ap) {
......
...@@ -21,5 +21,9 @@ TLSCertificateKeyPassword follow the white rabbit ...@@ -21,5 +21,9 @@ TLSCertificateKeyPassword follow the white rabbit
# Optional log level. 2 is default, 1 is less, 3 is more # Optional log level. 2 is default, 1 is less, 3 is more
#LogLevel 2 #LogLevel 2
#Optional LogDestinatinon, else stderr used for logging #Optional LogDestinatinon, else stderr used for logging
#LogDestination x-syslog:// # Logging to file
#LogDestination file:///tmp/rp.log #LogDestination file:///tmp/rp.log
# Or logging with Syslog. LOG_DAEMON used if facility not specified
#LogDestination x-syslog://
#LogDestination x-syslog://log_local2
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment