ManaTools::Shared::Users

Section: User Contributed Perl Documentation (3)
Updated: 2017-07-06
Page Index
 

NAME

ManaTools::Shared::Users - backend to manage users  

SYNOPSIS

    my $userBackEnd = ManaTools::Shared::Users->new();
    my $userInfo    = $userManager->getUserInfo('username');

 

DESCRIPTION

This module gives a low level access to the system user management it uses libUSER module.  

SUPPORT

You can find documentation for this module with the perldoc command:

perldoc ManaTools::Shared::Users  

SEE ALSO

libUSER  

AUTHOR

Angelo Naselli <anaselli@linux.it>  

COPYRIGHT and LICENSE

Copyright (C) 2014-2016, Angelo Naselli.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2, as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA  

METHODS

 

new - optional parameters

face_dir

    optional parameter to set the system face icon directory,
    default value is /usr/share/mga/faces/

 

new - optional parameters

user_face_dir

    optional parameter to set the user face icon directory,
    default value is /usr/share/mga/faces/

 

BUILD

INPUT

    $self: this object

DESCRIPTION

    The BUILD method is called after a Moose object is created,
    Into this method new optional parameters are tested once,
    instead of into any other methods.

 

facedir

OUTPUT

    path to directory containing face icon

DESCRIPTION

    Return the directory containing face icons.

 

userfacedir

OUTPUT

    path to directory containing user face icons

DESCRIPTION

    Return the directory containing user face icons.

 

face2png

INPUT

    $face: face icon name (usually username)

OUTPUT

    pathname to $face named icon with png extension

DESCRIPTION

    This method returns the face icon pathname related to username

 

facenames

OUTPUT

    $namelist: ARRAY reference containing the face name list

DESCRIPTION

    Retrieves the list of icon name from facesdir()

 

addKdmIcon

INPUT

    $user: username to add
    $icon: chosen icon for username $user

DESCRIPTION

    Add a $user named icon to $self->user_face_dir. It just copies
    $icon to $self->user_face_dir, naming it as $user

 

removeKdmIcon

INPUT

    $user: username icon to remove

DESCRIPTION

    Remove a $user named icon from $self->user_face_dir

 

_valid

INPUT

    $name:        User or Group name
    $name_length: Max length of $name (default 32)

OUTPUT

    1, locale "Ok" if valid
    0, and explanation string if not valid:
        - Name field is empty please provide a name
        - The name must contain only lower cased latin letters, numbers, '.', '-' and '_'
        - Name is too long

DESCRIPTION

    this internal method return if a name is compliant to
    a group or user name.

 

valid_username

INPUT

    $username: user name to check

OUTPUT

    1 if valid, 0 if not (see _valid)

DESCRIPTION

    Checks the valididty of the string $username

 

valid_groupname

INPUT

    $groupname: user name to check

OUTPUT

    1 if valid, 0 if not (see _valid)

DESCRIPTION

    Checks the valididty of the string $groupname

 

updateOrDelUsersInGroup

INPUT

    $name:   username

DESCRIPTION

    Fixes user deletion into groups.

 

getGoups

OUTPUT

    $groups: ARRAY reference containing all the groups

DESCRIPTION

    This method return the configured groups

 

groupNameExists

INPUT

    $groupname: the name of the group to check

OUTPUT

    if group exists

DESCRIPTION

    This method return if a given group exists

 

groupIDExists

INPUT

    $group: the id of the group to check

OUTPUT

    if group exists

DESCRIPTION

    This method return if a given group exists

 

groupID

INPUT

    $groupname: group name

OUTPUT

    groupid or undef

DESCRIPTION

    This method returns the group id for the group name

 

groupName

INPUT

    $gid group identifier

OUTPUT

    group name or undef

DESCRIPTION

    This method returns the group name for the given group
    identifier

 

addGroup

INPUT

    $params: HASH reference containing:
        groupname => name of teh group to be added
        gid       => group id of the group to be added
        is_system => is a system group?

OUTPUT

    $gid the actual group id

DESCRIPTION

    This method add a group to system

 

groupMembers

INPUT

    $groupname: The group name

OUTPUT

    $members: ARRAY reference containing all the user belonging
              to the given $groupname

DESCRIPTION

    This method gets the group name and returns the users
    belonging to it

 

isPrimaryGroup

INPUT

    $groupname: the name of the group

OUTPUT

    $username: undef if it is primary group or the username for
               which the group is the primary one.

DESCRIPTION

    This methods check if the given group name is primary group
    for any users belonging to the group

 

deleteGroup

INPUT

    $groupname: in_par_description

OUTPUT

    0: if error occurred
    1: if removed

DESCRIPTION

    This method remove the group from the system

 

modifyGroup

INPUT

    $groupInfo: HASH reference containing:
        old_groupname => old name of the group (if renaming)
        groupname     => group name
        members       => users belonging to the group

OUTPUT

    $retval => HASH reference
        status => 1 (ok) 0 (error)
        error  => error message if status is 0

DESCRIPTION

    This method modifies the group groupname

 

getGroupsInfo

    $options: HASH reference containing
            groupname_filter => groupname search string
            filter_system   => hides system groups

