Commit Graph
54 Commits
Author SHA1 Message Date
oech3andDaniel Hofstetter 65060418dd mv: Use rustc-hash 2026-02-19 14:44:42 +01:00
Yuri AstrakhanandGitHub 05204864d6 refactor: inline format! args in a few places (#10730)
* refactor: inline format! args in a few places

* in one spot remove redundant mem alloc

* run clippy fix with mixed
2026-02-07 10:05:44 +01:00
0xferrousandGitHub 08789257f6 chore: add test for setgid bit inheritance in mkdir -p (#10412) 2026-01-22 04:49:02 -08:00
Ruiyang WangandGitHub 037b9583bc mkdir: create directories atomically with correct permissions (#10036)
* mkdir: create directories atomically with correct permissions

Fix #10022: mkdir -m MODE was creating directories with umask-based
permissions first, then calling chmod afterward. This left a brief
window where the directory existed with wrong permissions.

Now we match GNU mkdir behavior by temporarily setting umask to 0
before the mkdir syscall, passing the exact requested mode to the
kernel, then restoring the original umask. The directory is created
atomically with the correct permissions.

Before (two syscalls, race condition):
  mkdir("dir", 0777)  -> created with 0755 (umask applied)
  chmod("dir", 0700)  -> fixed afterward

After (single syscall, atomic):
  umask(0)
  mkdir("dir", 0700)  -> created with exact mode
  umask(original)

Also added tests to verify -m MODE bypasses umask correctly.

* mkdir: add UmaskGuard for panic-safe umask restoration

Add RAII guard to ensure umask is restored even on panic. Encapsulate
unsafe umask calls in UmaskGuard::set() for a safe interface.

* mkdir: fix clippy and spelling warnings

- Add RAII to spell-checker ignore list
- Narrow chmod cfg to Linux only (only used for ACL bits)

* mkdir: fix unused import on non-Linux

FromIo is only used in chmod, which is now Linux-only.
2026-01-18 12:42:14 +01:00
Cả thế giới là RustandGitHub ee422bf55f Merge pull request #8947 from naoNao89/fix/mkdir-stack-overflow
mkdir: Fix stack overflow with deeply nested directories
2025-11-01 08:55:12 +01:00
3d6b0b2ea4 --version should just print the command name, not the path (#8921)
* --version should just print the command name, not the path

This will fix the parsing for old autoconf
Closes: #8880

* Update tests/by-util/test_mkdir.rs

Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>

---------

Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
2025-10-23 10:23:51 +02:00
Sylvestre Ledru 6e930966fb selinux: introduce get_getfattr_output to verify the output of getfatt 2025-07-31 17:45:34 +02:00
Daniel HofstetterandGitHub 8218f80bb0 Merge pull request #8367 from drinkcat/mkdir-osstr
Fix mkdir with non-unicode parameters
2025-07-22 17:15:19 +02:00
Nicolas Boichat 64fb7a7462 test_mkdir: Add a test for non-Unicode directory name
Similar to the first part of GNU test df/problematic-chars.
2025-07-22 17:25:59 +08:00
Julian Andres Klode abb5300068 install, mkdir: Handle dir/./ like dir/.
The dir/. special case was handled correctly, but dir/./ was not,
breaking gcc builds, which run:

../../../../src/libstdc++-v3/../install-sh -c -d debug/./

Bug-Ubuntu: https://bugs.launchpad.net/bugs/2117466
2025-07-22 09:44:15 +02:00
Sylvestre Ledru 832dd495bf selinux: adjust more error messages 2025-05-07 22:58:46 +02:00
Sylvestre Ledru c177362a51 set_selinux_security_context: also display the error from the crate
+ fix comments from review
2025-05-03 23:16:43 +02:00
Sylvestre Ledru 4a94a4e1dc spell: add getfattr in the ignore list 2025-04-24 21:54:29 +02:00
Sylvestre Ledru 81c02b7408 mkdir: add support of -Z
Should fix: gnu/tests/mkdir/selinux.sh
tests/mkdir/restorecon.sh
2025-04-10 18:26:41 -04:00
Sylvestre Ledru a0179ea239 uutests: adjust the tests to use them 2025-03-28 21:40:31 +01:00
Daniel Hofstetter df4dfea852 tests: replace run() with succeeds() or fails() 2025-03-09 16:53:56 +01:00
Sylvestre Ledru 18cb7dcf9e Use the new function fails_with_code
Done with
```
$ perl -0777 -i -pe 's/([ \t]+)\.fails\(\)[ \t]*\n[ \t]+\.no_stdout\(\)[ \t]*\n[ \t]+\.code_is\(([0-9]+)\);/\1.fails_with_code(\2)\n\1.no_stdout();/gs' *rs
$ sed -i -e "s|.fails()(.*).code_is(|.fails_with_code(|g" *rs
$ perl -0777 -i -pe 's/([ \t]+)\.fails\(\)[ \t]*\n[ \t]+\.code_is\(([0-9]+)\);/\1.fails_with_code(\2);/gs' *rs
$ perl -0777 -i -pe 's/([ \t]+)\.fails\(\)(.*?)[ \t]+\.code_is\(([0-9]+)\);/\1.fails_with_code(\3)\2;/gs' *rs
...
```
2025-03-01 17:26:20 +01:00
Daringcuteseal 8cecebc050 tests/mkdir: check for multiple --parent arguments 2024-10-31 05:10:31 +07:00
Andrew Liebenow 80b63931a4 mkdir: emit error when path is empty 2024-10-20 10:45:46 -05:00
Solomon VictorinoandSylvestre Ledru 6ad07a4fb3 mkdir: require argument 2024-10-18 08:30:18 +02:00
Anirban HalderandGitHub 7430856575 `mkdir: added acl` permissions inheritance for subdirectories (#6676)
Mostly for linux for now
2024-09-11 21:35:25 +02:00
Samuel TardieuandBen Wiederhake d627952fc8 mkdir: do not change mode of existing directories 2024-09-07 21:09:55 +02:00
n4n5 ab67947321 fix clippy tests 2024-06-30 16:27:08 +02:00
3c096ee6ac util: added umask manipulation (#6404)
Co-authored-by: Terts Diepraam <terts.diepraam@gmail.com>
2024-05-19 21:56:41 +02:00
Sylvestre Ledru bfca6bf70f Add license headers on all files 2023-08-21 10:49:27 +02:00