Subject: bug#7289: Tramp changes ownership of remote file when saving

From: Jo Vermeulen <[email-masked]>
Date: Wed, 27 Oct 2010 17:21:45 +0200

On Wed, Oct 27, 2010 at 3:53 PM, Stefan Monnier
<[email-masked]> wrote:
>> When editing a remote file over SSH using tramp, emacs changes the ownership
>> of the file. I was logged in as root, and the file had ownership svn:svn.
>> After saving, however, emacs changed the ownership to root:root. The backup
>> file (filename~) did have the user/group settings however.
>
> What are your settings for backup-by-copying and
> backup-by-copying-when-mismatch?

C-h-v backup-by-coping gives me:

"backup-by-copying's value is nil"

Which, I assume, means that Emacs might use renaming for backups.

And C-h-v backup-by-coping-when-mismatch results in:

"backup-by-copying-when-mismatch's value is nil"

I guess if this value would be non-nil, my problem would be solved?

Additionally, C-h-v backup-by-copying-when-privileged-mismatch gives me:

"backup-by-copying-when-privileged-mismatch's value is 200"

I just toggled backup-by-copying-when-mismatch and tried it again, and
indeed, it does work now.

I'm just wondering if this means that the default behavior is broken?
It seems Emacs automatically sets backup-by-copying-when-mismatch to t
when it is run by the superuser (root) to overcome this problem
(source: http://www.delorie.com/gnu/docs/emacs/emacs_117.html).

I don't think many people will run Emacs as root in this day and age.
However, they might log in as root on a remote server, or edit a file
as root (using sudo/su). Maybe Emacs or Tramp should also
automatically set the backup-by-copying-when-mismatch variable to t in
those cases?

Thanks for your help!

Cheers,

-- Jo