GNU bug report logs - #10401
move-file-to-trash trashes default file modes on error

Previous Next

Package: emacs;

Reported by: Paul Eggert <eggert <at> cs.ucla.edu>

Date: Thu, 29 Dec 2011 21:17:01 UTC

Severity: normal

Tags: patch

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 10401 in the body.
You can then email your comments to 10401 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#10401; Package emacs. (Thu, 29 Dec 2011 21:17:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Paul Eggert <eggert <at> cs.ucla.edu>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 29 Dec 2011 21:17:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: bug-gnu-emacs <at> gnu.org
Subject: move-file-to-trash trashes default file modes on error
Date: Thu, 29 Dec 2011 13:13:42 -0800
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 <at> cs.ucla.edu>
+
+	* files.el (move-file-to-trash): Preserve default file modes on error.
+
 2011-12-29  Michael Albinus  <michael.albinus <at> 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





Reply sent to Paul Eggert <eggert <at> cs.ucla.edu>:
You have taken responsibility. (Sat, 07 Jan 2012 20:07:02 GMT) Full text and rfc822 format available.

Notification sent to Paul Eggert <eggert <at> cs.ucla.edu>:
bug acknowledged by developer. (Sat, 07 Jan 2012 20:07:02 GMT) Full text and rfc822 format available.

Message #10 received at 10401-done <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: 10400-done <at> debbugs.gnu.org, 10401-done <at> debbugs.gnu.org
Subject: patch installed
Date: Sat, 07 Jan 2012 12:06:09 -0800
I installed this patch into the Emacs trunk as part of
bzr 106821 and am marking the bug as done.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 05 Feb 2012 12:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 93 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.