- continue;
- }
- if (f->f_flags & F_TTY) {
- v->iov_base = "\r\n";
- v->iov_len = 2;
- } else {
- v->iov_base = "\n";
- v->iov_len = 1;
- }
- if (writev(f->f_file, iov, 4) < 0) {
- int e = errno;
- (void) close(f->f_file);
- /*
- * Check for EBADF on the console due to vhangup() XXX
- */
- if (e == EBADF && (f->f_flags & F_TTY)) {
- f->f_file = open(f->f_name, O_WRONLY|O_APPEND);
- if (f->f_file < 0)
- logerror(f->f_name);
- } else {
- f->f_file = -1;
- errno = e;
- logerror(f->f_name);
- }
- } else if (flags & SYNC_FILE)
- (void) fsync(f->f_file);
- }
-
- /*
- * Output high priority messages to terminals.
- */
- if (!(flags & ISMARK) && (mask(pri) & Sumask))
- wallmsg(pri, msg, from);
-
- (void) sigsetmask(omask);
-}
-
-/*
- * INIT -- Initialize syslogd from configuration table
- *
- * The configuration table consists of a series of lines broken
- * into two sections by a blank line. The first section gives a
- * list of files to log on. Each line begins with a
- * comma-separated list of digits or ranges of digits (pairs of
- * digits separated by a dash); if the priority of a message falls
- * in the set of digits defined by this list, then the message is
- * logged in the file corresponding to this line. If the
- * following character is an asterisk, then syslogd arranges for
- * something to be printed every fifteen minutes (even if only a
- * null line), so that crashes and other events can be localized.
- * The rest of the line is the pathname of the log file. The
- * second section is a list of user names; these people are all
- * notified when subalert messages occur (if they are logged on).
- * These lines may also have associated priority lists.
- *
- * The configuration table will be reread by this routine if a
- * SIGHUP signal occurs; for that reason, it is tricky about not
- * re-opening files and closing files it will not be using.
- */
-
-init()
-{
- register int i;
- register FILE *cf;
- register struct filed *f;
- register char *p;
- char cline[BUFSIZ];
- struct hostent *hp;
- int pmask, flags;
- long now;
- char *getpmask();
-
- dprintf("init\n");
-
- /* flush any pending output */
- flushmsg();
-
- /*
- * Close all open log files.
- */
- for (f = Files; f < &Files[NLOGS]; f++) {
- if (f->f_file >= 0)
- (void) close(f->f_file);
- f->f_file = -1;
- }
-
- /* open the configuration file */
- if ((cf = fopen(ConfFile, "r")) == NULL) {
- dprintf("cannot open %s\n", ConfFile);
- f = Files;
- if ((f->f_file = open(ctty, O_WRONLY)) >= 0) {
- strncpy(f->f_name, ctty, sizeof(f->f_name)-1);
- f->f_pmask = mask(LOG_CRIT);
- f->f_flags = F_TTY|F_MARK|F_CONS;
- untty();
- }
- return;
- }
-
- /*
- * Foreach line in the conf table, open that file.
- */
- f = Files;
- while (fgets(cline, sizeof cline, cf) != NULL) {
- /* check for end-of-section */
- if (cline[0] == '\n')