Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/syslogd/syslogd.c
| Show First 20 Lines • Show All 428 Lines • ▼ Show 20 Lines | |||||
| static int deadq_removebypid(pid_t); | static int deadq_removebypid(pid_t); | ||||
| static int decode(const char *, const CODE *); | static int decode(const char *, const CODE *); | ||||
| static void die(int) __dead2; | static void die(int) __dead2; | ||||
| static void dofsync(void); | static void dofsync(void); | ||||
| static void fprintlog_first(struct filed *, const char *, const char *, | static void fprintlog_first(struct filed *, const char *, const char *, | ||||
| const char *, const char *, const char *, const char *, int); | const char *, const char *, const char *, const char *, int); | ||||
| static void fprintlog_write(struct filed *, struct iovlist *, int); | static void fprintlog_write(struct filed *, struct iovlist *, int); | ||||
| static void fprintlog_successive(struct filed *, int); | static void fprintlog_successive(struct filed *, int); | ||||
| static void init(int); | static void init(bool); | ||||
| static void logerror(const char *); | static void logerror(const char *); | ||||
| static void logmsg(int, const struct logtime *, const char *, const char *, | static void logmsg(int, const struct logtime *, const char *, const char *, | ||||
| const char *, const char *, const char *, const char *, int); | const char *, const char *, const char *, const char *, int); | ||||
| static void log_deadchild(pid_t, int, const char *); | static void log_deadchild(pid_t, int, const char *); | ||||
| static void markit(void); | static void markit(void); | ||||
| static int socksetup(struct peer *); | static int socksetup(struct peer *); | ||||
| static int socklist_recv_file(struct socklist *); | static int socklist_recv_file(struct socklist *); | ||||
| static int socklist_recv_sock(struct socklist *); | static int socklist_recv_sock(struct socklist *); | ||||
| ▲ Show 20 Lines • Show All 2,042 Lines • ▼ Show 20 Lines | if ((cf = fopen(path, "r")) != NULL) { | ||||
| cfline("*.PANIC\t*", "*", "*", "*"); | cfline("*.PANIC\t*", "*", "*", "*"); | ||||
| } | } | ||||
| } | } | ||||
| /* | /* | ||||
| * INIT -- Initialize syslogd from configuration table | * INIT -- Initialize syslogd from configuration table | ||||
| */ | */ | ||||
| static void | static void | ||||
| init(int signo) | init(bool reload) | ||||
| { | { | ||||
| int i; | int i; | ||||
| 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"); | ||||
| /* | /* | ||||
| * Load hostname (may have changed). | * Load hostname (may have changed). | ||||
| */ | */ | ||||
| if (signo != 0) | if (reload) | ||||
| (void)strlcpy(oldLocalHostName, LocalHostName, | (void)strlcpy(oldLocalHostName, LocalHostName, | ||||
| sizeof(oldLocalHostName)); | sizeof(oldLocalHostName)); | ||||
| if (gethostname(LocalHostName, sizeof(LocalHostName))) | if (gethostname(LocalHostName, sizeof(LocalHostName))) | ||||
| err(EX_OSERR, "gethostname() failed"); | err(EX_OSERR, "gethostname() failed"); | ||||
| if ((p = strchr(LocalHostName, '.')) != NULL) { | if ((p = strchr(LocalHostName, '.')) != NULL) { | ||||
| /* RFC 5424 prefers logging FQDNs. */ | /* RFC 5424 prefers logging FQDNs. */ | ||||
| if (RFC3164OutputFormat) | if (RFC3164OutputFormat) | ||||
| *p = '\0'; | *p = '\0'; | ||||
| ▲ Show 20 Lines • Show All 127 Lines • ▼ Show 20 Lines | #endif | ||||
| printf("\n"); | printf("\n"); | ||||
| } | } | ||||
| } | } | ||||
| logmsg(LOG_SYSLOG | LOG_INFO, NULL, LocalHostName, "syslogd", NULL, | logmsg(LOG_SYSLOG | LOG_INFO, NULL, LocalHostName, "syslogd", NULL, | ||||
| NULL, NULL, "restart", 0); | NULL, NULL, "restart", 0); | ||||
| dprintf("syslogd: restarted\n"); | dprintf("syslogd: restarted\n"); | ||||
| /* | /* | ||||
| * Log a change in hostname, but only on a restart. | * Log a change in hostname, but only on reload. | ||||
| */ | */ | ||||
| if (signo != 0 && strcmp(oldLocalHostName, LocalHostName) != 0) { | if (reload && strcmp(oldLocalHostName, LocalHostName) != 0) { | ||||
| (void)snprintf(hostMsg, sizeof(hostMsg), | (void)snprintf(hostMsg, sizeof(hostMsg), | ||||
| "hostname changed, \"%s\" to \"%s\"", | "hostname changed, \"%s\" to \"%s\"", | ||||
| oldLocalHostName, LocalHostName); | oldLocalHostName, LocalHostName); | ||||
| logmsg(LOG_SYSLOG | LOG_INFO, NULL, LocalHostName, "syslogd", | logmsg(LOG_SYSLOG | LOG_INFO, NULL, LocalHostName, "syslogd", | ||||
| NULL, NULL, NULL, hostMsg, 0); | NULL, NULL, NULL, hostMsg, 0); | ||||
| dprintf("%s\n", hostMsg); | dprintf("%s\n", hostMsg); | ||||
| } | } | ||||
| /* | /* | ||||
| * Log the kernel boot file if we aren't going to use it as | * Log the kernel boot file if we aren't going to use it as | ||||
| * the prefix, and if this is *not* a restart. | * the prefix, and if this is *not* a reload. | ||||
| */ | */ | ||||
| if (signo == 0 && !use_bootfile) { | if (!reload && !use_bootfile) { | ||||
| (void)snprintf(bootfileMsg, sizeof(bootfileMsg), | (void)snprintf(bootfileMsg, sizeof(bootfileMsg), | ||||
| "kernel boot file is %s", bootfile); | "kernel boot file is %s", bootfile); | ||||
| logmsg(LOG_KERN | LOG_INFO, NULL, LocalHostName, "syslogd", | logmsg(LOG_KERN | LOG_INFO, NULL, LocalHostName, "syslogd", | ||||
| NULL, NULL, NULL, bootfileMsg, 0); | NULL, NULL, NULL, bootfileMsg, 0); | ||||
| dprintf("%s\n", bootfileMsg); | dprintf("%s\n", bootfileMsg); | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 1,212 Lines • Show Last 20 Lines | |||||