aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2017-08-26 23:07:01 -0700
committerPaul Eggert2017-08-26 23:07:58 -0700
commit231bfd6818890c0c22181ad253f09c8f2399461d (patch)
tree0b6cdb3591ff182a2ddd31272bc5a3e455d440da
parent1be689fbc4df1ca9883f5bdeb5dd3ccc00eae3aa (diff)
downloademacs-231bfd6818890c0c22181ad253f09c8f2399461d.tar.gz
emacs-231bfd6818890c0c22181ad253f09c8f2399461d.zip
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.
-rw-r--r--lisp/emacs-lisp/autoload.el8
-rw-r--r--lisp/emacs-lisp/bytecomp.el5
2 files changed, 12 insertions, 1 deletions
diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el
index 4a9bd6d06b3..e811ee23fea 100644
--- a/lisp/emacs-lisp/autoload.el
+++ b/lisp/emacs-lisp/autoload.el
@@ -873,12 +873,18 @@ FILE's modification time."
873;; For parallel builds, to stop another process reading a half-written file. 873;; For parallel builds, to stop another process reading a half-written file.
874(defun autoload--save-buffer () 874(defun autoload--save-buffer ()
875 "Save current buffer to its file, atomically." 875 "Save current buffer to its file, atomically."
876 ;; Copied from byte-compile-file. 876 ;; Similar to byte-compile-file.
877 (let* ((version-control 'never) 877 (let* ((version-control 'never)
878 (tempfile (make-temp-file buffer-file-name)) 878 (tempfile (make-temp-file buffer-file-name))
879 (default-modes (default-file-modes))
880 (temp-modes (logand default-modes #o600))
881 (desired-modes (logand default-modes
882 (or (file-modes buffer-file-name) #o666)))
879 (kill-emacs-hook 883 (kill-emacs-hook
880 (cons (lambda () (ignore-errors (delete-file tempfile))) 884 (cons (lambda () (ignore-errors (delete-file tempfile)))
881 kill-emacs-hook))) 885 kill-emacs-hook)))
886 (unless (= temp-modes desired-modes)
887 (set-file-modes tempfile desired-modes))
882 (write-region (point-min) (point-max) tempfile nil 1) 888 (write-region (point-min) (point-max) tempfile nil 1)
883 (backup-buffer) 889 (backup-buffer)
884 (rename-file tempfile buffer-file-name t)) 890 (rename-file tempfile buffer-file-name t))
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index d769a155aa0..48bbd618712 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -1896,10 +1896,15 @@ The value is non-nil if there were no errors, nil if errors."
1896 ;; parallel bootstrap), it does not risk getting a 1896 ;; parallel bootstrap), it does not risk getting a
1897 ;; half-finished file. (Bug#4196) 1897 ;; half-finished file. (Bug#4196)
1898 (tempfile (make-temp-file target-file)) 1898 (tempfile (make-temp-file target-file))
1899 (default-modes (default-file-modes))
1900 (temp-modes (logand default-modes #o600))
1901 (desired-modes (logand default-modes #o666))
1899 (kill-emacs-hook 1902 (kill-emacs-hook
1900 (cons (lambda () (ignore-errors 1903 (cons (lambda () (ignore-errors
1901 (delete-file tempfile))) 1904 (delete-file tempfile)))
1902 kill-emacs-hook))) 1905 kill-emacs-hook)))
1906 (unless (= temp-modes desired-modes)
1907 (set-file-modes tempfile desired-modes))
1903 (write-region (point-min) (point-max) tempfile nil 1) 1908 (write-region (point-min) (point-max) tempfile nil 1)
1904 ;; This has the intentional side effect that any 1909 ;; This has the intentional side effect that any
1905 ;; hard-links to target-file continue to 1910 ;; hard-links to target-file continue to