View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0000956 | luatex | luatex bug | public | 2015-11-20 22:29 | 2015-12-06 16:31 |
| Reporter | phg | Assigned To | luigi scarso | ||
| Priority | normal | Severity | minor | Reproducibility | have not tried |
| Status | closed | Resolution | fixed | ||
| Platform | POSIX | OS | Linux | ||
| Target Version | 0.86.0 | Fixed in Version | 0.86.0 | ||
| Summary | 0000956: lfs fails to restore umask after mkdir | ||||
| Description | Original report by Élie Roux: https://github.com/lualatex/luaotfload/issues/285 The bug is a bit elusive since it appears to affect only Linux, not Windows (running Cygwin + TL2015 binaries). Also, due to the different approach to directory handling, it usually not triggered in Context. | ||||
| Steps To Reproduce | This snippet: https://bitbucket.org/phg/lua-la-tex-tests/src/89bb50d8183d1cc3c67129d1be2d830b6dcd51c4/plain/pln-perms.tex 1. ``$ umask 077`` 2. ``$ luatex pln-perms.tex 3. ``stat -c %a pln-perms.pdf`` | ||||
| Additional Information | Appears to have been known for some time: * https://bugs.launchpad.net/ubuntu/+source/texlive-base/+bug/1333016 * http://tug.org/pipermail/luatex/2010-September/001998.html * http://www.ntg.nl/pipermail/dev-luatex/2012-September/004547.html | ||||
| Tags | No tags attached. | ||||
|
|
0001-lfs-restore-umask-in-mkdir.patch (1,359 bytes)
From b43941fed25f8411b70d27fc9d7c9c54f83516d8 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: restore umask 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 restore the umask earlier, before checking whether the
operation succeded.
---
source/texk/web2c/luatexdir/luafilesystem/src/lfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source/texk/web2c/luatexdir/luafilesystem/src/lfs.c b/source/texk/web2c/luatexdir/luafilesystem/src/lfs.c
index a0b967d..89015d2 100644
--- a/source/texk/web2c/luatexdir/luafilesystem/src/lfs.c
+++ b/source/texk/web2c/luatexdir/luafilesystem/src/lfs.c
@@ -381,12 +381,12 @@ static int make_dir (lua_State *L) {
fail = mkdir (path, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP |
S_IWGRP | S_IXGRP | S_IROTH | S_IXOTH );
#endif
+ umask (oldmask);
if (fail) {
lua_pushnil (L);
lua_pushfstring (L, "%s", strerror(errno));
return 2;
}
- umask (oldmask);
lua_pushboolean (L, 1);
return 1;
}
--
2.6.2
|
|
|
Patch attached. |
|
|
Btw., upstream lfs doesn’t tamper with the umask at all: https://github.com/keplerproject/luafilesystem/blob/master/src/lfs.c#L439 That’s probably even better. |
|
|
0001-lfs-remove-calls-to-umask-2-in-mkdir.patch (1,714 bytes)
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
|
|
|
Second patch following upstream. |
|
|
Thank you very much for the report, I will see it asap. |
|
|
It should be fixed in rev. 5557. |
|
|
Just seen it there, thanks! |
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2015-11-20 22:29 | phg | New Issue | |
| 2015-11-20 22:32 | phg | File Added: 0001-lfs-restore-umask-in-mkdir.patch | |
| 2015-11-20 22:32 | phg | Note Added: 0001549 | |
| 2015-11-20 22:45 | phg | Note Added: 0001550 | |
| 2015-11-20 23:06 | phg | File Added: 0001-lfs-remove-calls-to-umask-2-in-mkdir.patch | |
| 2015-11-20 23:07 | phg | Note Added: 0001551 | |
| 2015-11-20 23:21 | luigi scarso | Note Added: 0001552 | |
| 2015-11-23 07:41 | Hans Hagen | Assigned To | => luigi scarso |
| 2015-11-23 07:41 | Hans Hagen | Status | new => assigned |
| 2015-11-23 11:03 | Hans Hagen | Product Version | => 0.86.0 |
| 2015-11-23 11:03 | Hans Hagen | Product Version | 0.86.0 => |
| 2015-11-23 11:03 | Hans Hagen | Target Version | => 0.86.0 |
| 2015-11-23 14:50 | luigi scarso | Note Added: 0001556 | |
| 2015-11-24 19:37 | phg | Note Added: 0001557 | |
| 2015-12-06 16:31 | Hans Hagen | Status | assigned => closed |
| 2015-12-06 16:31 | Hans Hagen | Resolution | open => fixed |
| 2015-12-06 16:31 | Hans Hagen | Fixed in Version | => 0.86.0 |