Repository navigation
chmod: report the real error for files below the -R operand - #15935
Conversation
|
The failing checks look unrelated to this change. Code Coverage and GNU (SELinux) failed during setup, before any tests ran. MinRustV failed on test_nohup_replaced_stdin_is_not_readable, which happens on ubuntu-26.04 runners; I opened #15937 for the underlying cat bug. Could someone re-run the setup failures? |
|
thanks for looking into this! |
|
a bunch of jobs are failing |
| @@ -843,13 +843,7 @@ impl Chmoder { | |||
| ); | |||
There was a problem hiding this comment.
the issue also covers this -v line: no old mode / symbolic form, and printed before the error
could you please fix it too, or not close #15934 with this PR? thanks
There was a problem hiding this comment.
Done, I fixed the -v line in this PR, it now matches GNU.
| fn test_chmod_recursive_reports_real_error_below_operand() { | ||
| use rustix::process::geteuid; | ||
|
|
||
| // A file found while recursing that the user does not own must be |
There was a problem hiding this comment.
could you please make this comment shorter? :)
|
The EPERM path now matches GNU 9.12, but the entry name is still lost when GNU: In Smaller gap in the same area: with |
4ba6487 to
ce166e9
Compare
d63ef55 to
0f6fde3
Compare
| self.report_failure(ChmodError::ChangingPermissions(file.into(), err).into()); | ||
| if self.verbose { | ||
| println!( | ||
| "failed to change mode of {} from {old_mode:04o} ({}) to {new_mode:04o} ({})", |
There was a problem hiding this comment.
could you please use translate!("chmod-verbose-failed-change") here? the key already exists in the ftl, just drop the "file" word there
There was a problem hiding this comment.
I tried translate! first, but it turned the mode into a number and the leading zero was dropped (0644 -> 644), so I used translate_text! instead.
33ac21a to
8210958
Compare
When chmod could not change the mode of a file found while recursing, every error except EROFS was reported as "cannot access ... Permission denied", even EPERM for a file the user doesn't own. Now the error from chmod is shown as is, the same way change_file() already does for the operand.
Show the old and new mode, drop the extra 'file' word for the operand, and print the line after the error, as GNU does.
8210958 to
0a7078f
Compare
|
Thanks for your PR |
With -R, if chmod couldn't change the mode of a file below the operand, every error except EROFS was shown as "cannot access ... Permission denied". For a file the user doesn't own, that's wrong: the real error is EPERM, and GNU prints "changing permissions of 'X': Operation not permitted".
safe_chmod_file() now reports the error from chmod as is, like change_file() does for the operand. The test uses -R -L with a symlink to /etc/passwd to get EPERM below the operand without root.
Closes #15934