NAME

Linux::usermod - modify user accounts

SYNOPSIS

use Linux::usermod;

$user = Linux::usermod->new(username);

$user->get(gid); # equal to $user->get(3);
$user->get(uid); # equal to $user->get(2);

#lock and unlock user account

$user->lock();
$user->unlock();

#get password(passwd file)
$user->get(ppassword);

#get encoded password(shadow file)
$user->get(password); 

#set encoded password
$user->set(password); 

#set shell
$user->set(shell);

Linux::usermod->add(username);

#or

Linux::usermod->add(username, password, uid, gid, comment, home, shell);

#where the password goes in shadow file and gid becomes 
#equal to uid unless specified and uid is becoming the 
#first unreserved number after 1000 unless specified

#delete user
Linux::usermod->del(username);

#all fields are returned from the class method fields
print $user->get($_) for (Linux::usermod->fields);

#set working passwd and shadow files

#$Linux::usermod::file_passwd = "./my_passwd";
#$Linux::usermod::file_shadow = "./my_shadow";

DESCRIPTION

Linux::usermod adds, removes and modify user account according to the passwd and shadow files syntax (like struct passwd from pwd.h). It is not necessary those accounts to be system as long as Linux::usermod::file_passwd and Linux::usermod::file_shadow are not in "/etc" directory.

METHODS

new (username)
add (username, ...)

Class method - add new user account arguments to add are optional, except username; they may be (username, password, uid, gid, comment, home, shell)

del (username) Class method - removes user account
tobsd converts user fields in shadow / master.passwd file to bsd style
get

get one of the following fields:

NAME or 0 - The user's name
PPASSWORD or 1 - The "passwd" file password
UID or 2 - The user's id
GID or 3 - The user's group id
COMMENT or 4 - The Comment about the user (real username)
HOME or 5 - The user's home directory
SHELL or 6 - The user's shell
SNAME or 7 - The user's name in shadow file
PASSWORD or 8 - The 13-character encoded password
LASTCHG or 9 - The number of days since January 1, 1970 of the last password changed date
MIN or 10 - The minimum number of days required between password changes
MAX or 11 - The maximum number of days the password is valid
WARN or 12 - The number of days before expiring the password that the user is warned
INACTIVE or 13 - The number of days of inactivity allowed for the user
EXPIRE or 14 - The number of days since January 1, 1970 that account is disabled
FLAG or 15 - Currently not used

either string or number can be argument

set (field)

set a field which must be string, but not a number

lock (username)

Lock user account (puts '!' at the beginning of the encoded password)

unlock (username)

Unlock user account (removes '!' from the beginning of the encoded password)

users

Class method - return hash which keys are all users, taken from $file_passwd

FILES

/etc/passwd, /etc/shadow unless given your own passwd and shadow files which must be created no matter what their names are as long as Linux::usermod::file_passwd and Linux::usermod::file_shadow vars know about them

TO DO

Groups management

SEE ALSO

getpwent(3), getpwnam(3), usermod(8), passwd(8)

BUGS

None known. Report any to author.

AUTHOR

Vidul Petrov, vidul@abv.bg

© 2004 Vidul Petrov. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 513:

Non-ASCII character seen before =encoding in '©'. Assuming CP1252