in reply to printing passwd file

Mmh, nothing on CPAN for this? I expected to find something like Passwd::Parse but for no avail.

Update: *Ouch.*


holli, /regexed monk/

Replies are listed 'Best First'.
Re^2: printing passwd file
by Fletch (Bishop) on Mar 14, 2005 at 19:16 UTC

    You mean aside from Unix::PasswdFile, Passwd::Solaris and Passwd::Linux, or AnyData::Format::Passwd?

    Or the built-in getpwent and friends? (Which has the benefit of probably honoring the local system's NIS or other remote password source)

    Nope. nothing.

    Update: OK, those middle two are for adding and removing new entries from the corresponding OS' passwd files rather than parsing out contents so they probably don't count as "parsing passwd" modules.

Re^2: printing passwd file
by jhourcle (Prior) on Mar 14, 2005 at 19:13 UTC

    There's a function -- getpwent, so I guess there hasn't been as much need for it. (besides, it's just a colon delim file, so most other parsing programs could do it).

    I'd also like to point out that there is no 'name' field in a passwd file -- it's the gecos field, which contains a comma seperated list of optional comments, the first of which is typically the name. (which is why you get odd behavior when someone tries entering a name in 'last, first' format.) From perldoc -f getpwent :

    The exact meaning of the $gcos field varies but it usually contains the real name of the user (as opposed to the login name) and other information pertaining to the user. Beware, however, that in many system users are able to change this information and therefore it cannot be trusted and therefore the $gcos is tainted (see perlsec). The $passwd and $shell, user's encrypted password and login shell, are also tainted, because of the same reason.
Re^2: printing passwd file
by sh1tn (Priest) on Mar 14, 2005 at 20:12 UTC
    Maybe I have put the wrong name - it is quite "silent",
    but what can be more expressive than usermod?
    #!/usr/bin/perl use strict; use Linux::usermod; my %users = Linux::usermod::users(); print join "\n", keys %users __END__ # STDOUT: backup bin cv daemon games gnats helpdesk identd irc list lp mail man mysql netsaint news nobody operator popa3d postfix postgres proxy reni root snort spong sshd su sync sys uucp vidul vis www-data # all those looks like system user accounts to me :)