From owner-freebsd-audit Fri Apr 27 6: 4:51 2001 Delivered-To: freebsd-audit@freebsd.org Received: from nebula.cybercable.fr (d217.dhcp212-198-126.noos.fr [212.198.126.217]) by hub.freebsd.org (Postfix) with ESMTP id 0628B37B423 for ; Fri, 27 Apr 2001 06:04:45 -0700 (PDT) (envelope-from mux@qualys.com) Received: (from mux@localhost) by nebula.cybercable.fr (8.11.3/8.11.3) id f3RD4b301323 for audit@FreeBSD.org; Fri, 27 Apr 2001 15:04:37 +0200 (CEST) (envelope-from mux) Date: Fri, 27 Apr 2001 15:04:36 +0200 From: Maxime Henrion To: audit@FreeBSD.org Subject: [PATCH] wall.c changes from OpenBSD Message-ID: <20010427150436.A1170@nebula.cybercable.fr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="FCuugMFkClbJLl1L" Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --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