Package syspolicy :: Package modules :: Module shadow :: Class Shadow
[hide private]
[frames] | no frames]

Class Shadow

source code

module.Module --+
                |
               Shadow

This module provides shadow users & groups management support for SysPolicy.

The features include full add, modify and remove operations and all the attributes supported by the standard utilities are supported. These include specifying the basedir, homedir, grouping of home directories, real name of the user, account expiration and inactivity periods, groups, custom skeleton directories, assigning specific shells and password auto-generation combined with strength checking.

Instance Methods [hide private]
 
__init__(self) source code
 
cs_set_attribute(self, group, attribute, value, diff)
This function returns a ChangeSet respective to a changed policy attribute.
source code
 
cs_add_user(self, username, group, password, extragroups=[], name=None, homedir=None, policy={})
This function returns a ChangeSet for when a new user account needs to be created.
source code
 
cs_mod_user(self, username, group=None, extragroups=[], password=None, name=None, homedir=None, policy={})
This function returns a ChangeSet which performs user modification.
source code
 
cs_del_user(self, username)
This function returns a ChangeSet which performs user removal.
source code
 
cs_add_group(self, group)
This function returns a ChangeSet which adds a new group.
source code
 
cs_del_group(self, group)
This function returns a ChangeSet which removes a group.
source code
 
add_user(self, change)
This function performs user addition by executing the useradd command.
source code
 
mod_user(self, change)
This function performs user modification by executing the usermod command.
source code
 
del_user(self, change)
This function performs user deletion by executing the userdel command.
source code
 
add_group(self, change)
This function performs group addition by executing the groupadd command.
source code
 
del_group(self, change)
This function performs group deletion by executing the groupdel command.
source code
 
get_password_policy(self)
This module returns the system main password security policy by looking it up from the main configuration and the service policy.
source code

Inherited from module.Module: append_lines_to_file, cs_check_diff, cs_new_attribute, cs_rem_attribute, cs_set_default, edit_configfile, execute, perform_change

Class Variables [hide private]

Inherited from module.Module: change_operations, diff_operations, event_hooks, handled_attributes, name, pt

Method Details [hide private]

__init__(self)
(Constructor)

source code 
Overrides: module.Module.__init__

cs_set_attribute(self, group, attribute, value, diff)

source code 

This function returns a ChangeSet respective to a changed policy attribute.

In case the changed attribute affects existing users, the group members' accounts will be updated as well. For example, when the shell of the group was changed, you probably want all the accounts to be updated.

Parameters:
  • group - The group for which the attribute is being set
  • attribute - The attribute in the policy that is being set
  • value - The new value
  • diff - The difference from the old value
Returns:
A ChangeSet or None
Overrides: module.Module.cs_set_attribute

cs_add_user(self, username, group, password, extragroups=[], name=None, homedir=None, policy={})

source code 

This function returns a ChangeSet for when a new user account needs to be created. It prepares the arguments that need to be passed to the useradd utility based on the arguments given and the users' group policy.

Parameters:
  • username - The username of the new account
  • group - The primary group name
  • password - The password for the account in crypt hash format
  • extragroups - Extra groups that the new account should belong to
  • name - Real name of the accont owner
  • homedir - Custom home directory for this account
  • policy - Additional parameters that override the group policy
Returns:
A ChangeSet

cs_mod_user(self, username, group=None, extragroups=[], password=None, name=None, homedir=None, policy={})

source code 

This function returns a ChangeSet which performs user modification.

It prepares any given arguments and checks also if changing the primary group was requested. In case the primary group is to be changed, the function also includes the differences from the old to the new group policy, keeping the account up to date (eg. quota).

Parameters:
  • username - The username of the account to be modified
  • group - The new primary group name
  • password - The new password for the account in crypt hash format
  • extragroups - Extra groups that the new account should belong to
  • name - Real name of the accont owner
  • homedir - Custom home directory for this account
  • policy - Additional parameters that override the group policy
Returns:
A ChangeSet

cs_del_user(self, username)

source code 

This function returns a ChangeSet which performs user removal.

Parameters:
  • username - The user account to be removed.
Returns:
A ChangeSet

cs_add_group(self, group)

source code 

This function returns a ChangeSet which adds a new group.

Parameters:
  • group - The name of the new group
Returns:
A ChangeSet

cs_del_group(self, group)

source code 

This function returns a ChangeSet which removes a group.

Parameters:
  • group - The name of the group to be removed
Returns:
A ChangeSet

add_user(self, change)

source code 

This function performs user addition by executing the useradd command.

Parameters:
  • change - Change element with parameters
Returns:
STATE_COMPLETED or STATE_FAILED

mod_user(self, change)

source code 

This function performs user modification by executing the usermod command.

Parameters:
  • change - Change element with parameters
Returns:
STATE_COMPLETED or STATE_FAILED

del_user(self, change)

source code 

This function performs user deletion by executing the userdel command.

Parameters:
  • change - Change element with parameters
Returns:
STATE_COMPLETED or STATE_FAILED

add_group(self, change)

source code 

This function performs group addition by executing the groupadd command.

Parameters:
  • change - Change element with parameters
Returns:
STATE_COMPLETED or STATE_FAILED

del_group(self, change)

source code 

This function performs group deletion by executing the groupdel command.

Parameters:
  • change - Change element with parameters
Returns:
STATE_COMPLETED or STATE_FAILED

get_password_policy(self)

source code 

This module returns the system main password security policy by looking it up from the main configuration and the service policy.

Returns:
A dictionary with password policy (cracklib-style keys-values)