|
|
| |
PasswdFile(3) |
User Contributed Perl Documentation |
PasswdFile(3) |
Unix::PasswdFile - Perl interface to /etc/passwd format files
use Unix::PasswdFile;
$pw = new Unix::PasswdFile "/etc/passwd";
$pw->user("joeblow", $pw->encpass("secret"), $pw->maxuid + 1, 10,
"Joe Blow", "/export/home/joeblow", "/bin/ksh");
$pw->delete("deadguy");
$pw->passwd("johndoe", $pw->encpass("newpass"));
foreach $user ($pw->users) {
print "Username: $user, Full Name: ", $pw->gecos($user), "\n";
}
$pw->commit();
undef $pw;
The Unix::PasswdFile module provides an abstract interface to /etc/passwd format
files. It automatically handles file locking, getting colons in the right
places, and all the other niggling details.
See the Unix::ConfigFile documentation for a description of this method.
This method will delete the named user. It has no effect if the supplied user
does not exist.
See the Unix::ConfigFile documentation for a description of this method.
Read or modify a user's GECOS string (typically their full name). Returns the
GECOS string in either case.
Read or modify a user's GID. Returns the GID in either case.
Read or modify a user's home directory. Returns the home directory in either
case.
This method returns the maximum UID in use by all users. If you pass in the
optional IGNORE parameter, it will ignore all UIDs greater or equal to IGNORE
when doing this calculation. This is useful for excluding accounts like
nobody.
See the Unix::ConfigFile documentation for a description of this method.
Read or modify a user's password. Returns the encrypted password in either case.
If you have a plaintext password, use the encpass method to encrypt it before
passing it to this method.
This method changes the username for a user. If NEWNAME corresponds to an
existing user, that user will be overwritten. It returns 0 on failure and 1 on
success.
Read or modify a user's shell. Returns the shell in either case.
Read or modify a user's UID. Returns the UID in either case.
This method can add, modify, or return information about a user. Supplied with a
single username parameter, it will return a six element list consisting of
(PASSWORD, UID, GID, GECOS, HOMEDIR, SHELL), or undef if no such user exists.
If you supply all seven parameters, the named user will be created or modified
if it already exists. The six element list is also returned to you in this
case.
This method returns a list of all existing usernames. By default the list will
be sorted in order of the UIDs of the users. You may also supply
"name" as a parameter to the method to get the list sorted by
username. In scalar context, this method returns the total number of users.
Steve Snodgrass, ssnodgra@fore.com
Unix::AliasFile, Unix::AutomountFile, Unix::ConfigFile, Unix::GroupFile
Visit the GSP FreeBSD Man Page Interface. Output converted with ManDoc. |