diff options
Diffstat (limited to 'src/fileio.c')
| -rw-r--r-- | src/fileio.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/fileio.c b/src/fileio.c index 3306085491e..9e940c9a324 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* File IO for GNU Emacs. | 1 | /* File IO for GNU Emacs. |
| 2 | 2 | ||
| 3 | Copyright (C) 1985-1988, 1993-2011 Free Software Foundation, Inc. | 3 | Copyright (C) 1985-1988, 1993-2012 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | This file is part of GNU Emacs. | 5 | This file is part of GNU Emacs. |
| 6 | 6 | ||
| @@ -90,6 +90,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 90 | /* Nonzero during writing of auto-save files */ | 90 | /* Nonzero during writing of auto-save files */ |
| 91 | static int auto_saving; | 91 | static int auto_saving; |
| 92 | 92 | ||
| 93 | /* Nonzero umask during creation of auto-save directories */ | ||
| 94 | static int auto_saving_dir_umask; | ||
| 95 | |||
| 93 | /* Set by auto_save_1 to mode of original file so Fwrite_region will create | 96 | /* Set by auto_save_1 to mode of original file so Fwrite_region will create |
| 94 | a new file with the same mode as the original */ | 97 | a new file with the same mode as the original */ |
| 95 | static int auto_save_mode_bits; | 98 | static int auto_save_mode_bits; |
| @@ -2062,7 +2065,7 @@ DEFUN ("make-directory-internal", Fmake_directory_internal, | |||
| 2062 | #ifdef WINDOWSNT | 2065 | #ifdef WINDOWSNT |
| 2063 | if (mkdir (dir) != 0) | 2066 | if (mkdir (dir) != 0) |
| 2064 | #else | 2067 | #else |
| 2065 | if (mkdir (dir, 0777) != 0) | 2068 | if (mkdir (dir, 0777 & ~auto_saving_dir_umask) != 0) |
| 2066 | #endif | 2069 | #endif |
| 2067 | report_file_error ("Creating directory", list1 (directory)); | 2070 | report_file_error ("Creating directory", list1 (directory)); |
| 2068 | 2071 | ||
| @@ -5205,16 +5208,18 @@ do_auto_save_unwind_1 (Lisp_Object value) /* used as unwind-protect function */ | |||
| 5205 | static Lisp_Object | 5208 | static Lisp_Object |
| 5206 | do_auto_save_make_dir (Lisp_Object dir) | 5209 | do_auto_save_make_dir (Lisp_Object dir) |
| 5207 | { | 5210 | { |
| 5208 | Lisp_Object mode; | 5211 | Lisp_Object result; |
| 5209 | 5212 | ||
| 5210 | call2 (Qmake_directory, dir, Qt); | 5213 | auto_saving_dir_umask = 077; |
| 5211 | XSETFASTINT (mode, 0700); | 5214 | result = call2 (Qmake_directory, dir, Qt); |
| 5212 | return Fset_file_modes (dir, mode); | 5215 | auto_saving_dir_umask = 0; |
| 5216 | return result; | ||
| 5213 | } | 5217 | } |
| 5214 | 5218 | ||
| 5215 | static Lisp_Object | 5219 | static Lisp_Object |
| 5216 | do_auto_save_eh (Lisp_Object ignore) | 5220 | do_auto_save_eh (Lisp_Object ignore) |
| 5217 | { | 5221 | { |
| 5222 | auto_saving_dir_umask = 0; | ||
| 5218 | return Qnil; | 5223 | return Qnil; |
| 5219 | } | 5224 | } |
| 5220 | 5225 | ||
| @@ -5282,7 +5287,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */) | |||
| 5282 | dir = Ffile_name_directory (listfile); | 5287 | dir = Ffile_name_directory (listfile); |
| 5283 | if (NILP (Ffile_directory_p (dir))) | 5288 | if (NILP (Ffile_directory_p (dir))) |
| 5284 | internal_condition_case_1 (do_auto_save_make_dir, | 5289 | internal_condition_case_1 (do_auto_save_make_dir, |
| 5285 | dir, Fcons (Fcons (Qfile_error, Qnil), Qnil), | 5290 | dir, Qt, |
| 5286 | do_auto_save_eh); | 5291 | do_auto_save_eh); |
| 5287 | UNGCPRO; | 5292 | UNGCPRO; |
| 5288 | } | 5293 | } |