unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Recursive copies in Dired do not preserve directory permissions
@ 2007-10-20 13:48 Sven Joachim
  2007-10-21  7:25 ` Richard Stallman
  0 siblings, 1 reply; 9+ messages in thread
From: Sven Joachim @ 2007-10-20 13:48 UTC (permalink / raw)
  To: emacs-pretest-bug


It seems that recursive copies in Dired lose directory permissions:

,----
| $ ls -ld .config; ls -l .config
| drwx------ 4 sven sven 4096 Apr 15  2007 .config
| total 8
| drwx------ 2 sven sven 4096 Oct 17 20:53 gtk-2.0
| drwx------ 2 sven sven 4096 Mar  3  2006 menus
`----

After recursively copying .config into a directory named tmp:

,----
| $ ls -ld tmp/.config; ls -l tmp/.config
| drwxr-xr-x 4 sven sven 4096 Oct 20 15:37 tmp/.config
| total 8
| drwxr-xr-x 2 sven sven 4096 Oct 20 15:37 gtk-2.0
| drwxr-xr-x 2 sven sven 4096 Oct 20 15:37 menus
`----

The new permissions are 775, matching my umask (022).


In GNU Emacs 22.1.50.1 (i486-pc-linux-gnu, GTK+ Version 2.10.13)
 of 2007-10-13 on debian, modified by Debian
Windowing system distributor `The X.Org Foundation', version 11.0.10300000
configured using `configure  '--build' 'i486-linux-gnu' '--host' 'i486-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--enable-locallisppath=/etc/emacs-snapshot:/etc/emacs:/usr/local/share/emacs/22.1.50/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/22.1.50/site-lisp:/usr/share/emacs/site-lisp:/usr/share/emacs/22.1.50/leim' '--with-x=yes' '--with-x-toolkit=gtk' 'build_alias=i486-linux-gnu' 'host_alias=i486-linux-gnu' 'CFLAGS=-DDEBIAN -DSITELOAD_PURESIZE_EXTRA=5000 -g -O2''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: C
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: de_DE.UTF-8
  locale-coding-system: utf-8
  default-enable-multibyte-characters: t

Major mode: Buffer Menu

Minor modes in effect:
  shell-dirtrack-mode: t
  display-time-mode: t
  auto-image-file-mode: t
  show-paren-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  unify-8859-on-encoding-mode: t
  utf-translate-cjk-mode: t
  auto-compression-mode: t
  temp-buffer-resize-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
<right> <right> <right> <right> <right> <right> <right> 
<right> <right> <right> <right> <right> <right> <right> 
<right> l R SPC . c o n f i g <return> C-x o <up> <up> 
<return> g <up> <up> <up> <up> <up> <up> <up> <up> 
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up> 
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up> 
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up> 
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up> 
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up> 
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up> 
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up> 
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up> 
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up> 
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up> 
<up> <up> <up> <up> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <up> <up> <up> <up> <up> <up> 
<up> <down> C <up> <return> y e s <return> C-x o M-p 
<left> <left> <left> <left> <left> <left> <left> <left> 
<left> <left> <left> <left> <left> <left> <left> <left> 
<left> <left> <left> <left> <left> <left> <left> <left> 
<right> t m p / <right> <right> <right> <right> <right> 
<right> <right> <right> <right> <right> <right> <right> 
<right> <right> <right> <right> t m p ( <backspace> 
/ <return> M-p M-p <left> <left> <left> <left> <left> 
<left> <left> <left> <backspace> <right> <right> <return> 
M-p M-p <left> <left> <left> <left> <left> <left> <left> 
<left> <left> <left> <left> <left> <backspace> <return> 
<f7> <down> M-x r e p o r t - e m <tab> <return>

Recent messages:
Directory has changed on disk; type g to update Dired
line-move-1: Beginning of buffer
Copy: 1 of 1
Copy: 1 file
History item: 1 [2 times]
History item: 2
History item: 1
History item: 2
Commands: d, s, x, u; f, o, 1, 2, m, v; ~, %; q to quit; ? for help.
Loading emacsbug...done

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Recursive copies in Dired do not preserve directory permissions
  2007-10-20 13:48 Recursive copies in Dired do not preserve directory permissions Sven Joachim
@ 2007-10-21  7:25 ` Richard Stallman
  2007-10-27 18:21   ` Sven Joachim
  0 siblings, 1 reply; 9+ messages in thread
From: Richard Stallman @ 2007-10-21  7:25 UTC (permalink / raw)
  To: Sven Joachim; +Cc: emacs-pretest-bug

Would someone please fix this in Emacs 22, then ack?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Recursive copies in Dired do not preserve directory permissions
  2007-10-21  7:25 ` Richard Stallman
