Artifacts Associated With Ticket cd609219f5
Ticket change [ebe5ee0e0d] (rid 212011) by christian.nassau on 2023-04-05 18:01:59:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/html"
- comment initialized to:
In <tt>unix/tclUnixFCmd.c</tt> the following code is used to determine the process's current "umask": <blockquote> <pre> mode = umask(0); umask(mode) </pre> </blockquote> In the (usually miniscule) period between the two calls, the umask is temporarily set to 0 which results in <i>elevated permissions</i> for newly created files at that point. As noted in <a href="https://man7.org/linux/man-pages/man2/umask.2.html">the umask man page</a> for modern Linux systems with a /proc filesystem there is a better way to determine the umask. It might make sense to use this when available.
- foundin initialized to: "8.6.12"
- is_private initialized to: "0"
- login: "christian.nassau"
- priority initialized to: "5 Medium"
- private_contact initialized to: "3b279cda57135cd36d2c32c66396637342913651"
- resolution initialized to: "None"
- severity initialized to: "Important"
- status initialized to: "Open"
- submitter initialized to: "christian.nassau"
- subsystem initialized to: "16. Commands A-H"
- title initialized to: "directory creation temporarily changes the umask"
- type initialized to: "Bug"
Ticket change [a458a28f2b] (rid 212029) by christian.nassau on 2023-04-06 10:43:17:
- icomment:
Note that in a multi-threaded application this code can be highly problematic: if two threads simultaneously try to create a directory, both might be stepping through these lines at the same time. If it happens in this sequence the processes' umask will end up permanently set to "0": <blockquote> <pre> thread 1 | thread 2 mode = umask(0); | | mode = umask(0); umask(mode) | | umask(mode) </pre> </blockquote> If a multithreaded process spawns a pool of threads which all try to create the same directory on startup that might not be an unlikely coincidence. - login: "christian.nassau"
- mimetype: "text/html"
- icomment:
Ticket change [e5372f042e] (rid 258490) by serhiy.storchaka on 2026-10-17 09:00:11:
- foundin changed to: "8.6.18, 9.0.5, 9.1.0"
- icomment:
Confirmed, and worse than temporary: with several threads running <nowiki>[file mkdir]</nowiki>, the process umask ends up permanently at 0, so later files are created world-writable (main, 9.0, 8.6). Proposed fix in branch [/timeline?r=mkdir-no-umask-call|mkdir-no-umask-call], with [623585ffff]: call mkdir(path, 0777) and let the kernel apply the umask; umask() is not called any more. The permissions of new directories do not change. Test unixFCmd-5.2. The old code also meant to always add u+rwx, but that never worked, because mkdir() applies the umask once more (umask 0700 gives 077). It could be done with chmod() after mkdir(), but that would change the permissions of new directories under such umasks, and it is not documented, so the branch does not do it.
- login: "serhiy.storchaka"
- mimetype: "text/x-fossil-wiki"
Ticket change [afde45d02e] (rid 263412) by jan.nijtmans on 2026-11-27 15:24:17:
- assignee changed to: "jan.nijtmans"
- icomment: "Merged to [ 14f40fe36f|trunk]"
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
- resolution changed to: "Fixed"
- status changed to: "Pending"