]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix bug #16299 with assertion violation in set-default-file-modes on Windows.
authorEli Zaretskii <eliz@gnu.org>
Mon, 30 Dec 2013 17:51:28 +0000 (19:51 +0200)
committerEli Zaretskii <eliz@gnu.org>
Mon, 30 Dec 2013 17:51:28 +0000 (19:51 +0200)
 src/w32.c (sys_umask): New function.

 nt/inc/ms-w32.h (umask) [emacs]: Redirect to sys_umask.

nt/ChangeLog
nt/inc/ms-w32.h
src/ChangeLog
src/w32.c

index feaf2cd783391ec9b0cf820c649b7ffff76a0da6..8eb601d4e3ec8336d115242212871d2a18f73f6c 100644 (file)
@@ -1,3 +1,7 @@
+2013-12-30  Eli Zaretskii  <eliz@gnu.org>
+
+       * inc/ms-w32.h (umask) [emacs]: Redirect to sys_umask.  (Bug#16299)
+
 2013-12-23  Eli Zaretskii  <eliz@gnu.org>
 
        * README.W32:
index bcccebc13a0ebfff90d88b423f7dcb69b2faba33..735f9a65320d5ae758419cbd4c0a848dad4c07e1 100644 (file)
@@ -235,6 +235,9 @@ extern struct tm * sys_localtime (const time_t *);
 extern int sys_unlink (const char *);
 #undef write
 #define write   sys_write
+#undef umask
+#define umask   sys_umask
+extern int sys_umask (int);
 
 /* Subprocess calls that are emulated.  */
 #define spawnve sys_spawnve
@@ -276,7 +279,6 @@ typedef int pid_t;
 #define lseek     _lseek
 #define popen     _popen
 #define pclose    _pclose
-#define umask    _umask
 #define strdup    _strdup
 #define strupr    _strupr
 #define strnicmp  _strnicmp
index fd2b6db116536dd719a9ebb7c416c3e023ab0fba..18d00ef7640af38ceebc5f05e82d7f1cbc744143 100644 (file)
@@ -1,3 +1,7 @@
+2013-12-30  Eli Zaretskii  <eliz@gnu.org>
+
+       * w32.c (sys_umask): New function.  (Bug#16299)
+
 2013-12-30  Martin Rudalics  <rudalics@gmx.at>
 
        * dispnew.c (change_frame_size_1): Take old width of root window
index dde74bfcdd988857e063e751dc7bdbb8f404b572..3fdb673b63f3d4338f5ee377c6bd953d5644cb98 100644 (file)
--- a/src/w32.c
+++ b/src/w32.c
@@ -5265,6 +5265,35 @@ utime (const char *name, struct utimbuf *times)
   return 0;
 }
 
+/* Emacs expects us to support the traditional octal form of the mode
+   bits, which is not what msvcrt.dll wants.  */
+
+#define WRITE_USER 00200
+
+int
+sys_umask (int mode)
+{
+  static int current_mask;
+  int retval, arg = 0;
+
+  /* The only bit we really support is the write bit.  Files are
+     always readable on MS-Windows, and the execute bit does not exist
+     at all.  */
+  /* FIXME: if the GROUP and OTHER bits are reset, we should use ACLs
+     to prevent access by other users on NTFS.  */
+  if ((mode & WRITE_USER) != 0)
+    arg |= S_IWRITE;
+
+  retval = _umask (arg);
+  /* Merge into the return value the bits they've set the last time,
+     which msvcrt.dll ignores and never returns.  Emacs insists on its
+     notion of mask being identical to what we return.  */
+  retval |= (current_mask & ~WRITE_USER);
+  current_mask = mode;
+
+  return retval;
+}
+
 \f
 /* Symlink-related functions.  */
 #ifndef SYMBOLIC_LINK_FLAG_DIRECTORY