[comp.soft-sys.andrew] Proposal: one line change to buffer.c.

wdc@ATHENA.MIT.EDU (Bill Cattey) (02/21/91)

Here at MIT, (why do so many of my notes to this list begin with "Here
at MIT"?) we have an interesting problem with file protection modes:

Our default umask for users is 77, so all files they create are
unreadable to the world.

A user having a problem with an ez file must chmod it so I can read it.

If they save the file after chmod'ing it, the readibility is masked out
by the umask.

The default GNU Emacs behavior solves this problem by doing a chmod on
the saved file to match the modes of the previous version.

The following change to buffer.c will do the same:  If and only if the
file already exists, it will get chmod'ed to match the original modes.

(All right, one line of code and three lines of comment to tell what's up.)

Do people think making this change is a good idea?

-wdc

*** /tmp/,RCSt1012884	Wed Feb 20 11:27:56 1991
--- buffer.c	Tue Feb 19 19:01:18 1991
***************
*** 593,598 ****
--- 593,602 ----
  	closeCode = -1;
      }
      else {
+ 	/* Now for GNU-Emacs compatibility, we chmod the file. */
+ 	/* This is so that we preserve the modes of the original */
+ 	/* file, un-modified by umask. */
+ 	if (fileExists) chmod(filename, originalMode);
  #ifdef AFS_ENV
  	if (flags & buffer_ReliableWrite) { /* Go for the expensive but safe operation. */
  	    if ((closeCode = vclose(fileno(outFile))) < 0) /* stdio can trash errno. */