Commit 15e3a074 authored by Paul Eggert's avatar Paul Eggert
Browse files

* fileio.c (Fcopy_file) [!MSDOS]: Tighten created file's mask.

This fixes some race conditions on the permissions of any newly
created file.
parent 41bed37d
2011-07-18 Paul Eggert <eggert@cs.ucla.edu> 2011-07-18 Paul Eggert <eggert@cs.ucla.edu>
* fileio.c (Fcopy_file) [!MSDOS]: Tighten created file's mask.
This fixes some race conditions on the permissions of any newly
created file.
* alloc.c (valid_pointer_p): Use pipe, not open. * alloc.c (valid_pointer_p): Use pipe, not open.
This fixes some permissions issues when debugging. This fixes some permissions issues when debugging.
......
...@@ -1937,10 +1937,19 @@ on the system, we copy the SELinux context of FILE to NEWNAME. */) ...@@ -1937,10 +1937,19 @@ on the system, we copy the SELinux context of FILE to NEWNAME. */)
| (NILP (ok_if_already_exists) ? O_EXCL : 0), | (NILP (ok_if_already_exists) ? O_EXCL : 0),
S_IREAD | S_IWRITE); S_IREAD | S_IWRITE);
#else /* not MSDOS */ #else /* not MSDOS */
{
int new_mask = 0666;
if (input_file_statable_p)
{
if (!NILP (preserve_uid_gid))
new_mask = 0600;
new_mask &= st.st_mode;
}
ofd = emacs_open (SSDATA (encoded_newname), ofd = emacs_open (SSDATA (encoded_newname),
O_WRONLY | O_TRUNC | O_CREAT (O_WRONLY | O_TRUNC | O_CREAT
| (NILP (ok_if_already_exists) ? O_EXCL : 0), | (NILP (ok_if_already_exists) ? O_EXCL : 0)),
0666); new_mask);
}
#endif /* not MSDOS */ #endif /* not MSDOS */
if (ofd < 0) if (ofd < 0)
report_file_error ("Opening output file", Fcons (newname, Qnil)); report_file_error ("Opening output file", Fcons (newname, Qnil));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment