summaryrefslogtreecommitdiffstats
path: root/usr.bin/wall
diff options
context:
space:
mode:
authorkris <kris@FreeBSD.org>2001-05-08 11:11:42 +0000
committerkris <kris@FreeBSD.org>2001-05-08 11:11:42 +0000
commitfd84041b002957f6614cb50c4a67060c64e1c99a (patch)
tree9532defdcb053646c1d7f6e31ac37474a15ea1f0 /usr.bin/wall
parent38e4267af012d2f5d815736d6b2641f4c35bbbff (diff)
downloadFreeBSD-src-fd84041b002957f6614cb50c4a67060c64e1c99a.zip
FreeBSD-src-fd84041b002957f6614cb50c4a67060c64e1c99a.tar.gz
When opening the file to broadcast, do it with the user's gid, not the
egid (tty). Obtained from: OpenBSD Submitted by: Maxime Henrion <mux@qualys.com> Reviewed by: imp
Diffstat (limited to 'usr.bin/wall')
-rw-r--r--usr.bin/wall/wall.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/usr.bin/wall/wall.c b/usr.bin/wall/wall.c
index 25cb786..96647df 100644
--- a/usr.bin/wall/wall.c
+++ b/usr.bin/wall/wall.c
@@ -189,6 +189,7 @@ makemsg(char *fname)
int fd;
char *p, *tty, hostname[MAXHOSTNAMELEN], lbuf[256], tmpname[64];
const char *whom;
+ gid_t egid;
(void)snprintf(tmpname, sizeof(tmpname), "%s/wall.XXXXXX", _PATH_TMP);
if ((fd = mkstemp(tmpname)) == -1 || !(fp = fdopen(fd, "r+")))
@@ -225,8 +226,13 @@ makemsg(char *fname)
}
(void)fprintf(fp, "%79s\r\n", " ");
- if (fname && !(freopen(fname, "r", stdin)))
- err(1, "can't read %s", fname);
+ if (fname) {
+ egid = getegid();
+ setegid(getgid());
+ if (freopen(fname, "r", stdin) == NULL)
+ err(1, "can't read %s", fname);
+ setegid(egid);
+ }
while (fgets(lbuf, sizeof(lbuf), stdin))
for (cnt = 0, p = lbuf; (ch = *p) != '\0'; ++p, ++cnt) {
if (ch == '\r') {
OpenPOWER on IntegriCloud