NAME

Passwd::DB - Perl module for manipulating a password file stored in a BerkeleyDB hash

SYNOPSIS

use Passwd::DB;

$db = Passwd::DB->new("/usr/local/databases/db_ftp_users");
$db = Passwd::DB->new("/usr/local/databases/db_ftp_users", 'create');
@info = $db->getpwnam('bob');
@info = $db->getpwuid('100');
@minfo = $db->mgetpwnam('bob');
$err = $db->modpwinfo(@minfo);
$err = $db->setpwinfo(@minfo);
$err = $db->rmpwnam('bob');

use Passwd::DB qw(init_db getpwnam getpwuid mgetpwnam modpwinfo setpwinfo rmpwnam);

Passwd::DB->init_db("/usr/local/databases/db_ftp_users");
Passwd::DB->init_db("/usr/local/databases/db_ftp_users", 1);
init_db("/usr/local/db_bob",1);
@info = getpwnam('bob');
@info = getpwuid('100');
@minfo = mgetpwnam('bob');
$err = modpwinfo(@minfo);
$err = setpwinfo(@minfo);
$err = rmpwnam('bob');

DESCRIPTION

Passwd::DB provides basic password routines. It augments getpwnam and getpwuid functions with setpwinfo, modpwinfo, rmpwnam, mgetpwnam. The routines can be used both in object context or straight. When used in non-object context a call to init_db is required to initialize the global data base structure. This does mean that you can have only one active database when used in non-object context.

new and init_db can be called with an optional second argument. If it is set to 1 or 'create' the database will be created if it doesn't already exist.

getpwnam and getpwuid are the same as their respective core counterparts.

setpwinfo and modpwinfo are called with arrays containing (in order): name, crypted_password, uid, gid, gecos, home_directory, shell

rmpwnam is called with a scalar containing the login name.

mgetpwnam returns the same array that getpwnam returns without the 'unused' age or comment fields.

setpwinfo does a create/modify of the user. modpwinfo only does a modify, it will return an error if the user doesn't exist.

rmpwnam removes the user with the given login. It returns an error if the user doesn't exist.

Right now all functions croak when they can't open the database. This will change if the majority of people don't like this behavior.

Error return values: < 0 system error occurred, error value should be in $! 0 no error 1 operation failed 2 operation failed because user does not exist

Exported functions on the OK basis

getpwnam
getpwuid
mgetpwnam
modpwinfo
setpwinfo
rmpwnam
init_db

AUTHOR

Eric Estabrooks, eric@urbanrage.com

SEE ALSO

perl(1).