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: Jo Vermeulen
Subject: bug#7289: Tramp changes ownership of remote file when saving
Date: Fri, 29 Oct 2010 12:42:18 +0200

On Thu, Oct 28, 2010 at 2:37 PM, Michael Albinus <michael.albinus@gmx.de> wrote:
> 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---

To which function does this patch apply? Couldn't immediately find it,
but my code might be different from the current Emacs 23 branch ...

Thanks!

-- Jo

-- Jo





reply via email to

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