Subject: Re: 26.0.50; byte-compiled files have mode 0600
From: Paul Eggert <[email-masked]>
To: Sven Joachim <[email-masked]>
Cc: [email-masked]
Date: Sat, 26 Aug 2017 23:10:55 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

Thanks for reporting that bug. It was indeed an unintended consequence of my 
earlier change. I installed the attached patch, which should fix it.
From 7207e4a3d533d959eebbb947235f741b1586722b Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
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