aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2012-01-07 11:58:55 -0800
committerPaul Eggert2012-01-07 11:58:55 -0800
commitcd0cf8aa185960bfa65be999aea2d8f061d0b055 (patch)
tree3aa1c1ba64b703a59c205c31aa67a93e4acf04ce
parent9a0115abd18f219f234d6dd460cf7f5ed3c0332f (diff)
downloademacs-cd0cf8aa185960bfa65be999aea2d8f061d0b055.tar.gz
emacs-cd0cf8aa185960bfa65be999aea2d8f061d0b055.zip
Undo patch for bug#10403; still being reviewed.
-rw-r--r--lisp/ChangeLog3
-rw-r--r--lisp/epg.el7
2 files changed, 3 insertions, 7 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 64416288c6c..b4bb7352fcb 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,8 +1,5 @@
12012-01-07 Paul Eggert <eggert@cs.ucla.edu> 12012-01-07 Paul Eggert <eggert@cs.ucla.edu>
2 2
3 * epg.el (epg--make-temp-file): Avoid permission race conditions
4 when creating temporary directories and files on older Emacs.
5
6 * files.el (move-file-to-trash): Preserve default file modes on error. 3 * files.el (move-file-to-trash): Preserve default file modes on error.
7 (Bug#10401) 4 (Bug#10401)
8 5
diff --git a/lisp/epg.el b/lisp/epg.el
index 4da06cd9933..3505e183c1f 100644
--- a/lisp/epg.el
+++ b/lisp/epg.el
@@ -1951,16 +1951,14 @@ The returned file name (created by appending some random characters at the end
1951of PREFIX, and expanding against `temporary-file-directory' if necessary), 1951of PREFIX, and expanding against `temporary-file-directory' if necessary),
1952is guaranteed to point to a newly created empty file. 1952is guaranteed to point to a newly created empty file.
1953You can then use `write-region' to write new data into the file." 1953You can then use `write-region' to write new data into the file."
1954 (let (tempdir tempfile orig-modes) 1954 (let (tempdir tempfile)
1955 (setq prefix (expand-file-name prefix 1955 (setq prefix (expand-file-name prefix
1956 (if (featurep 'xemacs) 1956 (if (featurep 'xemacs)
1957 (temp-directory) 1957 (temp-directory)
1958 temporary-file-directory))) 1958 temporary-file-directory)))
1959 (setq orig-modes (default-file-modes))
1960 (unwind-protect 1959 (unwind-protect
1961 (let (file) 1960 (let (file)
1962 ;; First, create a temporary directory. 1961 ;; First, create a temporary directory.
1963 (set-default-file-modes #o700)
1964 (while (condition-case () 1962 (while (condition-case ()
1965 (progn 1963 (progn
1966 (setq tempdir (make-temp-name 1964 (setq tempdir (make-temp-name
@@ -1971,12 +1969,14 @@ You can then use `write-region' to write new data into the file."
1971 (make-directory tempdir)) 1969 (make-directory tempdir))
1972 ;; let's try again. 1970 ;; let's try again.
1973 (file-already-exists t))) 1971 (file-already-exists t)))
1972 (set-file-modes tempdir 448)
1974 ;; Second, create a temporary file in the tempdir. 1973 ;; Second, create a temporary file in the tempdir.
1975 ;; There *is* a race condition between `make-temp-name' 1974 ;; There *is* a race condition between `make-temp-name'
1976 ;; and `write-region', but we don't care it since we are 1975 ;; and `write-region', but we don't care it since we are
1977 ;; in a private directory now. 1976 ;; in a private directory now.
1978 (setq tempfile (make-temp-name (concat tempdir "/EMU"))) 1977 (setq tempfile (make-temp-name (concat tempdir "/EMU")))
1979 (write-region "" nil tempfile nil 'silent) 1978 (write-region "" nil tempfile nil 'silent)
1979 (set-file-modes tempfile 384)
1980 ;; Finally, make a hard-link from the tempfile. 1980 ;; Finally, make a hard-link from the tempfile.
1981 (while (condition-case () 1981 (while (condition-case ()
1982 (progn 1982 (progn
@@ -1986,7 +1986,6 @@ You can then use `write-region' to write new data into the file."
1986 ;; let's try again. 1986 ;; let's try again.
1987 (file-already-exists t))) 1987 (file-already-exists t)))
1988 file) 1988 file)
1989 (set-default-file-modes orig-modes)
1990 ;; Cleanup the tempfile. 1989 ;; Cleanup the tempfile.
1991 (and tempfile 1990 (and tempfile
1992 (file-exists-p tempfile) 1991 (file-exists-p tempfile)