Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork1.5k
mknod: set cli specified file mode even when it's 0o666#8343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
setharnold commentedJul 16, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Forgive me if I've missed a conversation or discussion elsewhere. This feels more complex than the implementation that I expected:
What motivates the more complex implementation? Thanks |
GNU testsuite comparison:
|
TheJJ commentedJul 17, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Good point, I don't know :) but I tried to change the currently implemented behavior as little as possible. The umask restoring is probably done so the functions are usable inside single executables? My updated implementation now does
just like the GNU coreutils manpage says:
|
042b5d7
toa3c0e53
Comparelibc's mknod function applies the process' umask in the usual way:the permissions of the created node are `mode & ~umask`.the umask of uu-mknod is currently only set to 0 (= no mask)when the supplied mode is not 0o666:```rustlet set_umask_0 = config.mode & MODE_RW_UGO != MODE_RW_UGO;```because `MODE_RW_UGO == 0o666` is also the default `--mode` argument value.but when `--mode 0666` is given explicitly, the permissions should be setexactly to the requested bits, and the umask should not be applied.this patch fixes the issue by tracking if a custom mode was supplied by argument.interestingly, GNU coreutils issue a call to `fchmodat2` after `mknod` was called,even though they also set the umask to 0 if a custom mode was specified via `--mode`.this patch doesn't add that, but it may be necessary for other cases in the future.fixesuutils#8342
Could you please add a test to make sure we don't regress? |
GNU testsuite comparison:
|
done, it requires |
GNU testsuite comparison:
|
Uh oh!
There was an error while loading.Please reload this page.
libc's mknod function applies the process' umask in the usual way: the permissions of the created node are
mode & ~umask
.the umask of uu-mknod is currently only set to 0 (= no mask) when the supplied mode is not 0o666:
because
MODE_RW_UGO == 0o666
is also the default--mode
argument value.but when
--mode 0666
is given explicitly, the permissions should be set exactly to the requested bits, and the umask should not be applied.this patch fixes the issue by tracking if a custom mode was supplied by argument.
interestingly, GNU coreutils issue a call to
fchmodat2
aftermknod
was called, even though they also set the umask to 0 if a custom mode was specified via--mode
. this patch doesn't add that, but it may be necessary for other cases in the future.fixes#8342
this does now result in: