[gnu.emacs] Unwanted chown's done on files being edited

KSpagnol@massey.ac.nz (Ken Spagnolo) (02/08/90)

We have 18.55 running on a Pyramid 90x and some DECstation 3100's.
When I save a file that I've been editing as root, the owner of that
file becomes root, regardless of what it was to start with.  What a
pain this is.  This was not the case when we were running 18.51, nor
did I knowingly do anything at compile time to include or disable this
"feature" in either case.  A brief look thru the source shows that
chown is called only as a command in dired mode.

Can anyone say how to get around this one?  Thanx.

-- 
Ken Spagnolo - Systems Programmer, Postmaster, Usenet Administrator, etc.
   Computer Centre, Massey University, Palmerston North, New Zealand
K.Spagnolo@massey.ac.nz  Phone: +64-63-69099 x8587  New Zealand = GMT+12

barmar@think.com (Barry Margolin) (02/08/90)

GNU Emacs doesn't chown files when writing them.  The reason the owner is
getting set is that it's a new file.  Emacs renames the file you read in to
file~, and then writes out a new file.

Emacs can be told to create the backup file by copying the original file
instead of renaming it.  Set the variable backup-by-copying to t.

I consider the current default behavior to be a big win.  When there are
files that are edited by many different users (such as the aliases file) it
is nice to be able to tell who last edited a file (so you can inform them
of their error when they make a mistake).
--
Barry Margolin, Thinking Machines Corp.

barmar@think.com
{uunet,harvard}!think!barmar

darrylo@HPSRDMO.HP.COM (Darryl Okahata) (02/08/90)

Ken Spagnolo writes:
> We have 18.55 running on a Pyramid 90x and some DECstation 3100's.
> When I save a file that I've been editing as root, the owner of that
> file becomes root, regardless of what it was to start with.  What a
> pain this is.  This was not the case when we were running 18.51, nor
> did I knowingly do anything at compile time to include or disable this
> "feature" in either case.  A brief look thru the source shows that
> chown is called only as a command in dired mode.

     I suspect that the variable `make-backup-files' is non-nil, and
that the variables `backup-by-copying' and
`backup-by-copying-when-mismatch' are both nil.  What is probably
happening is that, when you write out the file, Emacs renames the
*original* file to that of the backup filename (whatever it is) and then
proceeds to write out the file.  As the original file was renamed, the
newly written file gets "root" ownerships (this is not a problem with
just "root" -- you'll have similar problems with other accounts).

     To solve this problem, you have a number of choices:

1. Disable backups.
2. Set the variable `backup-by-copying-when-mismatch' to `t'.  From the
   documentation for this variable:

	Non-nil means create backups by copying if this preserves owner
	or group.  Renaming may still be used (subject to control of
	other variables) when it would not result in changing the owner
	or group of the file; that is, for files which are owned by you
	and whose group matches the default for a new file created there
	by you.  This variable is relevant only if backup-by-copying is
	nil.

3. Set the variable `backup-by-copying' to `t'.

     -- Darryl Okahata
	UUCP: {hplabs!, hpcea!, hpfcla!} hpnmd!darrylo
	Internet: darrylo%hpnmd@hpcea.HP.COM

DISCLAIMER: this message is the author's personal opinion and does not
constitute the support, opinion or policy of Hewlett-Packard or of the
little green men that have been following him all day.