bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Michael Albinus
Subject: bug#7289: Tramp changes ownership of remote file when saving
Date: Thu, 28 Oct 2010 14:37:18 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

Jo Vermeulen <jo.vermeulen@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.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]