unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#10401: move-file-to-trash trashes default file modes on error
@ 2011-12-29 21:13 Paul Eggert
  0 siblings, 0 replies; only message in thread
From: Paul Eggert @ 2011-12-29 21:13 UTC (permalink / raw)
  To: 10401

Tags: patch

move-file-to-trash invokes set-default-file-modes when creating
temporary directories, but if there's an error during directory
creation it doesn't restore the default file modes.  This can
cause later files to be created with incorrect permissions.
Here's a patch.

=== modified file 'lisp/ChangeLog'
--- lisp/ChangeLog	2011-12-29 13:12:18 +0000
+++ lisp/ChangeLog	2011-12-29 21:08:18 +0000
@@ -1,3 +1,7 @@
+2011-12-29  Paul Eggert  <eggert@cs.ucla.edu>
+
+	* files.el (move-file-to-trash): Preserve default file modes on error.
+
 2011-12-29  Michael Albinus  <michael.albinus@gmx.de>
 
 	* net/tramp-sh.el (tramp-find-shell): Set "remote-shell" property

=== modified file 'lisp/files.el'
--- lisp/files.el	2011-12-21 18:33:38 +0000
+++ lisp/files.el	2011-12-29 21:08:18 +0000
@@ -6457,12 +6457,14 @@
 
 	   ;; Ensure that the trash directory exists; otherwise, create it.
 	   (let ((saved-default-file-modes (default-file-modes)))
-	     (set-default-file-modes ?\700)
-	     (unless (file-exists-p trash-files-dir)
-	       (make-directory trash-files-dir t))
-	     (unless (file-exists-p trash-info-dir)
-	       (make-directory trash-info-dir t))
-	     (set-default-file-modes saved-default-file-modes))
+	     (unwind-protect
+		 (progn
+		   (set-default-file-modes #o700)
+		   (unless (file-exists-p trash-files-dir)
+		     (make-directory trash-files-dir t))
+		   (unless (file-exists-p trash-info-dir)
+		     (make-directory trash-info-dir t)))
+	       (set-default-file-modes saved-default-file-modes)))
 
 	   ;; Try to move to trash with .trashinfo undo information
 	   (save-excursion






^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-12-29 21:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-29 21:13 bug#10401: move-file-to-trash trashes default file modes on error Paul Eggert

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).