From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.bugs Subject: bug#9879: 23.3; making script executable with tramp Date: Wed, 16 Nov 2011 20:59:56 +0100 Message-ID: <87pqgrsurn.fsf@gmx.de> References: <14vcrbfv28.fsf@e15.cs.rochester.edu> <20111027234209.GA16523@e15.cs.rochester.edu> <31obwi8k4o.fsf@fencepost.gnu.org> <87vcqocnhi.fsf@gmx.de> <9A00DEFE-B398-4D9A-9C48-1BD2FE273E19@cs.rochester.edu> <87bosgt2wt.fsf@gmx.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1321473688 19296 80.91.229.12 (16 Nov 2011 20:01:28 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 16 Nov 2011 20:01:28 +0000 (UTC) Cc: 9879@debbugs.gnu.org, Dan Gildea To: Daniel Gildea Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Nov 16 21:01:23 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RQlfd-0003YP-3b for geb-bug-gnu-emacs@m.gmane.org; Wed, 16 Nov 2011 21:01:21 +0100 Original-Received: from localhost ([::1]:57249 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RQlfc-0008OK-MZ for geb-bug-gnu-emacs@m.gmane.org; Wed, 16 Nov 2011 15:01:20 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:53830) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RQlfZ-0008O2-HQ for bug-gnu-emacs@gnu.org; Wed, 16 Nov 2011 15:01:18 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RQlfY-00016z-2n for bug-gnu-emacs@gnu.org; Wed, 16 Nov 2011 15:01:17 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:52298) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RQlfX-00016u-W5 for bug-gnu-emacs@gnu.org; Wed, 16 Nov 2011 15:01:16 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1RQlgI-0004e9-0T for bug-gnu-emacs@gnu.org; Wed, 16 Nov 2011 15:02:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Michael Albinus Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 16 Nov 2011 20:02:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 9879 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 9879-submit@debbugs.gnu.org id=B9879.132147366617796 (code B ref 9879); Wed, 16 Nov 2011 20:02:01 +0000 Original-Received: (at 9879) by debbugs.gnu.org; 16 Nov 2011 20:01:06 +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 1RQlfK-0004ct-9S for submit@debbugs.gnu.org; Wed, 16 Nov 2011 15:01:05 -0500 Original-Received: from mailout-de.gmx.net ([213.165.64.23]) by debbugs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1RQlfG-0004cQ-03 for 9879@debbugs.gnu.org; Wed, 16 Nov 2011 15:00:59 -0500 Original-Received: (qmail invoked by alias); 16 Nov 2011 20:00:01 -0000 Original-Received: from p57BB96DA.dip0.t-ipconnect.de (EHLO detlef.gmx.de) [87.187.150.218] by mail.gmx.net (mp049) with SMTP; 16 Nov 2011 21:00:01 +0100 X-Authenticated: #3708877 X-Provags-ID: V01U2FsdGVkX1+8Obt41J+8tRmLUsKJxCBQow4OEXLkXGbRkY1owM YGOR2SN3+Z5+k/ In-Reply-To: <87bosgt2wt.fsf@gmx.de> (Michael Albinus's message of "Sun, 13 Nov 2011 17:14:58 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.90 (gnu/linux) X-Y-GMX-Trusted: 0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Wed, 16 Nov 2011 15:02:02 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 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: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:53999 Archived-At: Michael Albinus writes: > You are working on "/u/gildea/xx.sh", which is a symlink to > "/home/vax7/u19/gildea/xx.sh". You have written "/u/gildea/xx.sh". Tramp > tries to check "/home/vax7/u19/gildea/xx.sh" file properties afterwards, > and it decides that this file doesn't exist. > > This is likely because of Tramp's cache, which hasn't been refreshed > accordingly for the symlink's target after writing. > > I will check how to fix this; unfortunately there is no simple patch. It > might take a day, or two. The following two patches shall solve the problem, could you, please verify? The patches are for Emacs 23.3, however, the line numbers might be a little bit different. --8<---------------cut here---------------start------------->8--- Index: tramp.el =================================================================== RCS file: /sources/tramp/tramp/lisp/tramp.el,v retrieving revision 2.814.2.16 diff -c -r2.814.2.16 tramp.el *** tramp.el 12 Oct 2011 14:56:21 -0000 2.814.2.16 --- tramp.el 16 Nov 2011 19:50:48 -0000 *************** *** 2671,2776 **** (defun tramp-handle-file-truename (filename &optional counter prev-dirs) "Like `file-truename' for Tramp files." (with-parsed-tramp-file-name (expand-file-name filename) nil ! (with-file-property v localname "file-truename" ! (let ((result nil)) ; result steps in reverse order ! (tramp-message v 4 "Finding true name for `%s'" filename) ! (cond ! ;; Use GNU readlink --canonicalize-missing where available. ! ((tramp-get-remote-readlink v) ! (setq result ! (tramp-send-command-and-read ! v ! (format "echo \"\\\"`%s --canonicalize-missing %s`\\\"\"" ! (tramp-get-remote-readlink v) ! (tramp-shell-quote-argument localname))))) ! ! ;; Use Perl implementation. ! ((and (tramp-get-remote-perl v) ! (tramp-get-connection-property v "perl-file-spec" nil) ! (tramp-get-connection-property v "perl-cwd-realpath" nil)) ! (tramp-maybe-send-script ! v tramp-perl-file-truename "tramp_perl_file_truename") ! (setq result ! (tramp-send-command-and-read ! v ! (format "tramp_perl_file_truename %s" ! (tramp-shell-quote-argument localname))))) ! ! ;; Do it yourself. We bind `directory-sep-char' here for ! ;; XEmacs on Windows, which would otherwise use backslash. ! (t (let* ((directory-sep-char ?/) ! (steps (tramp-compat-split-string localname "/")) ! (localnamedir (tramp-run-real-handler ! 'file-name-as-directory (list localname))) ! (is-dir (string= localname localnamedir)) ! (thisstep nil) ! (numchase 0) ! ;; Don't make the following value larger than ! ;; necessary. People expect an error message in a ! ;; timely fashion when something is wrong; ! ;; otherwise they might think that Emacs is hung. ! ;; Of course, correctness has to come first. ! (numchase-limit 20) ! symlink-target) ! (while (and steps (< numchase numchase-limit)) ! (setq thisstep (pop steps)) ! (tramp-message ! v 5 "Check %s" ! (mapconcat 'identity ! (append '("") (reverse result) (list thisstep)) ! "/")) ! (setq symlink-target ! (nth 0 (file-attributes ! (tramp-make-tramp-file-name ! method user host ! (mapconcat 'identity ! (append '("") ! (reverse result) ! (list thisstep)) ! "/"))))) ! (cond ((string= "." thisstep) ! (tramp-message v 5 "Ignoring step `.'")) ! ((string= ".." thisstep) ! (tramp-message v 5 "Processing step `..'") ! (pop result)) ! ((stringp symlink-target) ! ;; It's a symlink, follow it. ! (tramp-message v 5 "Follow symlink to %s" symlink-target) ! (setq numchase (1+ numchase)) ! (when (file-name-absolute-p symlink-target) ! (setq result nil)) ! ;; If the symlink was absolute, we'll get a string like ! ;; "/user@host:/some/target"; extract the ! ;; "/some/target" part from it. ! (when (tramp-tramp-file-p symlink-target) ! (unless (tramp-equal-remote filename symlink-target) ! (tramp-error ! v 'file-error ! "Symlink target `%s' on wrong host" symlink-target)) ! (setq symlink-target localname)) ! (setq steps ! (append (tramp-compat-split-string ! symlink-target "/") ! steps))) ! (t ! ;; It's a file. ! (setq result (cons thisstep result))))) ! (when (>= numchase numchase-limit) ! (tramp-error ! v 'file-error ! "Maximum number (%d) of symlinks exceeded" numchase-limit)) ! (setq result (reverse result)) ! ;; Combine list to form string. ! (setq result ! (if result ! (mapconcat 'identity (cons "" result) "/") ! "/")) ! (when (and is-dir (or (string= "" result) ! (not (string= (substring result -1) "/")))) ! (setq result (concat result "/")))))) ! (tramp-message v 4 "True name of `%s' is `%s'" filename result) ! (tramp-make-tramp-file-name method user host result))))) ;; Basic functions. --- 2671,2780 ---- (defun tramp-handle-file-truename (filename &optional counter prev-dirs) "Like `file-truename' for Tramp files." (with-parsed-tramp-file-name (expand-file-name filename) nil ! (tramp-make-tramp-file-name method user host ! (with-file-property v localname "file-truename" ! (let ((result nil)) ; result steps in reverse order ! (tramp-message v 4 "Finding true name for `%s'" filename) ! (cond ! ;; Use GNU readlink --canonicalize-missing where available. ! ((tramp-get-remote-readlink v) ! (setq result ! (tramp-send-command-and-read ! v ! (format "echo \"\\\"`%s --canonicalize-missing %s`\\\"\"" ! (tramp-get-remote-readlink v) ! (tramp-shell-quote-argument localname))))) ! ! ;; Use Perl implementation. ! ((and (tramp-get-remote-perl v) ! (tramp-get-connection-property v "perl-file-spec" nil) ! (tramp-get-connection-property v "perl-cwd-realpath" nil)) ! (tramp-maybe-send-script ! v tramp-perl-file-truename "tramp_perl_file_truename") ! (setq result ! (tramp-send-command-and-read ! v ! (format "tramp_perl_file_truename %s" ! (tramp-shell-quote-argument localname))))) ! ! ;; Do it yourself. We bind `directory-sep-char' here for ! ;; XEmacs on Windows, which would otherwise use backslash. ! (t (let* ((directory-sep-char ?/) ! (steps (tramp-compat-split-string localname "/")) ! (localnamedir (tramp-run-real-handler ! 'file-name-as-directory (list localname))) ! (is-dir (string= localname localnamedir)) ! (thisstep nil) ! (numchase 0) ! ;; Don't make the following value larger than ! ;; necessary. People expect an error message in ! ;; a timely fashion when something is wrong; ! ;; otherwise they might think that Emacs is hung. ! ;; Of course, correctness has to come first. ! (numchase-limit 20) ! symlink-target) ! (while (and steps (< numchase numchase-limit)) ! (setq thisstep (pop steps)) ! (tramp-message ! v 5 "Check %s" ! (mapconcat 'identity ! (append '("") (reverse result) (list thisstep)) ! "/")) ! (setq symlink-target ! (nth 0 (file-attributes ! (tramp-make-tramp-file-name ! method user host ! (mapconcat 'identity ! (append '("") ! (reverse result) ! (list thisstep)) ! "/"))))) ! (cond ((string= "." thisstep) ! (tramp-message v 5 "Ignoring step `.'")) ! ((string= ".." thisstep) ! (tramp-message v 5 "Processing step `..'") ! (pop result)) ! ((stringp symlink-target) ! ;; It's a symlink, follow it. ! (tramp-message ! v 5 "Follow symlink to %s" symlink-target) ! (setq numchase (1+ numchase)) ! (when (file-name-absolute-p symlink-target) ! (setq result nil)) ! ;; If the symlink was absolute, we'll get a ! ;; string like "/user@host:/some/target"; ! ;; extract the "/some/target" part from it. ! (when (tramp-tramp-file-p symlink-target) ! (unless (tramp-equal-remote filename symlink-target) ! (tramp-error ! v 'file-error ! "Symlink target `%s' on wrong host" ! symlink-target)) ! (setq symlink-target localname)) ! (setq steps ! (append (tramp-compat-split-string ! symlink-target "/") ! steps))) ! (t ! ;; It's a file. ! (setq result (cons thisstep result))))) ! (when (>= numchase numchase-limit) ! (tramp-error ! v 'file-error ! "Maximum number (%d) of symlinks exceeded" numchase-limit)) ! (setq result (reverse result)) ! ;; Combine list to form string. ! (setq result ! (if result ! (mapconcat 'identity (cons "" result) "/") ! "/")) ! (when (and is-dir ! (or (string= "" result) ! (not (string= (substring result -1) "/")))) ! (setq result (concat result "/")))))) ! (tramp-message v 4 "True name of `%s' is `%s'" filename result) ! result))))) ;; Basic functions. --8<---------------cut here---------------end--------------->8--- --8<---------------cut here---------------start------------->8--- Index: tramp-cache.el =================================================================== RCS file: /sources/tramp/tramp/lisp/tramp-cache.el,v retrieving revision 2.57.2.1 diff -c -r2.57.2.1 tramp-cache.el *** tramp-cache.el 24 Jan 2011 10:09:40 -0000 2.57.2.1 --- tramp-cache.el 16 Nov 2011 19:54:34 -0000 *************** *** 145,150 **** --- 145,155 ---- (defun tramp-flush-file-property (vec file) "Remove all properties of FILE in the cache context of VEC." + ;; Remove file property of symlinks. + (let ((truename (tramp-get-file-property vec file "file-truename" nil))) + (when (and (stringp truename) + (not (string-equal file truename))) + (tramp-flush-file-property vec truename))) ;; Unify localname. (setq vec (copy-sequence vec)) (aset vec 3 (tramp-run-real-handler 'directory-file-name (list file))) --8<---------------cut here---------------end--------------->8--- Best regards, Michael.