Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 6 May 2001 20:34:22 +0200
From:      Maxime Henrion <mux@qualys.com>
To:        audit@FreeBSD.org
Subject:   Patch for wall.c from OpenBSD
Message-ID:  <20010506203422.D673@nebula.cybercable.fr>

next in thread | raw e-mail | index | archive | help

--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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010506203422.D673>