aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGerd Moellmann2001-04-10 12:15:25 +0000
committerGerd Moellmann2001-04-10 12:15:25 +0000
commit302f0b29125675990ffd5825f6e6b9f9912cde84 (patch)
treea8814adee583cb0a6a5db043cdb41ec8c430b189 /src
parentdbb70029168d42bdb3b2fd5ba0f232469074e245 (diff)
downloademacs-302f0b29125675990ffd5825f6e6b9f9912cde84.tar.gz
emacs-302f0b29125675990ffd5825f6e6b9f9912cde84.zip
(sys_open): Try to open file without _O_CREAT first, to be
able to write to hidden and system files. Make file handles non-inheritable.
Diffstat (limited to 'src')
-rw-r--r--src/w32.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/w32.c b/src/w32.c
index 1fdb47383cb..f5ea84a6111 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -1,5 +1,5 @@
1/* Utility and Unix shadow routines for GNU Emacs on the Microsoft W32 API. 1/* Utility and Unix shadow routines for GNU Emacs on the Microsoft W32 API.
2 Copyright (C) 1994, 1995 Free Software Foundation, Inc. 2 Copyright (C) 1994, 1995, 2000, 2001 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
@@ -1819,8 +1819,14 @@ sys_mktemp (char * template)
1819int 1819int
1820sys_open (const char * path, int oflag, int mode) 1820sys_open (const char * path, int oflag, int mode)
1821{ 1821{
1822 /* Force all file handles to be non-inheritable. */ 1822 const char* mpath = map_w32_filename (path, NULL);
1823 return _open (map_w32_filename (path, NULL), oflag | _O_NOINHERIT, mode); 1823 /* Try to open file without _O_CREAT, to be able to write to hidden
1824 and system files. Force all file handles to be
1825 non-inheritable. */
1826 int res = _open (mpath, (oflag & ~_O_CREAT) | _O_NOINHERIT, mode);
1827 if (res >= 0)
1828 return res;
1829 return _open (mpath, oflag | _O_NOINHERIT, mode);
1824} 1830}
1825 1831
1826int 1832int