rwhod files have wrong mode

Steven M. Schultz sms at wlv.imsd.contel.com
Fri Jul 21 07:45:06 AEST 1989


	This isn't really a "bug", but a fix for an annoyance.  'rwhod'
	uses the system default for its umask() and can end up creating
	files which only the superuser can read.  the choice was to either
	make 'ruptime' setuid or reserved to superusers only, or to have 
	'rwhod' change the mode to something reasonable.

	The fix below or's in 0444 to the mode - forcing the files to
	be readable by everyone.

*** rwhod.c.old	Wed Jul 12 23:47:51 1989
--- rwhod.c	Thu Jul 20 13:48:33 1989
***************
*** 223,228 ****
--- 223,231 ----
  		(void) write(whod, (char *)&wd, cc);
  		if (fstat(whod, &st) < 0 || st.st_size > cc)
  			ftruncate(whod, (long)cc);
+ #define	ALLREAD (S_IREAD | (S_IREAD >> 3) | (S_IREAD >>6))
+ 		if ((st.st_mode & ALLREAD) != ALLREAD)
+ 			fchmod(whod, st.st_mode | ALLREAD);
  		(void) close(whod);
  	}
  }



More information about the Comp.bugs.2bsd mailing list