Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/syslogd/syslogd.c
| Show First 20 Lines • Show All 2,451 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 | ||||
| parseconfigfile(FILE *cf, bool allow_includes) | parseconfigfile(FILE *cf) | ||||
| { | { | ||||
| FILE *cf2; | FILE *cf2; | ||||
| 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]; | ||||
| char pfilter[LINE_MAX]; | char pfilter[LINE_MAX]; | ||||
| Show All 13 Lines | while (fgets(cline, sizeof(cline), cf) != NULL) { | ||||
| * check for end-of-section, comments, strip off trailing | * check for end-of-section, comments, strip off trailing | ||||
| * spaces and newline character. #!prog is treated specially: | * spaces and newline character. #!prog is treated specially: | ||||
| * following lines apply only to that program. | * following lines apply only to that program. | ||||
| */ | */ | ||||
| for (p = cline; isspace(*p); ++p) | for (p = cline; isspace(*p); ++p) | ||||
| continue; | continue; | ||||
| if (*p == '\0') | if (*p == '\0') | ||||
| continue; | continue; | ||||
| if (allow_includes && | if (strncmp(p, include_str, include_len) == 0 && | ||||
| strncmp(p, include_str, include_len) == 0 && | |||||
| isspace(p[include_len])) { | isspace(p[include_len])) { | ||||
| p += include_len; | p += include_len; | ||||
| while (isspace(*p)) | while (isspace(*p)) | ||||
| p++; | p++; | ||||
| tmp = p; | tmp = p; | ||||
| while (*tmp != '\0' && !isspace(*tmp)) | while (*tmp != '\0' && !isspace(*tmp)) | ||||
| tmp++; | tmp++; | ||||
| *tmp = '\0'; | *tmp = '\0'; | ||||
| Show All 12 Lines | if (strncmp(p, include_str, include_len) == 0 && | ||||
| 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); | ||||
| parseconfigfile(cf2, true); | parseconfigfile(cf2); | ||||
| (void)fclose(cf2); | (void)fclose(cf2); | ||||
| } | } | ||||
| free(ent); | free(ent); | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (*p == '#') { | if (*p == '#') { | ||||
| p++; | p++; | ||||
| if (*p == '\0' || strchr("!+-:", *p) == NULL) | if (*p == '\0' || strchr("!+-:", *p) == NULL) | ||||
| ▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | |||||
| static void | static void | ||||
| readconfigfile(const char *path) | readconfigfile(const char *path) | ||||
| { | { | ||||
| FILE *cf; | FILE *cf; | ||||
| /* open the configuration file */ | /* open the configuration file */ | ||||
| if ((cf = fopen(path, "r")) != NULL) { | if ((cf = fopen(path, "r")) != NULL) { | ||||
| parseconfigfile(cf, true); | parseconfigfile(cf); | ||||
| (void)fclose(cf); | (void)fclose(cf); | ||||
| } else { | } else { | ||||
| dprintf("cannot open %s\n", ConfFile); | dprintf("cannot open %s\n", ConfFile); | ||||
| cfline("*.ERR\t/dev/console", "*", "*", "*"); | cfline("*.ERR\t/dev/console", "*", "*", "*"); | ||||
| cfline("*.PANIC\t*", "*", "*", "*"); | cfline("*.PANIC\t*", "*", "*", "*"); | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 1,169 Lines • Show Last 20 Lines | |||||