chfn: writes five GECOS fields, GNU writes four when "other" is empty
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
从 src/uu/chfn/src/chfn.rs 中的 Gecos::to_gecos_string,以及 issue 中提到的单元测试 test_gecos_parse_empty 和 test_gecos_partial_update 开始。将预期输出与 GNU 示例进行比较,然后检查空的 “other” 值是否省略额外字段,而非空值是否仍得到表示。实现和两个测试都符合这些情况即为完成。
由索引模型根据 Issue 内容生成。
描述
chfn always writes the "other" field, so the GECOS gets a trailing comma that GNU chfn does not write:
# useradd -m alice
# chfn -f NewName alice
# getent passwd alice
alice:x:1001:1001:NewName,,,,:/home/alice:/bin/sh
GNU shadow 4.17.4 writes NewName,,,. Same with an existing entry: A,B,C,D and chfn -r R2 gives A,R2,C,D, (GNU A,R2,C,D), and A with chfn -r R gives A,R,,, (GNU A,R,,). When "other" is set (A,B,C,D,E), both keep it.
So every plain chfn run leaves an entry that differs from GNU, and tools that split the GECOS on commas see an extra empty field.
The output comes from Gecos::to_gecos_string (src/uu/chfn/src/chfn.rs:100). Two unit tests pin the five-field form: test_gecos_parse_empty expects ",,,," and test_gecos_partial_update expects a trailing comma. Matching GNU means changing both. I have a fix that writes "other" and its comma only when it is non-empty; happy to open a PR if you want GNU's output here.
GNU shadow 4.17.4 (Ubuntu 26.04). shadow-rs main f913109.
- 主要语言
- Rust
- 星标
- 17
- 派生
- 10
- 平均合并
- 1 天 5 小时
- 30 天内合并 PR
- 30
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
uutils/shadow 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 62/100
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 20/100
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
compiler P4 perf
难度 2/5 1-3 小时 新手友好度 78/100
HerringtonDarkholme/hd-lang#1044 ·
维护者通常 1 天内回复
-
good first issue help wanted r-docs
难度 2/5 1-3 小时 新手友好度 72/100
servo/rust-smallvec#824 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 90/100
akitaonrails/ai-usagebar#552 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100