Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def create_user(self, name, **kwargs):
- """
- Creates users for the system using the GNU passwd tools. This
- will work on an GNU system. This should be overriden on
- distros where useradd is not desirable or not available.
- """
- # Add the user
- self.add_user(name, **kwargs)
- # Set password if plain-text password provided and non-empty
- if 'plain_text_passwd' in kwargs and kwargs['plain_text_passwd']:
- self.set_passwd(name, kwargs['plain_text_passwd'])
- # Set password if hashed password provided and non-empty
- if 'hashed_passwd' in kwargs and kwargs['hashed_passwd']:
- self.set_passwd(name, kwargs['hashed_passwd'], True)
- # Default locking down the account. 'lock_passwd' defaults to True.
- # lock account unless lock_password is False.
- if kwargs.get('lock_passwd', True):
- self.lock_passwd(name)
- # Configure sudo access
- if 'sudo' in kwargs:
- self.write_sudo_rules(name, kwargs['sudo'])
- # Import SSH keys
- if 'ssh_authorized_keys' in kwargs:
- keys = set(kwargs['ssh_authorized_keys']) or []
- ssh_util.setup_user_keys(keys, name, options=None)
- return True
Advertisement
Add Comment
Please, Sign In to add comment