From f2e00212d0c441e2859b082f835d2fa13a89f6cc Mon Sep 17 00:00:00 2001
From: Philipp Gesang <phg@phi-gamma.net>
Date: Fri, 20 Nov 2015 23:23:13 +0100
Subject: [PATCH] lfs: remove calls to umask(2) in mkdir()

Address issue #956

The ``mkdir`` function of the luafilesystem library sets a different
umask when creating directories. However, when the operation fails, the
original mask is never restored. As a consequence, Luatex will create
files with a 0666 mask afterwards (e. g. the PDF or a Latex ``.aux``
file)

The fix is to not tamper with the umask at all. Upstream decided that as
well:

    * upstream commit fd028d32.. (2009),
    * upstream discussion: http://thread.gmane.org/gmane.comp.lang.lua.kepler-project/3920/focus=3930

Signed-off-by: Philipp Gesang <phg@phi-gamma.net>
---
 source/texk/web2c/luatexdir/luafilesystem/src/lfs.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/source/texk/web2c/luatexdir/luafilesystem/src/lfs.c b/source/texk/web2c/luatexdir/luafilesystem/src/lfs.c
index a0b967d..2b1b06c 100644
--- a/source/texk/web2c/luatexdir/luafilesystem/src/lfs.c
+++ b/source/texk/web2c/luatexdir/luafilesystem/src/lfs.c
@@ -374,10 +374,8 @@ static int make_dir (lua_State *L) {
 	const char *path = luaL_checkstring (L, 1);
 	int fail;
 #ifdef _WIN32
-	int oldmask = umask (0);
 	fail = _mkdir (path);
 #else
-	mode_t oldmask = umask( (mode_t)0 );
 	fail =  mkdir (path, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP |
 	                     S_IWGRP | S_IXGRP | S_IROTH | S_IXOTH );
 #endif
@@ -386,7 +384,6 @@ static int make_dir (lua_State *L) {
         lua_pushfstring (L, "%s", strerror(errno));
 		return 2;
 	}
-	umask (oldmask);
 	lua_pushboolean (L, 1);
 	return 1;
 }
-- 
2.6.2

