3.14. users

3.14.1. NAME

users - Guardian Digital WebTool module interface to system users and groups.

3.14.2. SYNOPSIS

use users;
my $users  = new users;

3.14.3. DESCRIPTION

This Guardian Digital WebTool module provides an interface to manipulating system users and groups. This module allows you to manage system users, system groups, and primary and secondary groups for users.

3.14.4. METHODS

map_grent_array($)

This function is used internally, it receives array as returned by getgrent(). It just makes a hash reference containing this information and returns it.

Example Usage:

my $hashgrent = users::map_grent_array(\@u);

map_pwent_array($)

This function receives array as returned by getpwent(). It sets all those parameters as key-value pairs including shell and type of users and returns hash reference.

Example Usage:

my $hashpwent = map_pwent_array(\@u);

set_password($$)

This function is basically used to set password for particular user. Username and password is passed as arguments.

Example Usage:

users::set_password($username, $password);

update_group_members($$)

This function is basically used to update the group members. Groupname and members are sent as arguments to this function.

Example Usage:

users::update_group_members($name, $members);

users_list()

This function returns all of the local users on the system excluding root.

Example Usage:

my @tmp = $users->users_list();

user_get($@)

This function is used to get a particular user related information(returned by getpwent). Username is passed as an argument.

Example Usage:

my $user = $users->user_get($username);

user_create($)

This function is used to create a user in the system, It receives a hash reference containing user parameters like username, login shell, home directory, group and password.

Example Usage:

my $u   = {
      'username'      => $in{'username'},
      'gcos'          => $in{'name'},
      'group'         => make_group($in{'type'}, $in{'group'}),
      'password'      => $in{'password'},
      'shell'         => make_shell($in{'shell_axs'}),
  };

$users->user_create($u);

user_modify($)

This function is used to modify a current user, It receives hash reference as argument which contains parameters to be modified (any parameters listed in user_create function).

Example Usage:

$users->user_modify($u);

user_delete($@)

This function is used to delete user's account from system. It also receives one optional argument besides username, depends on that user's home directory deletion can be decided. If that parameter is sent other than zero than that user's home directory will be deleted.

Example Usage:

$users->user_delete($username, $killhome);

groups_list($)

This function is basically used to retrive array references as returned by getgrent of all users falling under groups (root/admin,users and group id is greater than 500) and returns it in array form.

Example Usage:

my @grouplist  = $users->groups_list();

group_get($@)

This function can be used to receive arrays as returned by getgrnam. It receives group name as mandetory argument. Hash reference containing key-value pairs of parameters and values(from getgrnam) is returned.

Example Usage:

my $groupdetail  = $groups->group_get($group);

group_create($)

This function is used to create a new group. It receives hash reference containing new group name and list of members belongs to that group.

Example Usage:

my $group  = {
      'name'          => $in{'name'},
      'members'       => join(',', $in{'members'}),
  };

$users->group_create($group);

group_modify($)

This function is used to modify an existing group(e.g new name). It receives hash reference as argument which contains parameters to be modified (any parameters listed in group_create function).

Example Usage:

$users->group_modify($group);

group_delete($)

This function is used to delete an existing group. It receives a group name as an argument.

Example Usage:

$users->group_delete($group_name);

3.14.5. AUTHORS

Ryan W. Maple <ryan@guardiandigital.com>

3.14.6. COPYRIGHT AND LICENSE

Copyright Guardian Digital, Inc., All Rights Reserved