Guest User

Untitled

a guest
Jan 8th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. def create_user(self, name, **kwargs):
  2. """
  3. Creates users for the system using the GNU passwd tools. This
  4. will work on an GNU system. This should be overriden on
  5. distros where useradd is not desirable or not available.
  6. """
  7.  
  8. # Add the user
  9. self.add_user(name, **kwargs)
  10.  
  11. # Set password if plain-text password provided and non-empty
  12. if 'plain_text_passwd' in kwargs and kwargs['plain_text_passwd']:
  13. self.set_passwd(name, kwargs['plain_text_passwd'])
  14.  
  15. # Set password if hashed password provided and non-empty
  16. if 'hashed_passwd' in kwargs and kwargs['hashed_passwd']:
  17. self.set_passwd(name, kwargs['hashed_passwd'], True)
  18.  
  19. # Default locking down the account. 'lock_passwd' defaults to True.
  20. # lock account unless lock_password is False.
  21. if kwargs.get('lock_passwd', True):
  22. self.lock_passwd(name)
  23.  
  24. # Configure sudo access
  25. if 'sudo' in kwargs:
  26. self.write_sudo_rules(name, kwargs['sudo'])
  27.  
  28. # Import SSH keys
  29. if 'ssh_authorized_keys' in kwargs:
  30. keys = set(kwargs['ssh_authorized_keys']) or []
  31. ssh_util.setup_user_keys(keys, name, options=None)
  32.  
  33. return True
Advertisement
Add Comment
Please, Sign In to add comment