aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2011-07-18 14:01:36 -0700
committerPaul Eggert2011-07-18 14:01:36 -0700
commit15e3a074a6ebdcefd828a1ba14a5a12ff9921034 (patch)
treec8bfe3d2fc0cede440a408876040910563de678e /src
parent41bed37d157e1a7bdc519bfc3668d59be5b05402 (diff)
downloademacs-15e3a074a6ebdcefd828a1ba14a5a12ff9921034.tar.gz
emacs-15e3a074a6ebdcefd828a1ba14a5a12ff9921034.zip
* fileio.c (Fcopy_file) [!MSDOS]: Tighten created file's mask.
This fixes some race conditions on the permissions of any newly created file.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog4
-rw-r--r--src/fileio.c17
2 files changed, 17 insertions, 4 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index ca42b696f9c..484a4420363 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,9 @@
12011-07-18 Paul Eggert <eggert@cs.ucla.edu> 12011-07-18 Paul Eggert <eggert@cs.ucla.edu>
2 2
3 * fileio.c (Fcopy_file) [!MSDOS]: Tighten created file's mask.
4 This fixes some race conditions on the permissions of any newly
5 created file.
6
3 * alloc.c (valid_pointer_p): Use pipe, not open. 7 * alloc.c (valid_pointer_p): Use pipe, not open.
4 This fixes some permissions issues when debugging. 8 This fixes some permissions issues when debugging.
5 9
diff --git a/src/fileio.c b/src/fileio.c
index fb2c081ae5c..3e1aa54462f 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -1937,10 +1937,19 @@ on the system, we copy the SELinux context of FILE to NEWNAME. */)
1937 | (NILP (ok_if_already_exists) ? O_EXCL : 0), 1937 | (NILP (ok_if_already_exists) ? O_EXCL : 0),
1938 S_IREAD | S_IWRITE); 1938 S_IREAD | S_IWRITE);
1939#else /* not MSDOS */ 1939#else /* not MSDOS */
1940 ofd = emacs_open (SSDATA (encoded_newname), 1940 {
1941 O_WRONLY | O_TRUNC | O_CREAT 1941 int new_mask = 0666;
1942 | (NILP (ok_if_already_exists) ? O_EXCL : 0), 1942 if (input_file_statable_p)
1943 0666); 1943 {
1944 if (!NILP (preserve_uid_gid))
1945 new_mask = 0600;
1946 new_mask &= st.st_mode;
1947 }
1948 ofd = emacs_open (SSDATA (encoded_newname),
1949 (O_WRONLY | O_TRUNC | O_CREAT
1950 | (NILP (ok_if_already_exists) ? O_EXCL : 0)),
1951 new_mask);
1952 }
1944#endif /* not MSDOS */ 1953#endif /* not MSDOS */
1945 if (ofd < 0) 1954 if (ofd < 0)
1946 report_file_error ("Opening output file", Fcons (newname, Qnil)); 1955 report_file_error ("Opening output file", Fcons (newname, Qnil));