Changeset View
Standalone View
usr.sbin/syslogd/syslogd.c
Show First 20 Lines • Show All 2,397 Lines • ▼ Show 20 Lines | configfiles(const struct dirent *dp) | ||||
p = &dp->d_name[dp->d_namlen - ext_len]; | p = &dp->d_name[dp->d_namlen - ext_len]; | ||||
if (strcmp(p, include_ext) != 0) | if (strcmp(p, include_ext) != 0) | ||||
return (0); | return (0); | ||||
return (1); | return (1); | ||||
} | } | ||||
static void | static void | ||||
readconfigfile(FILE *cf, int allow_includes) | parseconfigfile(FILE *cf, bool allow_includes) | ||||
{ | { | ||||
FILE *cf2; | FILE *cf2; | ||||
struct filed *f; | struct filed *f; | ||||
struct dirent **ent; | struct dirent **ent; | ||||
char cline[LINE_MAX]; | char cline[LINE_MAX]; | ||||
char host[MAXHOSTNAMELEN]; | char host[MAXHOSTNAMELEN]; | ||||
char prog[LINE_MAX]; | char prog[LINE_MAX]; | ||||
char file[MAXPATHLEN]; | char file[MAXPATHLEN]; | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | if (allow_includes && | ||||
free(ent[i]); | free(ent[i]); | ||||
continue; | continue; | ||||
} | } | ||||
free(ent[i]); | free(ent[i]); | ||||
cf2 = fopen(file, "r"); | cf2 = fopen(file, "r"); | ||||
if (cf2 == NULL) | if (cf2 == NULL) | ||||
continue; | continue; | ||||
dprintf("reading %s\n", file); | dprintf("reading %s\n", file); | ||||
readconfigfile(cf2, 0); | parseconfigfile(cf2, false); | ||||
fclose(cf2); | fclose(cf2); | ||||
markj: This inverts the flag, but the commit message makes this seem unintentional. | |||||
Done Inline Actions
Ah, I ended up removing the allow_includes parameter later because of this unintentional flip. I don't see why recursive includes would be an issue, unless you had an inclusion loop. Maybe this is there to mitigate that? jfree: > This inverts the flag, but the commit message makes this seem unintentional.
Ah, I ended up… | |||||
Not Done Inline ActionsYes, I'm fairly sure this is a low-tech mechanism to avoid infinite loops. markj: Yes, I'm fairly sure this is a low-tech mechanism to avoid infinite loops. | |||||
} | } | ||||
free(ent); | free(ent); | ||||
continue; | continue; | ||||
} | } | ||||
if (*p == '#') { | if (*p == '#') { | ||||
p++; | p++; | ||||
if (*p == '\0' || strchr("!+-:", *p) == NULL) | if (*p == '\0' || strchr("!+-:", *p) == NULL) | ||||
continue; | continue; | ||||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | while (fgets(cline, sizeof(cline), cf) != NULL) { | ||||
f = cfline(cline, prog, host, pfilter); | f = cfline(cline, prog, host, pfilter); | ||||
if (f != NULL) | if (f != NULL) | ||||
addfile(f); | addfile(f); | ||||
free(f); | free(f); | ||||
} | } | ||||
} | } | ||||
static void | static void | ||||
readconfigfile(const char *path) | |||||
{ | |||||
FILE *cf; | |||||
struct filed *f; | |||||
if ((cf = fopen(path, "r")) != NULL) { | |||||
Not Done Inline ActionsI would drop this comment too, in the spirit of "comments should explain why, not what." markj: I would drop this comment too, in the spirit of "comments should explain why, not what." | |||||
parseconfigfile(cf, true); | |||||
(void)fclose(cf); | |||||
} else { | |||||
dprintf("cannot open %s\n", ConfFile); | |||||
f = cfline("*.ERR\t/dev/console", "*", "*", "*"); | |||||
if (f != NULL) | |||||
addfile(f); | |||||
free(f); | |||||
f = cfline("*.PANIC\t*", "*", "*", "*"); | |||||
if (f != NULL) | |||||
addfile(f); | |||||
free(f); | |||||
} | |||||
} | |||||
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. */ | ||||
write(sigpipe[1], &signo, sizeof(signo)); | write(sigpipe[1], &signo, sizeof(signo)); | ||||
} | } | ||||
/* | /* | ||||
* INIT -- Initialize syslogd from configuration table | * INIT -- Initialize syslogd from configuration table | ||||
*/ | */ | ||||
static void | static void | ||||
init(int signo) | init(int signo) | ||||
{ | { | ||||
int i; | int i; | ||||
FILE *cf; | |||||
struct filed *f; | struct filed *f; | ||||
char *p; | char *p; | ||||
char oldLocalHostName[MAXHOSTNAMELEN]; | char oldLocalHostName[MAXHOSTNAMELEN]; | ||||
char hostMsg[2*MAXHOSTNAMELEN+40]; | char hostMsg[2*MAXHOSTNAMELEN+40]; | ||||
char bootfileMsg[MAXLINE + 1]; | char bootfileMsg[MAXLINE + 1]; | ||||
dprintf("init\n"); | dprintf("init\n"); | ||||
WantInitialize = 0; | WantInitialize = 0; | ||||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | if (f->f_prop_filter) { | ||||
free(f->f_prop_filter->pflt_strval); | free(f->f_prop_filter->pflt_strval); | ||||
break; | break; | ||||
} | } | ||||
free(f->f_prop_filter); | free(f->f_prop_filter); | ||||
} | } | ||||
free(f); | free(f); | ||||
} | } | ||||
/* open the configuration file */ | readconfigfile(ConfFile); | ||||
if ((cf = fopen(ConfFile, "r")) == NULL) { | |||||
dprintf("cannot open %s\n", ConfFile); | |||||
f = cfline("*.ERR\t/dev/console", "*", "*", "*"); | |||||
if (f != NULL) | |||||
addfile(f); | |||||
free(f); | |||||
f = cfline("*.PANIC\t*", "*", "*", "*"); | |||||
if (f != NULL) | |||||
addfile(f); | |||||
free(f); | |||||
Initialized = 1; | |||||
return; | |||||
Not Done Inline ActionsWe no longer return early in this case. I think that's probably ok though? markj: We no longer return early in this case. I think that's probably ok though? | |||||
Done Inline Actions
Yeah, I went through the logic when I made this change. There shouldn't be an error in removing the early return. jfree: > We no longer return early in this case. I think that's probably ok though?
Yeah, I went… | |||||
Not Done Inline ActionsOk. In general I would suggest including this kind of information in the review/commit description, since otherwise it's hard to tell if this is intentional or not. markj: Ok. In general I would suggest including this kind of information in the review/commit… | |||||
} | |||||
readconfigfile(cf, 1); | |||||
/* close the configuration file */ | |||||
(void)fclose(cf); | |||||
Initialized = 1; | Initialized = 1; | ||||
if (Debug) { | if (Debug) { | ||||
int port; | int port; | ||||
STAILQ_FOREACH(f, &fhead, next) { | STAILQ_FOREACH(f, &fhead, next) { | ||||
for (i = 0; i <= LOG_NFACILITIES; i++) | for (i = 0; i <= LOG_NFACILITIES; i++) | ||||
if (f->f_pmask[i] == INTERNAL_NOPRI) | if (f->f_pmask[i] == INTERNAL_NOPRI) | ||||
printf("X "); | printf("X "); | ||||
▲ Show 20 Lines • Show All 1,290 Lines • Show Last 20 Lines |
This inverts the flag, but the commit message makes this seem unintentional.