Skip to content

pwcat: add password database dump utility - #63

Open
Franklin-Qi wants to merge 2 commits into
uutils:mainfrom
Franklin-Qi:feature-issue#61-add-pwcat
Open

Franklin-Qi wants to merge 2 commits into
uutils:mainfrom
Franklin-Qi:feature-issue#61-add-pwcat

Conversation

@Franklin-Qi

Copy link
Copy Markdown
Collaborator

Add a pwcat binary that prints the password database in /etc/passwd format 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

@Alonely0 Alonely0 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/bin/pwcat.rs Outdated
Comment thread src/bin/pwcat.rs Outdated
@Alonely0

Alonely0 commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

PD: use cfg_attr to set an ignore attribute on all tests when not running on Linux.

Comment thread src/bin/pwcat.rs Outdated
@Franklin-Qi
Franklin-Qi force-pushed the feature-issue#61-add-pwcat branch from 9852239 to c2117de Compare July 6, 2026 07:43
@Franklin-Qi

Copy link
Copy Markdown
Collaborator Author

PD: use cfg_attr to set an ignore attribute on all tests when not running on Linux.

Thanks for the review and the great suggestion; I’ve frequently encountered this issue before.

@sylvestre

Copy link
Copy Markdown
Contributor

i am sorry but why it should belong to awk ?

@oech3

oech3 commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

why it should belong to awk ?

See #34

Comment thread Cargo.toml Outdated
Comment thread src/bin/pwcat.rs Outdated
Comment thread src/bin/pwcat.rs Outdated
use rustix::fs::{Mode, OFlags, open};
use std::fs::File;

let fd = open(PASSWD_DB, OFlags::RDONLY, Mode::empty())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread tests/pwcat.rs Outdated
Comment thread tests/pwcat.rs Outdated
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
@Franklin-Qi
Franklin-Qi force-pushed the feature-issue#61-add-pwcat branch from c2117de to fb6b09e Compare September 30, 2026 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add pwcat command

4 participants