From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jo Vermeulen Newsgroups: gmane.emacs.bugs Subject: bug#7289: Tramp changes ownership of remote file when saving Date: Fri, 29 Oct 2010 12:42:18 +0200 Message-ID: References: <874oc6ze69.fsf@gmx.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1288350807 398 80.91.229.12 (29 Oct 2010 11:13:27 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 29 Oct 2010 11:13:27 +0000 (UTC) Cc: 7289@debbugs.gnu.org To: Michael Albinus Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Oct 29 13:13:24 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PBmtb-00075a-9I for geb-bug-gnu-emacs@m.gmane.org; Fri, 29 Oct 2010 13:13:19 +0200 Original-Received: from localhost ([127.0.0.1]:34267 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PBmta-0008Qg-K5 for geb-bug-gnu-emacs@m.gmane.org; Fri, 29 Oct 2010 07:13:18 -0400 Original-Received: from [140.186.70.92] (port=35112 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PBmtS-0008Pk-3v for bug-gnu-emacs@gnu.org; Fri, 29 Oct 2010 07:13:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PBmtQ-0005cA-OV for bug-gnu-emacs@gnu.org; Fri, 29 Oct 2010 07:13:10 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:56758) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PBmtQ-0005c6-Ll for bug-gnu-emacs@gnu.org; Fri, 29 Oct 2010 07:13:08 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1PBmMQ-0001hO-H7; Fri, 29 Oct 2010 06:39:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Jo Vermeulen Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 29 Oct 2010 10:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7289 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 7289-submit@debbugs.gnu.org id=B7289.12883487116513 (code B ref 7289); Fri, 29 Oct 2010 10:39:02 +0000 Original-Received: (at 7289) by debbugs.gnu.org; 29 Oct 2010 10:38:31 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PBmLv-0001gz-0p for submit@debbugs.gnu.org; Fri, 29 Oct 2010 06:38:31 -0400 Original-Received: from mail-qw0-f44.google.com ([209.85.216.44]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PBmLr-0001gu-94 for 7289@debbugs.gnu.org; Fri, 29 Oct 2010 06:38:27 -0400 Original-Received: by qwb7 with SMTP id 7so2978097qwb.3 for <7289@debbugs.gnu.org>; Fri, 29 Oct 2010 03:42:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=Ioob0qlY7vsIgDfbWqiOs7CdGiIhBLY3vC2etI/QL6c=; b=o0qtSTo776YNCL1B7eP1W47cGvEj1OdeTQomUs6taP99K2Mj0AgaB3DWoAV47TpuwV CTVqMjEYbLcwctLimebsGERxIGR7JIdfv/lAFHdzTE1ikoyntsShLrH+ktaVDF+cmqA4 zPBaelVtrog9ZuZJjLRn0Nqtptkh6w+ruxAB8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=OtqTeNs6BQ6QBUYQlIr6cGU7UsvudpWSvVlUYG0Vm/LJ7+4PEJ303eYrwQ7q1WXOu7 UTcdcgylzPK+oI1EzHxLmS/oApK9SYRP15GjscYyytcbYiqCHwz07UfD84mRwrXhyLyI MUpMvVKR9QTwb6Gi89WjKXLt/JDVqjo1mxplE= Original-Received: by 10.229.238.82 with SMTP id kr18mr5036962qcb.242.1288348958437; Fri, 29 Oct 2010 03:42:38 -0700 (PDT) Original-Received: by 10.229.127.99 with HTTP; Fri, 29 Oct 2010 03:42:18 -0700 (PDT) In-Reply-To: <874oc6ze69.fsf@gmx.de> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Fri, 29 Oct 2010 06:39:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:41221 Archived-At: On Thu, Oct 28, 2010 at 2:37 PM, Michael Albinus w= rote: > Jo Vermeulen 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~ =C2=A0 =C2=A0 = =C2=A0 2010-10-28 14:31:49.730285001 +0200 > --- /home/albinus/src/emacs-23/lisp/net/tramp.el =C2=A0 =C2=A0 =C2=A0 =C2= =A02010-10-28 14:29:40.990285001 +0200 > *************** > *** 5008,5014 **** > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(setq buffer-file-name filename) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(setq buffer-read-only (not (fil= e-writable-p filename))) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(set-visited-file-modtime) > ! =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (set-buffer-modified-p nil)) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(when (and (stringp local-copy) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (or= remote-copy (null tramp-temp-buffer-file-name))) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(delete-file local-copy)) > --- 5008,5018 ---- > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(setq buffer-file-name filename) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(setq buffer-read-only (not (fil= e-writable-p filename))) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(set-visited-file-modtime) > ! =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (set-buffer-modified-p nil) > ! =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; For root, preserve owner and grou= p when editing files. > ! =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (when (string-equal (file-remote-p f= ilename 'user) "root") > ! =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (set (make-local-variable 'ba= ckup-by-copying-when-mismatch) t) > ! =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (put 'backup-by-copying-when-= mismatch 'permanent-local t))) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(when (and (stringp local-copy) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (or= remote-copy (null tramp-temp-buffer-file-name))) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(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