-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
Description
Component
mkdir
Description
uutils mkdir with -m MODE creates the directory first, then changes permissions in a second syscall. The directory exists briefly with umask-based permissions (typically 0755) instead of the requested mode.
GNU mkdir avoids this by temporarily setting umask to 0 around the mkdir(2) call, passing the final mode directly to the kernel. The directory is created atomically with correct permissions.
Test / Reproduction Steps
umask 022
strace -e umask,mkdir,chmod mkdir -m 0700 testdir 2>&1GNU mkdir shows:
umask(000) = 022
mkdir("testdir", 0700) = 0
umask(022) = 000
uutils mkdir shows:
mkdir("testdir", 0777) = 0
chmod("testdir", 0700) = 0