summaryrefslogtreecommitdiff
path: root/usr.bin/wall/ttymsg.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1998-11-18 16:47:02 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1998-11-18 16:47:02 +0000
commit8b1adc5c1afcf420007a4f102b7cc4e7b8ebb925 (patch)
tree12a11fa16e429778612801b6d715887bcc31cd6f /usr.bin/wall/ttymsg.c
parent31cbabfe8d692932cd09f237079b28ae57f6ccc1 (diff)
simply honour S_IWGRP
Diffstat (limited to 'usr.bin/wall/ttymsg.c')
-rw-r--r--usr.bin/wall/ttymsg.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/usr.bin/wall/ttymsg.c b/usr.bin/wall/ttymsg.c
index 6fe3f9ebb30..f49fdec4912 100644
--- a/usr.bin/wall/ttymsg.c
+++ b/usr.bin/wall/ttymsg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ttymsg.c,v 1.5 1998/11/18 02:57:22 deraadt Exp $ */
+/* $OpenBSD: ttymsg.c,v 1.6 1998/11/18 16:47:01 deraadt Exp $ */
/* $NetBSD: ttymsg.c,v 1.3 1994/11/17 07:17:55 jtc Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)ttymsg.c 8.2 (Berkeley) 11/16/93";
#endif
-static char rcsid[] = "$OpenBSD: ttymsg.c,v 1.5 1998/11/18 02:57:22 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: ttymsg.c,v 1.6 1998/11/18 16:47:01 deraadt Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -93,28 +93,24 @@ ttymsg(iov, iovcnt, line, tmout)
return (errbuf);
}
- if (stat(device, &st) < 0)
- return (NULL);
- if ((st.st_mode & S_IWGRP) == 0)
- return (NULL);
-
- seteuid(geteuid());
+ if (getuid()) {
+ if (stat(device, &st) < 0)
+ return (NULL);
+ if ((st.st_mode & S_IWGRP) == 0)
+ return (NULL);
+ }
/*
* 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());
+ if (errno == EBUSY || errno == EACCES)
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;