From bfb5180627fb1ac88780d775fb975f84459cb752 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 2 Jan 2017 07:22:15 -0500 Subject: vim-patch:7.4.1889 Problem: When umask is set to 0177 Vim can't create temp files. (Lcd) Solution: Also correct umask when using mkdtemp(). https://github.com/vim/vim/commit/35d88f4e2ff5dcd9904f04612d5febede996137c --- src/nvim/fileio.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/nvim/fileio.c') diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 529b48adbd..1c96481389 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -51,6 +51,7 @@ #include "nvim/window.h" #include "nvim/shada.h" #include "nvim/os/os.h" +#include "nvim/os/os_defs.h" #include "nvim/os/time.h" #include "nvim/os/input.h" @@ -5224,6 +5225,10 @@ static void vim_maketempdir(void) // Try the entries in `TEMP_DIR_NAMES` to create the temp directory. char_u template[TEMP_FILE_PATH_MAXLEN]; char_u path[TEMP_FILE_PATH_MAXLEN]; + + // Make sure the umask doesn't remove the executable bit. + // "repl" has been reported to use "0177". + mode_t umask_save = umask(0077); for (size_t i = 0; i < ARRAY_SIZE(temp_dirs); i++) { // Expand environment variables, leave room for "/nvimXXXXXX/999999999" expand_env((char_u *)temp_dirs[i], template, TEMP_FILE_PATH_MAXLEN - 22); @@ -5247,6 +5252,7 @@ static void vim_maketempdir(void) os_rmdir((char *)path); } } + (void)umask(umask_save); } /// Delete "name" and everything in it, recursively. -- cgit