Changeset View
Changeset View
Standalone View
Standalone View
head/usr.sbin/syslogd/syslogd.c
Show First 20 Lines • Show All 174 Lines • ▼ Show 20 Lines | |||||
#define SYNC_FILE 0x002 /* do fsync on file after printing */ | #define SYNC_FILE 0x002 /* do fsync on file after printing */ | ||||
#define MARK 0x008 /* this message is a mark */ | #define MARK 0x008 /* this message is a mark */ | ||||
#define ISKERNEL 0x010 /* kernel generated message */ | #define ISKERNEL 0x010 /* kernel generated message */ | ||||
/* | /* | ||||
* This structure represents the files that will have log | * This structure represents the files that will have log | ||||
* copies printed. | * copies printed. | ||||
* We require f_file to be valid if f_type is F_FILE, F_CONSOLE, F_TTY | * We require f_file to be valid if f_type is F_FILE, F_CONSOLE, F_TTY | ||||
* or if f_type if F_PIPE and f_pid > 0. | * or if f_type is F_PIPE and f_pid > 0. | ||||
*/ | */ | ||||
struct filed { | struct filed { | ||||
STAILQ_ENTRY(filed) next; /* next in linked list */ | STAILQ_ENTRY(filed) next; /* next in linked list */ | ||||
short f_type; /* entry type, see below */ | short f_type; /* entry type, see below */ | ||||
short f_file; /* file descriptor */ | short f_file; /* file descriptor */ | ||||
time_t f_time; /* time this was last written */ | time_t f_time; /* time this was last written */ | ||||
char *f_host; /* host from which to recd. */ | char *f_host; /* host from which to recd. */ | ||||
▲ Show 20 Lines • Show All 185 Lines • ▼ Show 20 Lines | |||||
static void | static void | ||||
close_filed(struct filed *f) | close_filed(struct filed *f) | ||||
{ | { | ||||
if (f == NULL || f->f_file == -1) | if (f == NULL || f->f_file == -1) | ||||
return; | return; | ||||
switch (f->f_type) { | switch (f->f_type) { | ||||
case F_FORW: | |||||
if (f->f_un.f_forw.f_addr) { | |||||
freeaddrinfo(f->f_un.f_forw.f_addr); | |||||
f->f_un.f_forw.f_addr = NULL; | |||||
} | |||||
/*FALLTHROUGH*/ | |||||
case F_FILE: | case F_FILE: | ||||
case F_TTY: | case F_TTY: | ||||
case F_CONSOLE: | case F_CONSOLE: | ||||
case F_FORW: | |||||
f->f_type = F_UNUSED; | f->f_type = F_UNUSED; | ||||
break; | break; | ||||
case F_PIPE: | case F_PIPE: | ||||
f->fu_pipe_pid = 0; | f->fu_pipe_pid = 0; | ||||
break; | break; | ||||
} | } | ||||
(void)close(f->f_file); | (void)close(f->f_file); | ||||
f->f_file = -1; | f->f_file = -1; | ||||
▲ Show 20 Lines • Show All 1,457 Lines • ▼ Show 20 Lines | for (p = cline + 1; *p != '\0'; p++) { | ||||
*p = '\0'; | *p = '\0'; | ||||
break; | break; | ||||
} | } | ||||
for (i = strlen(cline) - 1; i >= 0 && isspace(cline[i]); i--) | for (i = strlen(cline) - 1; i >= 0 && isspace(cline[i]); i--) | ||||
cline[i] = '\0'; | cline[i] = '\0'; | ||||
f = cfline(cline, prog, host); | f = cfline(cline, prog, host); | ||||
if (f != NULL) | if (f != NULL) | ||||
addfile(f); | addfile(f); | ||||
free(f); | |||||
} | } | ||||
} | } | ||||
static void | static void | ||||
sighandler(int signo) | sighandler(int signo) | ||||
{ | { | ||||
/* Send an wake-up signal to the select() loop. */ | /* Send an wake-up signal to the select() loop. */ | ||||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | init(int signo) | ||||
} | } | ||||
/* open the configuration file */ | /* open the configuration file */ | ||||
if ((cf = fopen(ConfFile, "r")) == NULL) { | if ((cf = fopen(ConfFile, "r")) == NULL) { | ||||
dprintf("cannot open %s\n", ConfFile); | dprintf("cannot open %s\n", ConfFile); | ||||
f = cfline("*.ERR\t/dev/console", "*", "*"); | f = cfline("*.ERR\t/dev/console", "*", "*"); | ||||
if (f != NULL) | if (f != NULL) | ||||
addfile(f); | addfile(f); | ||||
free(f); | |||||
f = cfline("*.PANIC\t*", "*", "*"); | f = cfline("*.PANIC\t*", "*", "*"); | ||||
if (f != NULL) | if (f != NULL) | ||||
addfile(f); | addfile(f); | ||||
free(f); | |||||
Initialized = 1; | Initialized = 1; | ||||
return; | return; | ||||
} | } | ||||
readconfigfile(cf, 1); | readconfigfile(cf, 1); | ||||
/* close the configuration file */ | /* close the configuration file */ | ||||
▲ Show 20 Lines • Show All 1,122 Lines • Show Last 20 Lines |