From owner-freebsd-audit Sun May 6 11:34:31 2001 Delivered-To: freebsd-audit@freebsd.org Received: from nebula.cybercable.fr (d189.dhcp212-126.cybercable.fr [212.198.126.189]) by hub.freebsd.org (Postfix) with ESMTP id 2AD2437B422 for ; Sun, 6 May 2001 11:34:27 -0700 (PDT) (envelope-from mux@qualys.com) Received: (from mux@localhost) by nebula.cybercable.fr (8.11.3/8.11.3) id f46IYML06718 for audit@FreeBSD.org; Sun, 6 May 2001 20:34:22 +0200 (CEST) (envelope-from mux) Date: Sun, 6 May 2001 20:34:22 +0200 From: Maxime Henrion To: audit@FreeBSD.org Subject: Patch for wall.c from OpenBSD Message-ID: <20010506203422.D673@nebula.cybercable.fr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="R3G7APHDIzY6R/pk" Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --R3G7APHDIzY6R/pk Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, This patch makes wall open the file with the egid. It was taken from the OpenBSD commits of Kris mailbox. I have ripped out the err() -> errx() changes and fixed the non-style(9) compliant declaration. 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/ --R3G7APHDIzY6R/pk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="wall.c.diff" *** /usr/src/usr.bin/wall/wall.c Fri Mar 2 08:30:37 2001 --- wall.c Sun May 6 20:29:49 2001 *************** *** 189,194 **** --- 189,195 ---- 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,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') { --- 226,238 ---- } (void)fprintf(fp, "%79s\r\n", " "); ! 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') { --R3G7APHDIzY6R/pk-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message