Repository navigation
userdel: say when -r finds no mail spool or home - #396
pierre-warnier wants to merge 3 commits into
Conversation
| /// `userdel -r` says so when the mail spool or the home is not there, mail | ||
| /// spool first, on standard error and with exit 0, as Ubuntu 26.04's does. | ||
| #[test] | ||
| fn test_remove_reports_a_missing_mail_spool_and_home() { |
There was a problem hiding this comment.
could you please split this into 4 tests? easier to see which case fails
There was a problem hiding this comment.
Split in 5586d94 into test_remove_reports_a_missing_mail_spool_and_home, test_remove_reports_a_missing_home, test_remove_reports_a_missing_mail_spool and test_remove_reports_an_empty_home_field.
7826e86 to
5586d94
Compare
| shared_by_other: bool, | ||
| ) -> Result<(), UserdelError> { | ||
| let mail = root.resolve(&format!("/var/mail/{login}")); | ||
| if mail.exists() { |
There was a problem hiding this comment.
exists() follows symlinks: a dangling /var/mail/login link is reported as not found and left behind.
should we use symlink_metadata here?
There was a problem hiding this comment.
I checked Ubuntu 26.04 (passwd 1:4.17.4-2ubuntu3). userdel -r follows the link too. With a dangling /var/mail/LOGIN link it prints LOGIN mail spool (/var/mail/LOGIN) not found, exits 0 and leaves the link in place. A dangling home link gets LOGIN home directory (/home/LOGIN) not found, exit 0, and is also left in place. So exists() already matches it, and symlink_metadata would remove a link that Ubuntu keeps. 1ae392c adds a comment saying this and tests for both cases. I checked that both tests fail with symlink_metadata. When a link is removed it is never followed: the spool goes through remove_file, which unlinks it, and safe_remove_home refuses a symlinked home.
|
sorry but it needs to be rebased |
`userdel -r` was silent when the user's mail spool or home directory did not exist. Ubuntu 26.04's userdel prints `LOGIN mail spool (PATH) not found` and `LOGIN home directory (PATH) not found` on standard error, mail spool first, and still exits 0; an empty home field is reported as `()`. Do the same, handling the spool before the home as upstream does. Fixes #392
One test per case, so a failure names the case: both missing, only the home missing, only the spool missing, and an empty home field.
Ubuntu 26.04's userdel -r follows the link: a dangling /var/mail/LOGIN or home link is reported as not found, with exit 0, and left in place. exists() follows it the same way; say so, and test both cases.
1ae392c to
7783c18
Compare
|
Rebased on main. New head: 7783c18 |
Fixes #392
Split out of #393, as asked there. Based on #394, which reverts #393; independent of #395.
userdel -rsaid nothing when the user's mail spool or home directory did not exist. Ubuntu 26.04's userdel printsLOGIN mail spool (PATH) not foundandLOGIN home directory (PATH) not foundon standard error, mail spool first, and still exits 0; an empty home field is reported as(). This does the same, handling the spool before the home as upstream does.Checks
In the Debian container:
cargo test --workspace(1066 passed, 0 failed),cargo clippy --workspace --all-targets -- -D warnings,cargo fmt --all --check.Reviews welcome. Without objection, this will be merged after 7 days.