=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/wall/ttymsg.c,v retrieving revision 1.3 retrieving revision 1.4 diff -c -r1.3 -r1.4 *** src/usr.bin/wall/ttymsg.c 1996/10/25 06:06:30 1.3 --- src/usr.bin/wall/ttymsg.c 1998/11/18 01:03:16 1.4 *************** *** 1,4 **** ! /* $OpenBSD: ttymsg.c,v 1.3 1996/10/25 06:06:30 downsj Exp $ */ /* $NetBSD: ttymsg.c,v 1.3 1994/11/17 07:17:55 jtc Exp $ */ /* --- 1,4 ---- ! /* $OpenBSD: ttymsg.c,v 1.4 1998/11/18 01:03:16 deraadt Exp $ */ /* $NetBSD: ttymsg.c,v 1.3 1994/11/17 07:17:55 jtc Exp $ */ /* *************** *** 38,44 **** #if 0 static char sccsid[] = "@(#)ttymsg.c 8.2 (Berkeley) 11/16/93"; #endif ! static char rcsid[] = "$OpenBSD: ttymsg.c,v 1.3 1996/10/25 06:06:30 downsj Exp $"; #endif /* not lint */ #include --- 38,44 ---- #if 0 static char sccsid[] = "@(#)ttymsg.c 8.2 (Berkeley) 11/16/93"; #endif ! static char rcsid[] = "$OpenBSD: ttymsg.c,v 1.4 1998/11/18 01:03:16 deraadt Exp $"; #endif /* not lint */ #include *************** *** 52,57 **** --- 52,58 ---- #include #include #include + #include /* * Display the contents of a uio structure on a terminal. Used by wall(1), *************** *** 91,107 **** return (errbuf); } /* * open will fail on slip lines or exclusive-use lines * if not running as root; not an error. */ if ((fd = open(device, O_WRONLY|O_NONBLOCK, 0)) < 0) { ! if (errno == EBUSY || errno == EACCES) return (NULL); (void) snprintf(errbuf, sizeof(errbuf), "%s: %s", device, strerror(errno)); return (errbuf); } for (cnt = left = 0; cnt < iovcnt; ++cnt) left += iov[cnt].iov_len; --- 92,114 ---- return (errbuf); } + seteuid(geteuid()); + /* * open will fail on slip lines or exclusive-use lines * if not running as root; not an error. */ if ((fd = open(device, O_WRONLY|O_NONBLOCK, 0)) < 0) { ! if (errno == EBUSY || errno == EACCES) { ! seteuid(getuid()); return (NULL); + } + seteuid(getuid()); (void) snprintf(errbuf, sizeof(errbuf), "%s: %s", device, strerror(errno)); return (errbuf); } + seteuid(getuid()); for (cnt = left = 0; cnt < iovcnt; ++cnt) left += iov[cnt].iov_len;