@ 2007-10-27 18:21   ` Sven Joachim
  2007-10-28 13:51     ` Richard Stallman
  0 siblings, 1 reply; 9+ messages in thread
From: Sven Joachim @ 2007-10-27 18:21 UTC (permalink / raw)
  To: rms; +Cc: emacs-pretest-bug

I have now looked into this myself and prepared a minimal patch
(against EMACS_22_BASE) which seems to work.  During that I discovered
another small issue: if a source directory is not readable, the
corresponding target directory is not created.  Before I investigate
that, I'd like to get comments on the following patch, though:

Index: dired-aux.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/dired-aux.el,v
retrieving revision 1.151.2.2
diff -u -r1.151.2.2 dired-aux.el
--- dired-aux.el	8 Aug 2007 07:38:48 -0000	1.151.2.2
+++ dired-aux.el	27 Oct 2007 17:59:56 -0000
@@ -1162,7 +1162,8 @@
 	     (or (eq recursive 'always)
 		 (yes-or-no-p (format "Recursive copies of %s? " from))))
 	;; This is a directory.
-	(let ((files
+	(let ((mode (file-modes from))
+	      (files
 	       (condition-case err
 		   (directory-files from nil dired-re-no-dot)
 		 (file-error
@@ -1176,7 +1177,9 @@
 	    (if (file-exists-p to)
 		(or top (dired-handle-overwrite to))
 	      (condition-case err
-		  (make-directory to)
+		  (progn
+		    (make-directory to)
+		    (set-file-modes to #o700))
 		(file-error
 		 (push (dired-make-relative from)
 		       dired-create-files-failures)
@@ -1195,7 +1198,9 @@
 		(file-error
 		 (push (dired-make-relative thisfrom)
 		       dired-create-files-failures)
-		 (dired-log "Copying error for %s:\n%s\n" thisfrom err))))))
+		 (dired-log "Copying error for %s:\n%s\n" thisfrom err)))))
+	  (if (file-directory-p to)
+	      (set-file-modes to mode)))
       ;; Not a directory.
       (or top (dired-handle-overwrite to))
       (condition-case err


Changelog entry:

2007-10-27  Sven Joachim <svenjoac@gmx.de>

	* dired-aux.el (dired-copy-file-recursive): Preserve directory
	permissions.
	

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Recursive copies in Dired do not preserve directory permissions
  2007-10-27 18:21   ` Sven Joachim
@ 2007-10-28 13:51     ` Richard Stallman
  2007-10-28 16:29       ` Sven Joachim
  2007-10-31 17:01       ` Sven Joachim
  0 siblings, 2 replies; 9+ messages in thread
From: Richard Stallman @ 2007-10-28 13:51 UTC (permalink / raw)
  To: Sven Joachim; +Cc: emacs-pretest-bug

It looks correct to me.  If nobody shows a problem in 3 days,
please install it.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Recursive copies in Dired do not preserve directory permissions
  2007-10-28 13:51     ` Richard Stallman
@ 2007-10-28 16:29       ` Sven Joachim
  2007-10-31 17:01       ` Sven Joachim
  1 sibling, 0 replies; 9+ messages in thread
From: Sven Joachim @ 2007-10-28 16:29 UTC (permalink / raw)
  To: rms; +Cc: emacs-pretest-bug

Richard Stallman <rms@gnu.org> writes:

> It looks correct to me.  If nobody shows a problem in 3 days,
> please install it.

Note that I do not have write access.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Recursive copies in Dired do not preserve directory permissions
  2007-10-28 13:51     ` Richard Stallman
  2007-10-28 16:29       ` Sven Joachim
@ 2007-10-31 17:01       ` Sven Joachim
  2007-10-31 18:26         ` Juanma Barranquero
  1 sibling, 1 reply; 9+ messages in thread
From: Sven Joachim @ 2007-10-31 17:01 UTC (permalink / raw)
  To: rms; +Cc: emacs-pretest-bug

Richard Stallman <rms@gnu.org> writes:

> It looks correct to me.  If nobody shows a problem in 3 days,
> please install it.

Since I cannot do this myself, would someone please install it into
Emacs_22_BASE?  Changelog entry and diff follow again:

2007-10-31  Sven Joachim <svenjoac@gmx.de>

	* dired-aux.el (dired-copy-file-recursive): Preserve directory
	permissions.
	

Index: dired-aux.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/dired-aux.el,v
retrieving revision 1.151.2.2
diff -u -r1.151.2.2 dired-aux.el
--- dired-aux.el	8 Aug 2007 07:38:48 -0000	1.151.2.2
+++ dired-aux.el	27 Oct 2007 17:59:56 -0000
@@ -1162,7 +1162,8 @@
 	     (or (eq recursive 'always)
 		 (yes-or-no-p (format "Recursive copies of %s? " from))))
 	;; This is a directory.
-	(let ((files
+	(let ((mode (file-modes from))
+	      (files
 	       (condition-case err
 		   (directory-files from nil dired-re-no-dot)
 		 (file-error
@@ -1176,7 +1177,9 @@
 	    (if (file-exists-p to)
 		(or top (dired-handle-overwrite to))
 	      (condition-case err
-		  (make-directory to)
+		  (progn
+		    (make-directory to)
+		    (set-file-modes to #o700))
 		(file-error
 		 (push (dired-make-relative from)
 		       dired-create-files-failures)
@@ -1195,7 +1198,9 @@
 		(file-error
 		 (push (dired-make-relative thisfrom)
 		       dired-create-files-failures)
-		 (dired-log "Copying error for %s:\n%s\n" thisfrom err))))))
+		 (dired-log "Copying error for %s:\n%s\n" thisfrom err)))))
+	  (if (file-directory-p to)
+	      (set-file-modes to mode)))
       ;; Not a directory.
       (or top (dired-handle-overwrite to))
       (condition-case err

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Recursive copies in Dired do not preserve directory permissions
  2007-10-31 17:01       ` Sven Joachim
@ 2007-10-31 18:26         ` Juanma Barranquero
  2007-10-31 20:11           ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Juanma Barranquero @ 2007-10-31 18:26 UTC (permalink / raw)
  To: Sven Joachim; +Cc: emacs-pretest-bug, rms

On 10/31/07, Sven Joachim <svenjoac@gmx.de> wrote:

> Since I cannot do this myself, would someone please install it into
> Emacs_22_BASE?

Done.

             Juanma

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Recursive copies in Dired do not preserve directory permissions
  2007-10-31 18:26         ` Juanma Barranquero
@ 2007-10-31 20:11           ` Eli Zaretskii
  2007-10-31 21:23             ` Jason Rumney
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2007-10-31 20:11 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: emacs-pretest-bug, svenjoac, rms

> Date: Wed, 31 Oct 2007 19:26:21 +0100
> From: "Juanma Barranquero" <lekktu@gmail.com>
> Cc: emacs-pretest-bug@gnu.org, rms@gnu.org
> 
> On 10/31/07, Sven Joachim <svenjoac@gmx.de> wrote:
> 
> > Since I cannot do this myself, would someone please install it into
> > Emacs_22_BASE?
> 
> Done.

Did someone verify that (set-file-modes FOO #o700) works on MS-Windows
when FOO is a directory?  If not, it's not safe to install this on the
Emacs 22 branch.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Recursive copies in Dired do not preserve directory permissions
  2007-10-31 20:11           ` Eli Zaretskii
@ 2007-10-31 21:23             ` Jason Rumney
  0 siblings, 0 replies; 9+ messages in thread
From: Jason Rumney @ 2007-10-31 21:23 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Juanma Barranquero, svenjoac, rms, emacs-pretest-bug

Eli Zaretskii wrote:
> Did someone verify that (set-file-modes FOO #o700) works on MS-Windows
> when FOO is a directory?  If not, it's not safe to install this on the
> Emacs 22 branch.
>   

It doesn't cause an error, if that was what you meant.

set-file-modes uses the system library's _chmod function, which only
works on files on Windows, and only the owner write permission has any
effect.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2007-10-31 21:23 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-20 13:48 Recursive copies in Dired do not preserve directory permissions Sven Joachim
2007-10-21  7:25 ` Richard Stallman
2007-10-27 18:21   ` Sven Joachim
2007-10-28 13:51     ` Richard Stallman
2007-10-28 16:29       ` Sven Joachim
2007-10-31 17:01       ` Sven Joachim
2007-10-31 18:26         ` Juanma Barranquero
2007-10-31 20:11           ` Eli Zaretskii
2007-10-31 21:23             ` Jason Rumney

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).