1
0
Fork 0
mirror of https://github.com/pygos/init.git synced 2024-05-19 20:26:14 +02:00

usyslogd: do logfile lookup by facility number

Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
This commit is contained in:
David Oberhollenzer 2018-06-17 16:27:10 +02:00
parent f1cc12f55e
commit 8a8f49a501
3 changed files with 6 additions and 4 deletions

View file

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

View file

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

View file

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