OUTPUT

    $groupsInfo: HASH reference containing
        groupname-1 => {
            gid    => group identifier
            members  => ARRAY of username
        }
        groupname-2 => {
            ...
        }

DESCRIPTION

    This method get group information (all groups or the
    filtered ones)

 

getUsers

OUTPUT

    $users: ARRAY reference containing all the users

DESCRIPTION

    This method return the configured users

 

getUserInfo

INPUT

    $username: user name

OUTPUT

    $userInfo: HASH reference containing
        {
            uid         => user identifier
            gid         => group identifier
            fullname    => user full name
            home        => home directory
            shell       => user shell
            expire      => shadow expire time
            locked      => is locked?
            exp_min     => shadow Min
            exp_max     => shadow Max
            exp_warn    => shadow Warn
            exp_inact   => shadow Inact
            last_change => Shadow last change
            members     => groups the user belongs to
        }

DESCRIPTION

    This method get all the information for the given user

 

getUsersInfo

INPUT

    $options: HASH reference containing
        username_filter => username search string
        filter_system   => hides system users

OUTPUT

    $usersInfo: HASH reference containing
        username-1 => {
            uid    => user identifier
            group  => primary group name
            gid    => group identifier
            fullname  => user full name
            home   => home directory
            shell  => user shell
            status => login status (locked, expired, etc)
        }
        username-2 => {
            ...
        }

DESCRIPTION

    This method get user information (all users or filtered ones)

 

getUserHome

INPUT

    $username: given user name

OUTPUT

    $homedir: user home directory

DESCRIPTION

    This method return the home directory belonging to the given
    username

 

userNameExists

INPUT

    $username: the name of the user to check

OUTPUT

    if user exists

DESCRIPTION

    This method return if a given user exists

 

computeLockExpire

INPUT

    $l: login user info

OUTPUT

    $status: Locked, Expired, or empty string

DESCRIPTION

    This method returns if the login is Locked, Expired or ok.
    Note this function is meant for internal use only

 

addUser

INPUT

    $params: HASH reference containing:
        username  => name of teh user to be added
        uid       => user id of the username to be added
        is_system => is a system user?
        homedir   => user home directory
        donotcreatehome => do not create the home directory
        shell => user shall
        fullname => user full name
        gid => group id for the user
        shadowMin => min time password validity
        shadowMax => max time password validity
        shadowInact =>
        shadowWarn  =>
        password  => user password

OUTPUT

    0 if errors 1 if ok

DESCRIPTION

    This method add a user to system

 

modifyUser

INPUT

    $userInfo: HASH reference containing:
        old_username  => old name of the user (if renaming)
        username      => user name
        fullname      => full name of teh user
        password      => password
        homedir       => home directory
        shell         => user shell
        members       => groups the user belongs to
        gid           => primary group identifier
        lockuser      => lock user
        acc_expires   => account expire time - containing:
                exp_y     => year
                exp_m     => month
                exp_d     => day
     password_expires => password expire time - containing:
                exp_min   => min
                exp_max   => max
                exp_warn  => when warn
                exp_inact => when inactive

DESCRIPTION

    This method modifies the group groupname

 

deleteUser

INPUT

    $username: username to be deleted
    $options:  HASH reference containing
            clean_home  => if home has to be removed
            clean_spool => if sppol has to be removed

OUTPUT

    error string or undef if no errors occurred

DESCRIPTION

    This method delete a user from the system.

 

getUserShells

OUTPUT

    GetUserShells: from libUSER

DESCRIPTION

    This method returns the available shell

 

GetFaceIcon

INPUT

    $name: icon name for the given username
    $next: if passed means getting next icon from the given $name

OUTPUT

    $user_icon: icon name

DESCRIPTION

    This method returns the icon for the given user ($name) or the
    following one if $next is passed

 

strongPassword

INPUT

    $passwd: password to be checked

OUTPUT

    1: if password is strong
    0: if password is weak

DESCRIPTION

    Check for a strong password

 

weakPasswordForSecurityLevel

INPUT

    $passwd: password to check

OUTPUT

    1: if the password is too weak for security level

DESCRIPTION

    Check the security level set if /etc/security/msec/security.conf
    exists and the level is not 'standard' and if the password
    is not at least 6 characters return true

 

Add2UsersGroup

INPUT

    $name: username

OUTPUT

    $gid: group id

DESCRIPTION

    Adds the given username $name to 'users' group


 

Index

NAME
SYNOPSIS
DESCRIPTION
SUPPORT
SEE ALSO
AUTHOR
COPYRIGHT and LICENSE
METHODS
new - optional parameters
new - optional parameters
BUILD
facedir
userfacedir
face2png
facenames
addKdmIcon
removeKdmIcon
_valid
valid_username
valid_groupname
updateOrDelUsersInGroup
getGoups
groupNameExists
groupIDExists
groupID
groupName
addGroup
groupMembers
isPrimaryGroup
deleteGroup
modifyGroup
getGroupsInfo
getUsers
getUserInfo
getUsersInfo
getUserHome
userNameExists
computeLockExpire
addUser
modifyUser
deleteUser
getUserShells
GetFaceIcon
strongPassword
weakPasswordForSecurityLevel
Add2UsersGroup