aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-06-17 16:27:10 +0200
committerDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-06-17 16:27:26 +0200
commit8a8f49a501fd109bcb722afff7eb2c7852a04107 (patch)
tree10702f4086c6df7720c53ed4de5f81cb0d308c38
parentf1cc12f55ebb51209cb26e71985d35c5e6671520 (diff)
usyslogd: do logfile lookup by facility number
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
-rw-r--r--syslogd/logfile.c3
-rw-r--r--syslogd/logfile.h3
-rw-r--r--syslogd/main.c4
3 files changed, 6 insertions, 4 deletions
diff --git a/syslogd/logfile.c b/syslogd/logfile.c
index a59f7e7..5687750 100644
--- a/syslogd/logfile.c
+++ b/syslogd/logfile.c
@@ -25,7 +25,7 @@
#include "logfile.h"
-logfile_t *logfile_create(const char *name)
+logfile_t *logfile_create(const char *name, int facility)
{
logfile_t *file;
@@ -36,6 +36,7 @@ logfile_t *logfile_create(const char *name)
}
strcpy(file->name, name);
+ file->facility = facility;
file->fd = open(file->name, O_WRONLY | O_CREAT, 0640);
if (file->fd < 0)
diff --git a/syslogd/logfile.h b/syslogd/logfile.h
index 58da272..cf4a7d6 100644
--- a/syslogd/logfile.h
+++ b/syslogd/logfile.h
@@ -20,12 +20,13 @@
typedef struct logfile_t {
struct logfile_t *next;
+ int facility;
int fd;
char name[];
} logfile_t;
-logfile_t *logfile_create(const char *name);
+logfile_t *logfile_create(const char *name, int facility);
void logfile_destroy(logfile_t *file);
diff --git a/syslogd/main.c b/syslogd/main.c
index b1b70b0..79d6325 100644
--- a/syslogd/main.c
+++ b/syslogd/main.c
@@ -134,12 +134,12 @@ static int print_to_log(const syslog_msg_t *msg)
return -1;
for (log = logfiles; log != NULL; log = log->next) {
- if (!strcmp(log->name, fac_name))
+ if (log->facility == msg->facility)
break;
}
if (log == NULL) {
- log = logfile_create(fac_name);
+ log = logfile_create(fac_name, msg->facility);
if (log == NULL)
return -1;
log->next = logfiles;