src/ssh_pmod.py
def _get_user(self, user=None):
        """Gets a new user from the user and returns it."""

        new_user = {}
        if user:
            logging.info('SSHPMod: Replacing bad user:', user)

        new_user['username'] = ''
        while (len(new_user['username']) == 0 or
               new_user['username'] == 'root' or
               not new_user['username'].isalpha() or
               any(map(lambda user: user['username'] == new_user['username'],
                       self.users)) or
               not os.path.isdir(BASE_HOME_DIR + new_user['username'])):
            ipt = input('SSHPMod: User: username [NOT "root" or previous, ' +
                        '/home/$username exists, alpha char only]: ')
            ipt = ipt.strip().lower()
            new_user['username'] = ipt
        new_user['homeDir'] = BASE_HOME_DIR + new_user['username']

        ipt = input('SSHPMod: User: deleteAllSSHKeys [true]: ')
        ipt = ipt.strip().lower()
        new_user['deleteAllSSHKeys'] = ipt != 'false'

        new_user['authorizedKeys'] = []
        while len(new_user['authorizedKeys']) == 0:
            auth_key = None
            while auth_key is None or len(auth_key) > 0:
                if auth_key:
                    new_user['authorizedKeys'].append(auth_key)

                auth_key = input('SSHPMod: User: authorizedKey ' +
                                 '[ENTER when done]: ')

        return new_user
Gets a new user from the user and returns it.
Gets a new user from the user and returns it.
Gets a new user from the user and returns it .
def _get_user(self, user=None):
        new_user = {}
        if user:
            logging.info('SSHPMod: Replacing bad user:', user)
        new_user['username'] = ''
        while (len(new_user['username']) == 0 or
               new_user['username'] == 'root' or
               not new_user['username'].isalpha() or
               any(map(lambda user: user['username'] == new_user['username'],
                       self.users)) or
               not os.path.isdir(BASE_HOME_DIR + new_user['username'])):
            ipt = input('SSHPMod: User: username [NOT "root" or previous, ' +
                        '/home/$username exists, alpha char only]: ')
            ipt = ipt.strip().lower()
            new_user['username'] = ipt
        new_user['homeDir'] = BASE_HOME_DIR + new_user['username']
        ipt = input('SSHPMod: User: deleteAllSSHKeys [true]: ')
        ipt = ipt.strip().lower()
        new_user['deleteAllSSHKeys'] = ipt != 'false'
        new_user['authorizedKeys'] = []
        while len(new_user['authorizedKeys']) == 0:
            auth_key = None
            while auth_key is None or len(auth_key) > 0:
                if auth_key:
                    new_user['authorizedKeys'].append(auth_key)
                auth_key = input('SSHPMod: User: authorizedKey ' +
                                 '[ENTER when done]: ')
        return new_user
def _get_user ( self , user = None ) : new_user = { } if user : logging . info ( 'SSHPMod: Replacing bad user:' , user ) new_user [ 'username' ] = '' while ( len ( new_user [ 'username' ] ) == 0 or new_user [ 'username' ] == 'root' or not new_user [ 'username' ] . isalpha ( ) or any ( map ( lambda user : user [ 'username' ] == new_user [ 'username' ] , self . users ) ) or not os . path . isdir ( BASE_HOME_DIR + new_user [ 'username' ] ) ) : ipt = input ( 'SSHPMod: User: username [NOT "root" or previous, ' + '/home/$username exists, alpha char only]: ' ) ipt = ipt . strip ( ) . lower ( ) new_user [ 'username' ] = ipt new_user [ 'homeDir' ] = BASE_HOME_DIR + new_user [ 'username' ] ipt = input ( 'SSHPMod: User: deleteAllSSHKeys [true]: ' ) ipt = ipt . strip ( ) . lower ( ) new_user [ 'deleteAllSSHKeys' ] = ipt != 'false' new_user [ 'authorizedKeys' ] = [ ] while len ( new_user [ 'authorizedKeys' ] ) == 0 : auth_key = None while auth_key is None or len ( auth_key ) > 0 : if auth_key : new_user [ 'authorizedKeys' ] . append ( auth_key ) auth_key = input ( 'SSHPMod: User: authorizedKey ' + '[ENTER when done]: ' ) return new_user
Gets a new user from the user and returns it.
Gets a new user from the user and returns it .
"""Gets a new user from the user and returns it."""
self
user