From d486bc8fb9d83b576363d08a2ec6717e6489bccf Mon Sep 17 00:00:00 2001 From: Peter Wemm Date: Tue, 26 Nov 1996 02:24:42 +0000 Subject: [PATCH] Make the handling of the /dev/ prefix for tty names more consistant. ttymsg() insists on them not being there. Also, since ttymsg() opens the tty "on demand", don't keep an fd open ourselves. This would interfere with HUPCL etc. This should close PR#2103 from --- usr.sbin/syslogd/syslogd.c | 48 ++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index b75c5907442..3549145c00e 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -39,7 +39,7 @@ static const char copyright[] = static char sccsid[] = "@(#)syslogd.c 8.3 (Berkeley) 4/4/94"; */ static const char rcsid[] = - "$Id: syslogd.c,v 1.12 1996/10/28 08:25:13 joerg Exp $"; + "$Id: syslogd.c,v 1.13 1996/11/18 21:48:29 peter Exp $"; #endif /* not lint */ /* @@ -261,7 +261,7 @@ main(argc, argv) setlinebuf(stdout); consfile.f_type = F_CONSOLE; - (void)strcpy(consfile.f_un.f_fname, ctty); + (void)strcpy(consfile.f_un.f_fname, ctty + sizeof _PATH_DEV - 1); (void)gethostname(LocalHostName, sizeof(LocalHostName)); if ((p = strchr(LocalHostName, '.')) != NULL) { *p++ = '\0'; @@ -702,13 +702,6 @@ fprintlog(f, flags, msg) } break; - case F_CONSOLE: - if (flags & IGN_CONS) { - dprintf(" (ignored)\n"); - break; - } - /* FALLTHROUGH */ - case F_FILE: dprintf(" %s\n", f->f_un.f_fname); v->iov_base = "\n"; @@ -723,8 +716,15 @@ fprintlog(f, flags, msg) (void)fsync(f->f_file); break; + case F_CONSOLE: + if (flags & IGN_CONS) { + dprintf(" (ignored)\n"); + break; + } + /* FALLTHROUGH */ + case F_TTY: - dprintf(" %s\n", f->f_un.f_fname); + dprintf(" %s%s\n", _PATH_DEV, f->f_un.f_fname); v->iov_base = "\r\n"; v->iov_len = 2; @@ -938,11 +938,12 @@ init(signo) switch (f->f_type) { case F_FILE: - case F_TTY: - case F_CONSOLE: case F_FORW: (void)close(f->f_file); break; + case F_CONSOLE: + case F_TTY: + break; } next = f->f_next; if(f->f_program) free(f->f_program); @@ -1021,11 +1022,14 @@ init(signo) printf("%s: ", TypeNames[f->f_type]); switch (f->f_type) { case F_FILE: - case F_TTY: - case F_CONSOLE: printf("%s", f->f_un.f_fname); break; + case F_CONSOLE: + case F_TTY: + printf("%s%s", _PATH_DEV, f->f_un.f_fname); + break; + case F_FORW: printf("%s", f->f_un.f_forw.f_hname); break; @@ -1159,18 +1163,22 @@ cfline(line, f, prog) break; case '/': - (void)strcpy(f->f_un.f_fname, p); if ((f->f_file = open(p, O_WRONLY|O_APPEND, 0)) < 0) { f->f_file = F_UNUSED; logerror(p); break; } - if (isatty(f->f_file)) - f->f_type = F_TTY; - else + if (isatty(f->f_file)) { + if (strcmp(p, ctty) == 0) + f->f_type = F_CONSOLE; + else + f->f_type = F_TTY; + close(f->f_file); + (void)strcpy(f->f_un.f_fname, p + sizeof _PATH_DEV - 1); + } else { + (void)strcpy(f->f_un.f_fname, p); f->f_type = F_FILE; - if (strcmp(p, ctty) == 0) - f->f_type = F_CONSOLE; + } break; case '*':