From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thierry Volpiatto Newsgroups: gmane.emacs.bugs Subject: bug#10489: 24.0.92; dired-do-copy may create infinite directory hierarchy Date: Fri, 13 Jan 2012 12:00:18 +0100 Message-ID: <87fwfjsw8t.fsf@gmail.com> References: <87mx9su32g.fsf@web.de> <87sjjkfvwt.fsf@gmail.com> <8362ggkquq.fsf@gnu.org> <87lipcrlga.fsf@gmail.com> <87fwfkc4pn.fsf@gmx.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-Trace: dough.gmane.org 1326453049 21607 80.91.229.12 (13 Jan 2012 11:10:49 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 13 Jan 2012 11:10:49 +0000 (UTC) To: 10489@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jan 13 12:10:45 2012 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 1Rlf1i-0003k1-Rv for geb-bug-gnu-emacs@m.gmane.org; Fri, 13 Jan 2012 12:10:30 +0100 Original-Received: from localhost ([::1]:59579 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rleu3-0004tN-Il for geb-bug-gnu-emacs@m.gmane.org; Fri, 13 Jan 2012 06:02:35 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:53545) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rleu0-0004t8-6E for bug-gnu-emacs@gnu.org; Fri, 13 Jan 2012 06:02:33 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rletu-0002aq-8k for bug-gnu-emacs@gnu.org; Fri, 13 Jan 2012 06:02:32 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:32980) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rletu-0002am-6Z for bug-gnu-emacs@gnu.org; Fri, 13 Jan 2012 06:02:26 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1RleuU-000634-AO for bug-gnu-emacs@gnu.org; Fri, 13 Jan 2012 06:03:02 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <87mx9su32g.fsf@web.de> Resent-From: Thierry Volpiatto Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 13 Jan 2012 11:03:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 10489 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.132645252323178 (code B ref -1); Fri, 13 Jan 2012 11:03:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 13 Jan 2012 11:02:03 +0000 Original-Received: from localhost ([127.0.0.1]:55885 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RletW-00061c-6M for submit@debbugs.gnu.org; Fri, 13 Jan 2012 06:02:02 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:37691) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RletS-00061N-VP for submit@debbugs.gnu.org; Fri, 13 Jan 2012 06:02:00 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rlesm-0002XR-IT for submit@debbugs.gnu.org; Fri, 13 Jan 2012 06:01:22 -0500 Original-Received: from lists.gnu.org ([140.186.70.17]:51817) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rlesm-0002XN-H0 for submit@debbugs.gnu.org; Fri, 13 Jan 2012 06:01:16 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:53446) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rlesc-0004qX-UX for bug-gnu-emacs@gnu.org; Fri, 13 Jan 2012 06:01:16 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RlesS-0002Vb-MD for bug-gnu-emacs@gnu.org; Fri, 13 Jan 2012 06:01:06 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]:49572) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlesS-0002VP-D6 for bug-gnu-emacs@gnu.org; Fri, 13 Jan 2012 06:00:56 -0500 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1RlesQ-0007NZ-QA for bug-gnu-emacs@gnu.org; Fri, 13 Jan 2012 12:00:54 +0100 Original-Received: from 121.77.197.77.rev.sfr.net ([77.197.77.121]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 13 Jan 2012 12:00:54 +0100 Original-Received: from thierry.volpiatto by 121.77.197.77.rev.sfr.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 13 Jan 2012 12:00:54 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 177 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 121.77.197.77.rev.sfr.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux) Cancel-Lock: sha1:aK/501LspyIUzF/BwaIcee4UIqw= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list 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:55678 Archived-At: --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi Michael, Michael Albinus writes: > Thierry Volpiatto writes: > >> Here a version of the patch that use `equal' and handle also same error >> on remotes files. >> i.e (copy-directory "/sudo:host:/home/user/Test" "/home/user/Test") > > Your code seems also to suppress > > (copy-directory "/sssh:remotehost:/home/user/Test" "/home/user/Test") > > Why that? Because I forget to handle this case ;-). Here the patch modified that handle this. I want to only suppress the use of: (copy-directory "/sudo:host:/home/user/Test" "/home/user/Test") or (copy-directory "/sudo:host:/home/user/Test" "/sudo:host:/home/user/Test") =2D-=20 Thierry Get my Gnupg key: gpg --keyserver pgp.mit.edu --recv-keys 59F29997=20 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=Singlepatch-r118414ToTip.patch Content-Transfer-Encoding: quoted-printable ##Merge of all patches applied from revision 118413 ## patch-r118414: Fix error when trying to copy directory on itself (bug#10= 489). ## patch-r118415: * lisp/dired-aux.el (dired-copy-file-recursive): Handle a= lso remote file/dir. ## patch-r118416: "New patch" ##=20 diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el =2D-- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -1264,6 +1264,13 @@ =20 (defun dired-copy-file-recursive (from to ok-flag &optional preserve-time top recursive) + (when (equal (or (and (equal "sudo" (file-remote-p (file-name-as-directo= ry from) 'method)) + (file-remote-p (file-name-as-directory from) 'loca= lname)) + (file-name-as-directory from)) + (or (and (equal "sudo" (file-remote-p (file-name-as-directo= ry to) 'method)) + (file-remote-p (file-name-as-directory to) 'localn= ame)) + (file-name-as-directory to))) + (error "Can't copy directory `%s' on itself" from)) (let ((attrs (file-attributes from))) (if (and recursive (eq t (car attrs)) @@ -1402,7 +1409,7 @@ newfile's entry, or t to use the current marker character if the old file was marked." (let (dired-create-files-failures failures =2D skipped (success-count 0) (total (length fn-list))) + skipped (success-count 0) (total (leng= th fn-list))) (let (to overwrite-query overwrite-backup-query) ; for dired-handle-overwrite (dolist (from fn-list) @@ -1431,7 +1438,28 @@ (marker-char (dired-file-marker from)) ; slow (t nil)))) (when (and (file-directory-p from) =2D (file-directory-p to) + (or + (equal + ;; Test if 'from' + ;; is a remote file localname with sudo method. + (or (and (equal + "sudo" + (file-remote-p (file-name-as-directory = from) + 'method)) + (file-remote-p (file-name-as-directory f= rom) + 'localname)) + (file-name-as-directory from)) + ;; Test if 'to' + ;; is a remote file localname with sudo method. + (or (and (equal + "sudo" + (file-remote-p (file-name-as-directory = to) + 'method)) + (file-remote-p (file-name-as-directory + (file-name-directory to)) + 'localname)) + (file-name-as-directory (file-name-directory = to)))) + (file-directory-p to)) (eq file-creator 'dired-copy-file)) (setq to (file-name-directory to))) (condition-case err @@ -1456,21 +1484,21 @@ (setq failures (nconc failures dired-create-files-failures)) (dired-log-summary (format "%s failed for %d file%s in %d requests" =2D operation (length failures) =2D (dired-plural-s (length failures)) =2D total) + operation (length failures) + (dired-plural-s (length failures)) + total) failures)) (failures (dired-log-summary (format "%s failed for %d of %d file%s" =2D operation (length failures) =2D total (dired-plural-s total)) + operation (length failures) + total (dired-plural-s total)) failures)) (skipped (dired-log-summary (format "%s: %d of %d file%s skipped" =2D operation (length skipped) total =2D (dired-plural-s total)) + operation (length skipped) total + (dired-plural-s total)) skipped)) (t (message "%s: %s file%s" diff --git a/lisp/files.el b/lisp/files.el =2D-- a/lisp/files.el +++ b/lisp/files.el @@ -4928,6 +4928,13 @@ (format "Copy directory %s to: " dir) default-directory default-directory nil nil) current-prefix-arg t nil))) + (when (equal (or (and (equal "sudo" (file-remote-p (file-name-as-directo= ry directory) 'method)) + (file-remote-p (file-name-as-directory directory) = 'localname)) + (file-name-as-directory directory)) + (or (and (equal "sudo" (file-remote-p (file-name-as-directo= ry newname) 'method)) + (file-remote-p (file-name-as-directory newname) 'l= ocalname)) + (file-name-as-directory newname))) + (error "Can't copy directory `%s' on itself" directory)) ;; If default-directory is a remote directory, make sure we find its ;; copy-directory handler. (let ((handler (or (find-file-name-handler directory 'copy-directory) --=-=-=-- --==-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iEYEARECAAYFAk8QDsIACgkQKNF/U1nymZc8jgCgn/HfLQFe5VNkLZR1tyCQ1m5X iWQAn3NpW4ClBWER/DZEUgrf2wzkMl/N =v2yZ -----END PGP SIGNATURE----- --==-=-=--