Repository navigation
chfn: write the other sub-field only when it is set - #397
Merged
Merged
Conversation
sylvestre
reviewed
Nov 3, 2026
| /// Run `chfn -R` on an account whose GECOS is `gecos` and return the GECOS | ||
| /// field written back. | ||
| fn gecos_after(gecos: &str, args: &[&str]) -> String { | ||
| let dir = tempfile::tempdir().expect("failed to create temp dir"); |
Collaborator
There was a problem hiding this comment.
could use setup_prefix here, no?
Collaborator
Author
There was a problem hiding this comment.
Yes, it fits: gecos_after now builds its prefix with setup_prefix, in 11cac62.
Upstream writes the four finger fields and adds "other", with its comma, only when it is not empty. chfn always wrote five fields, so every change on an account with no "other" left a trailing empty sub-field: chfn -f NewName on an empty GECOS gave NewName,,,, where upstream gives NewName,,,.
gecos_after wrote etc/passwd by hand, which is what setup_prefix does.
pierre-warnier
force-pushed
the
fix-362-chfn-other
branch
from
November 8, 2026 07:13
11cac62 to
2768a12
Compare
Collaborator
|
Thanks for your PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #362
chfnalways wrote five GECOS sub-fields, so an account with no "other" got a trailing empty field (NewName,,,,). It now writes the four finger fields and adds "other", with its comma, only when "other" is not empty.Behaviour checked against Ubuntu 26.04's packaged
passwd(1:4.17.4-2ubuntu3) inubuntu:26.04:-f NewNameNewName,,,A,B,C,D-r R2A,R2,C,DA-r RA,R,,A,B,C,D,-r RA,R,C,DA,,,,-r RA,R,,A-f '',,,A,B,C,D,E-o ''A,B,C,DA,B,C,D,E,F-r RA,R,C,D,E,F-o X,,,,XEvery row is now an integration test (
test_chfn_writes_other_only_when_set), which fails on main. The two unit tests that pinned the five-field form are updated, the man page says when "other" is written, and there is a CHANGELOG entry.Reviews welcome. Without objection, this will be merged after 7 days.