Conversation
|
Also another note about why i use chmod after the creation of the directory to change the permission. I tried first creating the right mode with setgid bit set for line 283 |
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
86e218d to
7c235a4
Compare
|
sorry but what is the issue being fixed here ? |
|
On Linux using mkdir creates a directory which inherits the setgid bitflag from its parent folder. In the linked comment of this issue it was discussed that this behaviour doesn't work in macOS/bsd. When trying to reproduce it with gnu utils mkdir on macOS it doesn't seem to inherit the setgid bit though. |
|
As this comment notices it's done on a kernel level and the question is if we want the same behaviour if uutils mkdir between Linux and macOS that setgid is always beeing inherited or if we want uutils mkdir to behave like gnu uutils on macOS which does in fact not inherit setgid |
| if let Some(parent) = path.parent() { | ||
| if let Ok(parent_metadata) = parent.metadata() { | ||
| if let Ok(paths_metadata) = path.metadata() { | ||
| if (parent_metadata.mode() & 0o2000) != (paths_metadata.mode() & 0o2000) { |
There was a problem hiding this comment.
condition checks if bits are different, should check if parent has setgid AND child doesn't: `(parent_metadata.mode() & 0o2000) != 0 && (paths_metadata.mode() & 0o2000) == 0
no ?
| #[cfg(all(unix, not(target_os = "linux")))] | ||
| fn inherit_setgid_bit(path: &Path) -> UResult<()> { | ||
| if let Some(parent) = path.parent() { | ||
| if let Ok(parent_metadata) = parent.metadata() { |
There was a problem hiding this comment.
what happens in case of error on metadata() ?
| if (parent_metadata.mode() & 0o2000) != (paths_metadata.mode() & 0o2000) { | ||
| chmod( | ||
| path, | ||
| paths_metadata.mode() | parent_metadata.mode() & 0o2000, |
There was a problem hiding this comment.
should be paths_metadata.mode() | 0o2000 since we already verified parent has the bit, no?
|
GNU testsuite comparison: |
Fix: #10428
Note: when testing on my macos system with GNU utils i saw that mkdir does not inherit the setgid flag. So this change would not make macos uutils act like macos GNU utils but rather macos uutils like linux GNU uutils.
I leave it for a maintainer to decide which way is more desired.