all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Sven Joachim <svenjoac@gmx.de>
Cc: 28244-done@debbugs.gnu.org
Subject: bug#28244: 26.0.50; byte-compiled files have mode 0600
Date: Sat, 26 Aug 2017 23:10:55 -0700	[thread overview]
Message-ID: <8a1a9773-83a9-cb58-f808-08133fec6217@cs.ucla.edu> (raw)
In-Reply-To: <87r2vyytng.fsf@turtle.gmx.de>

[-- Attachment #1: Type: text/plain, Size: 147 bytes --]

Thanks for reporting that bug. It was indeed an unintended consequence of my 
earlier change. I installed the attached patch, which should fix it.

[-- Attachment #2: 0001-Fix-over-protection-of-byte-compiled-files.patch --]
[-- Type: text/x-patch, Size: 2672 bytes --]

From 7207e4a3d533d959eebbb947235f741b1586722b Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Sat, 26 Aug 2017 23:07:01 -0700
Subject: [PATCH] Fix over-protection of byte-compiled files

Problem reported by Sven Joachim (Bug#28244).
Also, fix similar problem for autoload files.
* lisp/emacs-lisp/autoload.el (autoload--save-buffer):
Set temp file modes to the buffer-file-name file modes (or 666
if not available) as adjusted by umask.
* lisp/emacs-lisp/bytecomp.el (byte-compile-file):
Set temp file modes to 666 as adjusted by umask.
---
 lisp/emacs-lisp/autoload.el | 8 +++++++-
 lisp/emacs-lisp/bytecomp.el | 5 +++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el
index 4a9bd6d..e811ee2 100644
--- a/lisp/emacs-lisp/autoload.el
+++ b/lisp/emacs-lisp/autoload.el
@@ -873,12 +873,18 @@ autoload-generate-file-autoloads
 ;; For parallel builds, to stop another process reading a half-written file.
 (defun autoload--save-buffer ()
   "Save current buffer to its file, atomically."
-  ;; Copied from byte-compile-file.
+  ;; Similar to byte-compile-file.
   (let* ((version-control 'never)
          (tempfile (make-temp-file buffer-file-name))
+	 (default-modes (default-file-modes))
+	 (temp-modes (logand default-modes #o600))
+	 (desired-modes (logand default-modes
+				(or (file-modes buffer-file-name) #o666)))
          (kill-emacs-hook
           (cons (lambda () (ignore-errors (delete-file tempfile)))
                 kill-emacs-hook)))
+    (unless (= temp-modes desired-modes)
+      (set-file-modes tempfile desired-modes))
     (write-region (point-min) (point-max) tempfile nil 1)
     (backup-buffer)
     (rename-file tempfile buffer-file-name t))
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index d769a15..48bbd61 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -1896,10 +1896,15 @@ byte-compile-file
 		       ;; parallel bootstrap), it does not risk getting a
 		       ;; half-finished file.  (Bug#4196)
 		       (tempfile (make-temp-file target-file))
+		       (default-modes (default-file-modes))
+		       (temp-modes (logand default-modes #o600))
+		       (desired-modes (logand default-modes #o666))
 		       (kill-emacs-hook
 			(cons (lambda () (ignore-errors
 					   (delete-file tempfile)))
 			      kill-emacs-hook)))
+		  (unless (= temp-modes desired-modes)
+		    (set-file-modes tempfile desired-modes))
 		  (write-region (point-min) (point-max) tempfile nil 1)
 		  ;; This has the intentional side effect that any
 		  ;; hard-links to target-file continue to
-- 
2.7.4


      reply	other threads:[~2017-08-27  6:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-26 20:13 bug#28244: 26.0.50; byte-compiled files have mode 0600 Sven Joachim
2017-08-27  6:10 ` Paul Eggert [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8a1a9773-83a9-cb58-f808-08133fec6217@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=28244-done@debbugs.gnu.org \
    --cc=svenjoac@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.