From a2fd57f445ebd6b25b5aa0cb5c384072e9fdc8eb Mon Sep 17 00:00:00 2001 From: ngie Date: Thu, 22 Jun 2017 07:54:12 +0000 Subject: [PATCH] Revert r320222,r320223,r320224 The committed changes (reverted after this commit) break POLA on a stable branch. Requested by: jhb git-svn-id: svn://svn.freebsd.org/base/stable/10@320229 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- etc/cron.d/Makefile | 11 -- etc/cron.d/at | 7 - etc/crontab | 2 + etc/mtree/BSD.root.dist | 4 - etc/newsyslog.conf | 6 + etc/newsyslog.conf.d/Makefile | 24 --- etc/newsyslog.conf.d/amd.conf | 2 - etc/newsyslog.conf.d/ftp.conf | 2 - etc/newsyslog.conf.d/lpr.conf | 2 - etc/newsyslog.conf.d/pf.conf | 2 - etc/newsyslog.conf.d/ppp.conf | 2 - etc/newsyslog.conf.d/sendmail.conf | 2 - etc/pam.d/Makefile | 39 +--- etc/syslog.conf | 6 +- etc/syslog.d/Makefile | 19 -- etc/syslog.d/ftp.conf | 2 - etc/syslog.d/lpr.conf | 2 - etc/syslog.d/ppp.conf | 3 - tools/build/mk/OptionalObsoleteFiles.inc | 12 -- usr.sbin/cron/cron/cron.8 | 8 +- usr.sbin/cron/cron/cron.h | 2 +- usr.sbin/cron/cron/database.c | 49 +---- usr.sbin/cron/cron/pathnames.h | 2 - usr.sbin/cron/lib/misc.c | 6 +- usr.sbin/syslogd/syslog.conf.5 | 8 +- usr.sbin/syslogd/syslogd.c | 233 ++++++++--------------- 26 files changed, 108 insertions(+), 349 deletions(-) delete mode 100644 etc/cron.d/Makefile delete mode 100644 etc/cron.d/at delete mode 100644 etc/newsyslog.conf.d/amd.conf delete mode 100644 etc/newsyslog.conf.d/ftp.conf delete mode 100644 etc/newsyslog.conf.d/lpr.conf delete mode 100644 etc/newsyslog.conf.d/pf.conf delete mode 100644 etc/newsyslog.conf.d/ppp.conf delete mode 100644 etc/newsyslog.conf.d/sendmail.conf delete mode 100644 etc/syslog.d/Makefile delete mode 100644 etc/syslog.d/ftp.conf delete mode 100644 etc/syslog.d/lpr.conf delete mode 100644 etc/syslog.d/ppp.conf diff --git a/etc/cron.d/Makefile b/etc/cron.d/Makefile deleted file mode 100644 index aa487cbfb..000000000 --- a/etc/cron.d/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -# $FreeBSD$ - -.include - -.if ${MK_AT} != "no" -FILES+= at -.endif - -BINDIR= /etc/cron.d - -.include diff --git a/etc/cron.d/at b/etc/cron.d/at deleted file mode 100644 index 61fe5a843..000000000 --- a/etc/cron.d/at +++ /dev/null @@ -1,7 +0,0 @@ -# $FreeBSD$ -# -SHELL=/bin/sh -PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin - -# See crontab(5) for field format. -*/5 * * * * root /usr/libexec/atrun diff --git a/etc/crontab b/etc/crontab index a3248dabe..e1e6e8862 100644 --- a/etc/crontab +++ b/etc/crontab @@ -7,6 +7,8 @@ PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin # #minute hour mday month wday who command # +*/5 * * * * root /usr/libexec/atrun +# # Save some entropy so that /dev/random can re-seed on boot. */11 * * * * operator /usr/libexec/save-entropy # diff --git a/etc/mtree/BSD.root.dist b/etc/mtree/BSD.root.dist index b47d9816a..4f3bdfc69 100644 --- a/etc/mtree/BSD.root.dist +++ b/etc/mtree/BSD.root.dist @@ -30,8 +30,6 @@ .. bluetooth .. - cron.d - .. defaults .. devd @@ -74,8 +72,6 @@ .. ssl .. - syslog.d - .. zfs .. .. diff --git a/etc/newsyslog.conf b/etc/newsyslog.conf index 966fb329c..ab595cac6 100644 --- a/etc/newsyslog.conf +++ b/etc/newsyslog.conf @@ -18,6 +18,7 @@ # # logfilename [owner:group] mode count size when flags [/pid_file] [sig_num] /var/log/all.log 600 7 * @T00 J +/var/log/amd.log 644 7 100 * J /var/log/auth.log 600 7 100 @0101T JC /var/log/console.log 600 5 100 * J /var/log/cron 600 3 100 * JC @@ -25,13 +26,18 @@ /var/log/debug.log 600 7 100 * JC /var/log/init.log 644 3 100 * J /var/log/kerberos.log 600 7 100 * J +/var/log/lpd-errs 644 7 100 * JC /var/log/maillog 640 7 * @T00 JC /var/log/messages 644 5 100 @0101T JC /var/log/monthly.log 640 12 * $M1D0 JN +/var/log/pflog 600 3 100 * JB /var/run/pflogd.pid +/var/log/ppp.log root:network 640 3 100 * JC /var/log/devd.log 644 3 100 * JC /var/log/security 600 10 100 * JC +/var/log/sendmail.st 640 10 * 168 BN /var/log/utx.log 644 3 * @01T05 B /var/log/weekly.log 640 5 * $W6D0 JN +/var/log/xferlog 600 7 100 * JC /etc/newsyslog.conf.d/* /usr/local/etc/newsyslog.conf.d/* diff --git a/etc/newsyslog.conf.d/Makefile b/etc/newsyslog.conf.d/Makefile index 58aac203b..46609576a 100644 --- a/etc/newsyslog.conf.d/Makefile +++ b/etc/newsyslog.conf.d/Makefile @@ -6,32 +6,8 @@ BINDIR= /etc/newsyslog.conf.d FILES= -.if ${MK_AMD} != "no" -FILES+= amd.conf -.endif - -.if ${MK_FTP} != "no" -FILES+= ftp.conf -.endif - -.if ${MK_LPR} != "no" -FILES+= lpr.conf -.endif - .if ${MK_OFED} != "no" FILES+= opensm.conf .endif -.if ${MK_PF} != "no" -FILES+= pf.conf -.endif - -.if ${MK_PPP} != "no" -FILES+= ppp.conf -.endif - -.if ${MK_SENDMAIL} != "no" -FILES+= sendmail.conf -.endif - .include diff --git a/etc/newsyslog.conf.d/amd.conf b/etc/newsyslog.conf.d/amd.conf deleted file mode 100644 index 6bacc700d..000000000 --- a/etc/newsyslog.conf.d/amd.conf +++ /dev/null @@ -1,2 +0,0 @@ -# $FreeBSD$ -/var/log/amd.log 644 7 100 * J diff --git a/etc/newsyslog.conf.d/ftp.conf b/etc/newsyslog.conf.d/ftp.conf deleted file mode 100644 index 16cea6493..000000000 --- a/etc/newsyslog.conf.d/ftp.conf +++ /dev/null @@ -1,2 +0,0 @@ -# $FreeBSD$ -/var/log/xferlog 600 7 100 * JC diff --git a/etc/newsyslog.conf.d/lpr.conf b/etc/newsyslog.conf.d/lpr.conf deleted file mode 100644 index d3beff1eb..000000000 --- a/etc/newsyslog.conf.d/lpr.conf +++ /dev/null @@ -1,2 +0,0 @@ -# $FreeBSD$ -/var/log/lpd-errs 644 7 100 * JC diff --git a/etc/newsyslog.conf.d/pf.conf b/etc/newsyslog.conf.d/pf.conf deleted file mode 100644 index 71adbfd76..000000000 --- a/etc/newsyslog.conf.d/pf.conf +++ /dev/null @@ -1,2 +0,0 @@ -# $FreeBSD$ -/var/log/pflog 600 3 100 * JB /var/run/pflogd.pid diff --git a/etc/newsyslog.conf.d/ppp.conf b/etc/newsyslog.conf.d/ppp.conf deleted file mode 100644 index 3e62968b1..000000000 --- a/etc/newsyslog.conf.d/ppp.conf +++ /dev/null @@ -1,2 +0,0 @@ -# $FreeBSD$ -/var/log/ppp.log root:network 640 3 100 * JC diff --git a/etc/newsyslog.conf.d/sendmail.conf b/etc/newsyslog.conf.d/sendmail.conf deleted file mode 100644 index 5cb59c4e8..000000000 --- a/etc/newsyslog.conf.d/sendmail.conf +++ /dev/null @@ -1,2 +0,0 @@ -# $FreeBSD$ -/var/log/sendmail.st 640 10 * 168 BN diff --git a/etc/pam.d/Makefile b/etc/pam.d/Makefile index 626e22ae9..7369022cc 100644 --- a/etc/pam.d/Makefile +++ b/etc/pam.d/Makefile @@ -1,52 +1,23 @@ # $FreeBSD$ -.include - NO_OBJ= -FILESGROUPS= FILES - FILES= README \ + atrun \ cron \ + ftpd \ imap \ login \ other \ passwd pop3 \ + rsh \ sshd su system \ + telnetd \ xdm FILESDIR= /etc/pam.d FILESMODE= 644 - -.if ${MK_AT} != "no" -FILESGROUPS+= AT -AT+= atrun -ATDIR= ${FILESDIR} -ATMODE= ${FILESMODE} -.endif - -.if ${MK_FTP} != "no" -FILESGROUPS+= FTP -FTP+= ftpd -FTPDIR= ${FILESDIR} -FTPMODE= ${FILESMODE} -LINKS= ${FILESDIR}/ftpd ${FILESDIR}/ftp -.endif - -.if ${MK_RCMDS} != "no" -FILESGROUPS+= RCMDS -RCMDS+= rsh -RCMDSDIR= ${FILESDIR} -RCMDSMODE= ${FILESMODE} -.endif - -.if ${MK_TELNET} != "no" -FILESGROUPS+= TELNET -TELNET+= telnetd -TELNETDIR= ${FILESDIR} -TELNETMODE= ${FILESMODE} -.endif - FILESMODE_README= 444 +LINKS= ${FILESDIR}/ftpd ${FILESDIR}/ftp .include diff --git a/etc/syslog.conf b/etc/syslog.conf index e0df421b9..e65db5347 100644 --- a/etc/syslog.conf +++ b/etc/syslog.conf @@ -10,6 +10,8 @@ security.* /var/log/security auth.info;authpriv.info /var/log/auth.log mail.info /var/log/maillog +lpr.info /var/log/lpd-errs +ftp.info /var/log/xferlog cron.* /var/log/cron !-devd *.=debug /var/log/debug.log @@ -29,6 +31,6 @@ cron.* /var/log/cron # Uncomment this if you wish to see messages produced by devd # !devd # *.>=notice /var/log/devd.log +!ppp +*.* /var/log/ppp.log !* -include /etc/syslog.d -include /usr/local/etc/syslog.d diff --git a/etc/syslog.d/Makefile b/etc/syslog.d/Makefile deleted file mode 100644 index 315950221..000000000 --- a/etc/syslog.d/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -# $FreeBSD$ - -.include - -.if ${MK_FTP} != "no" -FILES+= ftp.conf -.endif - -.if ${MK_LPR} != "no" -FILES+= lpr.conf -.endif - -.if ${MK_PPP} != "no" -FILES+= ppp.conf -.endif - -BINDIR= /etc/syslog.d - -.include diff --git a/etc/syslog.d/ftp.conf b/etc/syslog.d/ftp.conf deleted file mode 100644 index d4d11cfb7..000000000 --- a/etc/syslog.d/ftp.conf +++ /dev/null @@ -1,2 +0,0 @@ -# $FreeBSD$ -ftp.info /var/log/xferlog diff --git a/etc/syslog.d/lpr.conf b/etc/syslog.d/lpr.conf deleted file mode 100644 index 0eb6eb06d..000000000 --- a/etc/syslog.d/lpr.conf +++ /dev/null @@ -1,2 +0,0 @@ -# $FreeBSD$ -lpr.info /var/log/lpd-errs diff --git a/etc/syslog.d/ppp.conf b/etc/syslog.d/ppp.conf deleted file mode 100644 index 57ee868bd..000000000 --- a/etc/syslog.d/ppp.conf +++ /dev/null @@ -1,3 +0,0 @@ -# $FreeBSD$ -!ppp -*.* /var/log/ppp.log diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index 3068ad9e8..43bbff97d 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -56,7 +56,6 @@ OLD_FILES+=usr/share/man/man8/iasl.8.gz .if ${MK_AMD} == no OLD_FILES+=etc/amd.map -OLD_FILES+=etc/newsyslog.conf.d/amd.conf OLD_FILES+=etc/rc.d/amd OLD_FILES+=usr/bin/pawd OLD_FILES+=usr/sbin/amd @@ -1064,11 +1063,7 @@ OLD_FILES+=usr/share/man/man8/fmtree.8.gz .if ${MK_FTP} == no OLD_FILES+=etc/ftpusers -OLD_FILES+=etc/newsyslog.conf.d/ftp.conf -OLD_FILES+=etc/pam.d/ftp -OLD_FILES+=etc/pam.d/ftpd OLD_FILES+=etc/rc.d/ftpd -OLD_FILES+=etc/syslog.d/ftp.conf OLD_FILES+=usr/bin/ftp OLD_FILES+=usr/bin/gate-ftp OLD_FILES+=usr/bin/pftp @@ -3821,9 +3816,7 @@ OLD_FILES+=usr/share/man/man8/updatedb.8.gz .if ${MK_LPR} == no OLD_FILES+=etc/hosts.lpd OLD_FILES+=etc/printcap -OLD_FILES+=etc/newsyslog.conf.d/lpr.conf OLD_FILES+=etc/rc.d/lpd -OLD_FILES+=etc/syslog.d/lpr.conf OLD_FILES+=usr/bin/lp OLD_FILES+=usr/bin/lpq OLD_FILES+=usr/bin/lpr @@ -4199,7 +4192,6 @@ OLD_DIRS+=usr/share/examples/pc-sysinstall .endif .if ${MK_PF} == no -OLD_FILES+=etc/newsyslog.conf.d/pf.conf OLD_FILES+=etc/periodic/security/520.pfdenied OLD_FILES+=etc/pf.os OLD_FILES+=etc/rc.d/ftp-proxy @@ -4268,9 +4260,7 @@ OLD_FILES+=usr/share/man/man8/portsnap.8.gz .endif .if ${MK_PPP} == no -OLD_FILES+=etc/newsyslog.conf.d/ppp.conf OLD_FILES+=etc/ppp/ppp.conf -OLD_FILES+=etc/syslog.d/ppp.conf OLD_DIRS+=etc/ppp OLD_FILES+=usr/sbin/ppp OLD_FILES+=usr/sbin/pppctl @@ -4470,7 +4460,6 @@ OLD_FILES+=usr/share/man/man8/rtquery.8.gz .endif .if ${MK_SENDMAIL} == no -OLD_FILES+=etc/newsyslog.conf.d/sendmail.conf OLD_FILES+=etc/periodic/daily/150.clean-hoststat OLD_FILES+=etc/periodic/daily/440.status-mailq OLD_FILES+=etc/periodic/daily/460.status-mail-rejects @@ -4789,7 +4778,6 @@ OLD_FILES+=usr/share/nls/uk_UA.UTF-8/tcsh.cat .endif .if ${MK_TELNET} == no -OLD_FILES+=etc/pam.d/telnetd OLD_FILES+=usr/bin/telnet OLD_FILES+=usr/libexec/telnetd OLD_FILES+=usr/share/man/man1/telnet.1.gz diff --git a/usr.sbin/cron/cron/cron.8 b/usr.sbin/cron/cron/cron.8 index d7f34cff8..5d5a8d9a9 100644 --- a/usr.sbin/cron/cron/cron.8 +++ b/usr.sbin/cron/cron/cron.8 @@ -17,7 +17,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 31, 2016 +.Dd June 29, 2008 .Dt CRON 8 .Os .Sh NAME @@ -52,11 +52,7 @@ The .Nm utility also searches for .Pa /etc/crontab -and files in -.Pa /etc/cron.d -and -.Pa /usr/local/etc/cron.d -which are in a different format (see +which is in a different format (see .Xr crontab 5 ) . .Pp The diff --git a/usr.sbin/cron/cron/cron.h b/usr.sbin/cron/cron/cron.h index a6810be84..60b2a9081 100644 --- a/usr.sbin/cron/cron/cron.h +++ b/usr.sbin/cron/cron/cron.h @@ -218,7 +218,7 @@ void set_cron_uid(void), unget_char(int, FILE *), free_entry(entry *), skip_comments(FILE *), - log_it(char *, int, char *, const char *), + log_it(char *, int, char *, char *), log_close(void); int job_runqueue(void), diff --git a/usr.sbin/cron/cron/database.c b/usr.sbin/cron/cron/database.c index 2b0c67b9c..7a44d1429 100644 --- a/usr.sbin/cron/cron/database.c +++ b/usr.sbin/cron/cron/database.c @@ -44,19 +44,10 @@ load_database(old_db) { DIR *dir; struct stat statbuf; - struct stat syscron_stat, st; - time_t maxmtime; + struct stat syscron_stat; DIR_T *dp; cron_db new_db; user *u, *nu; - struct { - const char *name; - struct stat st; - } syscrontabs [] = { - { SYSCRONTABS }, - { LOCALSYSCRONTABS } - }; - int i; Debug(DLOAD, ("[%d] load_database()\n", getpid())) @@ -74,16 +65,6 @@ load_database(old_db) if (stat(SYSCRONTAB, &syscron_stat) < OK) syscron_stat.st_mtime = 0; - maxmtime = TMAX(statbuf.st_mtime, syscron_stat.st_mtime); - - for (i = 0; i < nitems(syscrontabs); i++) { - if (stat(syscrontabs[i].name, &syscrontabs[i].st) != -1) { - maxmtime = TMAX(syscrontabs[i].st.st_mtime, maxmtime); - } else { - syscrontabs[i].st.st_mtime = 0; - } - } - /* if spooldir's mtime has not changed, we don't need to fiddle with * the database. * @@ -91,7 +72,7 @@ load_database(old_db) * so is guaranteed to be different than the stat() mtime the first * time this function is called. */ - if (old_db->mtime == maxmtime) { + if (old_db->mtime == TMAX(statbuf.st_mtime, syscron_stat.st_mtime)) { Debug(DLOAD, ("[%d] spool dir mtime unch, no load needed.\n", getpid())) return; @@ -102,7 +83,7 @@ load_database(old_db) * actually changed. Whatever is left in the old database when * we're done is chaff -- crontabs that disappeared. */ - new_db.mtime = maxmtime; + new_db.mtime = TMAX(statbuf.st_mtime, syscron_stat.st_mtime); new_db.head = new_db.tail = NULL; if (syscron_stat.st_mtime) { @@ -111,30 +92,6 @@ load_database(old_db) &new_db, old_db); } - for (i = 0; i < nitems(syscrontabs); i++) { - char tabname[MAXPATHLEN]; - if (syscrontabs[i].st.st_mtime == 0) - continue; - if (!(dir = opendir(syscrontabs[i].name))) { - log_it("CRON", getpid(), "OPENDIR FAILED", - syscrontabs[i].name); - (void) exit(ERROR_EXIT); - } - - while (NULL != (dp = readdir(dir))) { - if (dp->d_name[0] == '.') - continue; - if (fstatat(dirfd(dir), dp->d_name, &st, 0) == 0 && - !S_ISREG(st.st_mode)) - continue; - snprintf(tabname, sizeof(tabname), "%s/%s", - syscrontabs[i].name, dp->d_name); - process_crontab("root", SYS_NAME, tabname, - &syscrontabs[i].st, &new_db, old_db); - } - closedir(dir); - } - /* we used to keep this dir open all the time, for the sake of * efficiency. however, we need to close it in every fork, and * we fork a lot more often than the mtime of the dir changes. diff --git a/usr.sbin/cron/cron/pathnames.h b/usr.sbin/cron/cron/pathnames.h index fe3ebf55d..ba91bfdc6 100644 --- a/usr.sbin/cron/cron/pathnames.h +++ b/usr.sbin/cron/cron/pathnames.h @@ -62,8 +62,6 @@ /* 4.3BSD-style crontab */ #define SYSCRONTAB "/etc/crontab" -#define SYSCRONTABS "/etc/cron.d" -#define LOCALSYSCRONTABS "/usr/local/etc/cron.d" /* what editor to use if no EDITOR or VISUAL * environment variable specified. diff --git a/usr.sbin/cron/lib/misc.c b/usr.sbin/cron/lib/misc.c index 6a0b8acbd..afed07f3e 100644 --- a/usr.sbin/cron/lib/misc.c +++ b/usr.sbin/cron/lib/misc.c @@ -385,7 +385,11 @@ out: if (allow) void -log_it(char *username, int xpid, char *event, const char *detail) +log_it(username, xpid, event, detail) + char *username; + int xpid; + char *event; + char *detail; { #if defined(LOG_FILE) || DEBUGGING PID_T pid = xpid; diff --git a/usr.sbin/syslogd/syslog.conf.5 b/usr.sbin/syslogd/syslog.conf.5 index 94c1cd415..3378aa08c 100644 --- a/usr.sbin/syslogd/syslog.conf.5 +++ b/usr.sbin/syslogd/syslog.conf.5 @@ -28,7 +28,7 @@ .\" @(#)syslog.conf.5 8.1 (Berkeley) 6/9/93 .\" $FreeBSD$ .\" -.Dd November 1, 2016 +.Dd September 12, 2012 .Dt SYSLOG.CONF 5 .Os .Sh NAME @@ -62,12 +62,6 @@ field is separated from the .Em action field by one or more tab characters or spaces. .Pp -A special -.Em include -keyword can be used to include all files with names ending in '.conf' and not -beginning with a '.' contained in the directory following the keyword. -This keyword can only be used in the first level configuration file. -.Pp Note that if you use spaces as separators, your .Nm might be incompatible with other Unices or Unix-like systems. diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index 40487d1e2..3d5429f9e 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -97,7 +97,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include #include @@ -121,8 +120,6 @@ __FBSDID("$FreeBSD$"); const char *ConfFile = _PATH_LOGCONF; const char *PidFile = _PATH_LOGPID; const char ctty[] = _PATH_CONSOLE; -static const char include_str[] = "include"; -static const char include_ext[] = ".conf"; #define dprintf if (Debug) printf @@ -1551,46 +1548,96 @@ die(int signo) exit(1); } -static int -configfiles(const struct dirent *dp) +/* + * INIT -- Initialize syslogd from configuration table + */ +static void +init(int signo) { - const char *p; - size_t ext_len; - - if (dp->d_name[0] == '.') - return (0); + int i; + FILE *cf; + struct filed *f, *next, **nextp; + char *p; + char cline[LINE_MAX]; + char prog[LINE_MAX]; + char host[MAXHOSTNAMELEN]; + char oldLocalHostName[MAXHOSTNAMELEN]; + char hostMsg[2*MAXHOSTNAMELEN+40]; + char bootfileMsg[LINE_MAX]; - ext_len = sizeof(include_ext) -1; + dprintf("init\n"); - if (dp->d_namlen <= ext_len) - return (0); + /* + * Load hostname (may have changed). + */ + if (signo != 0) + (void)strlcpy(oldLocalHostName, LocalHostName, + sizeof(oldLocalHostName)); + if (gethostname(LocalHostName, sizeof(LocalHostName))) + err(EX_OSERR, "gethostname() failed"); + if ((p = strchr(LocalHostName, '.')) != NULL) { + *p++ = '\0'; + LocalDomain = p; + } else { + LocalDomain = ""; + } - p = &dp->d_name[dp->d_namlen - ext_len]; - if (strcmp(p, include_ext) != 0) - return (0); + /* + * Close all open log files. + */ + Initialized = 0; + for (f = Files; f != NULL; f = next) { + /* flush any pending output */ + if (f->f_prevcount) + fprintlog(f, 0, (char *)NULL); - return (1); -} + switch (f->f_type) { + case F_FILE: + case F_FORW: + case F_CONSOLE: + case F_TTY: + close_filed(f); + break; + case F_PIPE: + if (f->f_un.f_pipe.f_pid > 0) { + close_filed(f); + deadq_enter(f->f_un.f_pipe.f_pid, + f->f_un.f_pipe.f_pname); + } + f->f_un.f_pipe.f_pid = 0; + break; + } + next = f->f_next; + if (f->f_program) free(f->f_program); + if (f->f_host) free(f->f_host); + free((char *)f); + } + Files = NULL; + nextp = &Files; -static void -readconfigfile(FILE *cf, struct filed **nextp, int allow_includes) -{ - FILE *cf2; - struct filed *f; - struct dirent **ent; - char cline[LINE_MAX]; - char host[MAXHOSTNAMELEN]; - char prog[LINE_MAX]; - char file[MAXPATHLEN]; - char *p, *tmp; - int i, nents; - size_t include_len; + /* open the configuration file */ + if ((cf = fopen(ConfFile, "r")) == NULL) { + dprintf("cannot open %s\n", ConfFile); + *nextp = (struct filed *)calloc(1, sizeof(*f)); + if (*nextp == NULL) { + logerror("calloc"); + exit(1); + } + cfline("*.ERR\t/dev/console", *nextp, "*", "*"); + (*nextp)->f_next = (struct filed *)calloc(1, sizeof(*f)); + if ((*nextp)->f_next == NULL) { + logerror("calloc"); + exit(1); + } + cfline("*.PANIC\t*", (*nextp)->f_next, "*", "*"); + Initialized = 1; + return; + } /* * Foreach line in the conf table, open that file. */ f = NULL; - include_len = sizeof(include_str) -1; (void)strlcpy(host, "*", sizeof(host)); (void)strlcpy(prog, "*", sizeof(prog)); while (fgets(cline, sizeof(cline), cf) != NULL) { @@ -1603,42 +1650,6 @@ readconfigfile(FILE *cf, struct filed **nextp, int allow_includes) continue; if (*p == 0) continue; - if (allow_includes && - strncmp(p, include_str, include_len) == 0 && - isspace(p[include_len])) { - p += include_len; - while (isspace(*p)) - p++; - tmp = p; - while (*tmp != '\0' && !isspace(*tmp)) - tmp++; - *tmp = '\0'; - dprintf("Trying to include files in '%s'\n", p); - nents = scandir(p, &ent, configfiles, alphasort); - if (nents == -1) { - dprintf("Unable to open '%s': %s\n", p, - strerror(errno)); - continue; - } - for (i = 0; i < nents; i++) { - if (snprintf(file, sizeof(file), "%s/%s", p, - ent[i]->d_name) >= (int)sizeof(file)) { - dprintf("ignoring path too long: " - "'%s/%s'\n", p, ent[i]->d_name); - free(ent[i]); - continue; - } - free(ent[i]); - cf2 = fopen(file, "r"); - if (cf2 == NULL) - continue; - dprintf("reading %s\n", file); - readconfigfile(cf2, nextp, 0); - fclose(cf2); - } - free(ent); - continue; - } if (*p == '#') { p++; if (*p != '!' && *p != '+' && *p != '-') @@ -1700,92 +1711,6 @@ readconfigfile(FILE *cf, struct filed **nextp, int allow_includes) nextp = &f->f_next; cfline(cline, f, prog, host); } -} - -/* - * INIT -- Initialize syslogd from configuration table - */ -static void -init(int signo) -{ - int i; - FILE *cf; - struct filed *f, *next, **nextp; - char *p; - char oldLocalHostName[MAXHOSTNAMELEN]; - char hostMsg[2*MAXHOSTNAMELEN+40]; - char bootfileMsg[LINE_MAX]; - - dprintf("init\n"); - - /* - * Load hostname (may have changed). - */ - if (signo != 0) - (void)strlcpy(oldLocalHostName, LocalHostName, - sizeof(oldLocalHostName)); - if (gethostname(LocalHostName, sizeof(LocalHostName))) - err(EX_OSERR, "gethostname() failed"); - if ((p = strchr(LocalHostName, '.')) != NULL) { - *p++ = '\0'; - LocalDomain = p; - } else { - LocalDomain = ""; - } - - /* - * Close all open log files. - */ - Initialized = 0; - for (f = Files; f != NULL; f = next) { - /* flush any pending output */ - if (f->f_prevcount) - fprintlog(f, 0, (char *)NULL); - - switch (f->f_type) { - case F_FILE: - case F_FORW: - case F_CONSOLE: - case F_TTY: - close_filed(f); - break; - case F_PIPE: - if (f->f_un.f_pipe.f_pid > 0) { - close_filed(f); - deadq_enter(f->f_un.f_pipe.f_pid, - f->f_un.f_pipe.f_pname); - } - f->f_un.f_pipe.f_pid = 0; - break; - } - next = f->f_next; - if (f->f_program) free(f->f_program); - if (f->f_host) free(f->f_host); - free((char *)f); - } - Files = NULL; - nextp = &Files; - - /* open the configuration file */ - if ((cf = fopen(ConfFile, "r")) == NULL) { - dprintf("cannot open %s\n", ConfFile); - *nextp = (struct filed *)calloc(1, sizeof(*f)); - if (*nextp == NULL) { - logerror("calloc"); - exit(1); - } - cfline("*.ERR\t/dev/console", *nextp, "*", "*"); - (*nextp)->f_next = (struct filed *)calloc(1, sizeof(*f)); - if ((*nextp)->f_next == NULL) { - logerror("calloc"); - exit(1); - } - cfline("*.PANIC\t*", (*nextp)->f_next, "*", "*"); - Initialized = 1; - return; - } - - readconfigfile(cf, &Files, 1); /* close the configuration file */ (void)fclose(cf); -- 2.42.0