GNU bug report logs - #7289
Tramp changes ownership of remote file when saving

Previous Next

Package: emacs;

Reported by: Jo Vermeulen <jo.vermeulen <at> gmail.com>

Date: Wed, 27 Oct 2010 10:54:03 UTC

Severity: important

Found in version 23.1

Done: Michael Albinus <michael.albinus <at> gmx.de>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Jo Vermeulen <jo.vermeulen <at> gmail.com>
Cc: 7289 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: bug#7289: Tramp changes ownership of remote file when saving
Date: Thu, 28 Oct 2010 14:37:18 +0200
Jo Vermeulen <jo.vermeulen <at> gmail.com> writes:

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

Could you, please, try the following patch? It is towards the Emacs-23
branch, line numbers might differ with your tramp.el.

--8<---------------cut here---------------start------------->8---
*** /home/albinus/src/emacs-23/lisp/net/tramp.el.~100136~	2010-10-28 14:31:49.730285001 +0200
--- /home/albinus/src/emacs-23/lisp/net/tramp.el	2010-10-28 14:29:40.990285001 +0200
***************
*** 5008,5014 ****
  	    (setq buffer-file-name filename)
  	    (setq buffer-read-only (not (file-writable-p filename)))
  	    (set-visited-file-modtime)
! 	    (set-buffer-modified-p nil))
  	  (when (and (stringp local-copy)
  		     (or remote-copy (null tramp-temp-buffer-file-name)))
  	    (delete-file local-copy))
--- 5008,5018 ----
  	    (setq buffer-file-name filename)
  	    (setq buffer-read-only (not (file-writable-p filename)))
  	    (set-visited-file-modtime)
! 	    (set-buffer-modified-p nil)
! 	    ;; For root, preserve owner and group when editing files.
! 	    (when (string-equal (file-remote-p filename 'user) "root")
! 	      (set (make-local-variable 'backup-by-copying-when-mismatch) t)
! 	      (put 'backup-by-copying-when-mismatch 'permanent-local t)))
  	  (when (and (stringp local-copy)
  		     (or remote-copy (null tramp-temp-buffer-file-name)))
  	    (delete-file local-copy))
--8<---------------cut here---------------end--------------->8---

> Thanks for your help!
>
> Cheers,
>
> -- Jo

Best regards, Michael.




This bug report was last modified 14 years and 207 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.