Exemplo n.º 1
0
    def __init__(self, cfg=None):
        self.config = cfg
        if self.config is None:
            self.config = config.Config()
        self.cache = Password_Cache(self.config)
        self.fifo = password_ipc.FIFO(self.config.passwordCacheFifo())
        self.db = {}

        self.keyringSupported = tools.keyringSupported()
Exemplo n.º 2
0
    def __init__(self, cfg = None, *args, **kwargs):
        self.config = cfg
        if self.config is None:
            self.config = config.Config()
        pw_cache_path = self.config.get_password_cache_folder()
        if not os.path.isdir(pw_cache_path):
            os.mkdir(pw_cache_path, 0o700)
        else:
            os.chmod(pw_cache_path, 0o700)
        Daemon.__init__(self, self.config.get_password_cache_pid(), *args, **kwargs)
        self.db_keyring = {}
        self.db_usr = {}
        self.fifo = password_ipc.FIFO(self.config.get_password_cache_fifo())

        self.keyring_supported = tools.keyring_supported()
Exemplo n.º 3
0
    def __init__(self, cfg=None, *args, **kwargs):
        self.config = cfg
        if self.config is None:
            self.config = config.Config()
        cachePath = self.config.passwordCacheFolder()
        if not tools.mkdir(cachePath, 0o700):
            msg = 'Failed to create secure Password_Cache folder'
            logger.error(msg, self)
            raise PermissionError(msg)
        pid = self.config.passwordCachePid()
        super(Password_Cache, self).__init__(pid, *args, **kwargs)
        self.dbKeyring = {}
        self.dbUsr = {}
        self.fifo = password_ipc.FIFO(self.config.passwordCacheFifo())

        self.keyringSupported = tools.keyringSupported()
Exemplo n.º 4
0
import config

if __name__ == '__main__':
    """
    return password.
    """
    cfg = config.Config()
    tools.envLoad(cfg.cronEnvFile())

    profile_id = os.getenv('ASKPASS_PROFILE_ID', '1')
    mode = os.getenv('ASKPASS_MODE', 'local')

    if mode == 'USER':
        prompt = os.getenv('ASKPASS_PROMPT', None)
        pw = password.Password(cfg)
        print(pw.passwordFromUser(None, prompt = prompt))
        sys.exit(0)

    temp_file = os.getenv('ASKPASS_TEMP')
    if temp_file is None:
        #normal mode, get password from module password
        pw = password.Password(cfg)
        print(pw.password(None, profile_id, mode))
        sys.exit(0)

    #temp mode
    fifo = password_ipc.FIFO(temp_file)
    pw = fifo.read(5)
    if pw:
        print(pw)