pwcat: add password database dump utility - #63
Franklin-Qi wants to merge 2 commits into
Conversation
Alonely0
left a comment
There was a problem hiding this comment.
As oech3 had mentioned in the other PR, we would really prefer not to use libc directly if we can help it. I can't see these functions implemented in either nix or rustix, so maybe we could add a safe API boundary in uucore and reuse it here? Mentioning this since we plan to reuse a lot of functionality from uucore in the interpreter directly.
|
PD: use |
9852239 to
c2117de
Compare
Thanks for the review and the great suggestion; I’ve frequently encountered this issue before. |
3cf396b to
048fe2a
Compare
|
i am sorry but why it should belong to awk ? |
See #34 |
| use rustix::fs::{Mode, OFlags, open}; | ||
| use std::fs::File; | ||
|
|
||
| let fd = open(PASSWD_DB, OFlags::RDONLY, Mode::empty()) |
There was a problem hiding this comment.
this just cats /etc/passwd, so users coming from ldap/sssd/systemd-userdb are missing. pwcat exists precisely because awk can't call getpwent() - please iterate over the password database instead.
Annotate elided lifetimes on prop-test helpers so clippy -D warnings passes under the current toolchain.
Add the pwcat helper used by gawk library routines such as passwd.awk. Print /etc/passwd-format lines from getpwent/endpwent, return ExitCode from main, and treat BrokenPipe as success. libc is needed because rustix/nix do not expose the password-database iterators. Closes uutils#61
c2117de to
fb6b09e
Compare
Add a
pwcatbinary that prints the password database in/etc/passwdformat for gawk library routines, matching the helper shipped with GNU awk.Includes integration tests that validate the seven-field output format and compare against
getent passwd.Closes #61