Date: Fri, 27 Apr 2001 15:04:36 +0200 From: Maxime Henrion <mux@qualys.com> To: audit@FreeBSD.org Subject: [PATCH] wall.c changes from OpenBSD Message-ID: <20010427150436.A1170@nebula.cybercable.fr>
next in thread | raw e-mail | index | archive | help
--FCuugMFkClbJLl1L Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hello, This patch makes wall open the file with the egid, as taken from the OpenBSD mbox of Kris. I changed several err() to errx() and added some dots to end of sentences to match OpenBSD and reduce the diffs. I hope this patch is correct. Maxime -- Don't be fooled by cheap finnish imitations ; BSD is the One True Code Key fingerprint = F9B6 1D5A 4963 331C 88FC CA6A AB50 1EF2 8CBE 99D6 Public Key : http://www.epita.fr/~henrio_m/ --FCuugMFkClbJLl1L Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="wall.c.diff" *** wall.c.old Fri Apr 27 14:58:30 2001 --- wall.c Fri Apr 27 14:58:09 2001 *************** *** 135,141 **** makemsg(*argv); if (!(fp = fopen(_PATH_UTMP, "r"))) ! err(1, "cannot read %s", _PATH_UTMP); iov.iov_base = mbuf; iov.iov_len = mbufsize; /* NOSTRICT */ --- 135,141 ---- makemsg(*argv); if (!(fp = fopen(_PATH_UTMP, "r"))) ! errx(1, "cannot read %s.", _PATH_UTMP); iov.iov_base = mbuf; iov.iov_len = mbufsize; /* NOSTRICT */ *************** *** 192,198 **** (void)snprintf(tmpname, sizeof(tmpname), "%s/wall.XXXXXX", _PATH_TMP); if ((fd = mkstemp(tmpname)) == -1 || !(fp = fdopen(fd, "r+"))) ! err(1, "can't open temporary file"); (void)unlink(tmpname); if (!nobanner) { --- 192,198 ---- (void)snprintf(tmpname, sizeof(tmpname), "%s/wall.XXXXXX", _PATH_TMP); if ((fd = mkstemp(tmpname)) == -1 || !(fp = fdopen(fd, "r+"))) ! errx(1, "can't open temporary file."); (void)unlink(tmpname); if (!nobanner) { *************** *** 225,232 **** } (void)fprintf(fp, "%79s\r\n", " "); ! if (fname && !(freopen(fname, "r", stdin))) ! err(1, "can't read %s", fname); while (fgets(lbuf, sizeof(lbuf), stdin)) for (cnt = 0, p = lbuf; (ch = *p) != '\0'; ++p, ++cnt) { if (ch == '\r') { --- 225,238 ---- } (void)fprintf(fp, "%79s\r\n", " "); ! if (fname) { ! gid_t egid = getegid(); ! ! setegid(getgid()); ! if (freopen(fname, "r", stdin) == NULL) ! errx(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') { *************** *** 275,285 **** rewind(fp); if (fstat(fd, &sbuf)) ! err(1, "can't stat temporary file"); mbufsize = sbuf.st_size; if (!(mbuf = malloc((u_int)mbufsize))) ! err(1, "out of memory"); if (fread(mbuf, sizeof(*mbuf), mbufsize, fp) != mbufsize) ! err(1, "can't read temporary file"); (void)close(fd); } --- 281,291 ---- rewind(fp); if (fstat(fd, &sbuf)) ! errx(1, "can't stat temporary file."); mbufsize = sbuf.st_size; if (!(mbuf = malloc((u_int)mbufsize))) ! errx(1, "out of memory."); if (fread(mbuf, sizeof(*mbuf), mbufsize, fp) != mbufsize) ! errx(1, "can't read temporary file."); (void)close(fd); } --FCuugMFkClbJLl1L-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010427150436.A1170>