Check a keyid for membership in a autosign directory.
322706
def check_autosign_dir(self, keyid):
        '''
        
        '''
        autosign_dir = os.path.join(self.opts['pki_dir'], 'minions_autosign')

        # cleanup expired files
        expire_minutes = self.opts.get('autosign_timeout', 120)
        if expire_minutes > 0:
            min_time = time.time() - (60 * int(expire_minutes))
            for root, dirs, filenames in salt.utils.path.os_walk(autosign_dir):
                for f in filenames:
                    stub_file = os.path.join(autosign_dir, f)
                    mtime = os.path.getmtime(stub_file)
                    if mtime < min_time:
                        log.warning('Autosign keyid expired %s', stub_file)
                        os.remove(stub_file)

        stub_file = os.path.join(autosign_dir, keyid)
        if not os.path.exists(stub_file):
            return False
        os.remove(stub_file)
        return True
1252910
def get_key_auth_cb(key_filepath):
    """"""

    def auth_cb(ssh):
        key = ssh_pki_import_privkey_file(key_filepath)
        ssh.userauth_publickey(key)

    return auth_cb
712083
def has_key(self, key):
        """"""
        k = self._lowerOrReturn(key)
        return k in self.data
1055243
def get(key, default=-1):
        """"""
        if isinstance(key, int):
            return Registration(key)
        if key not in Registration._member_map_:
            extend_enum(Registration, key, default)
        return Registration[key]
707023
def contains(bank, key, cachedir):
    '''
    
    '''
    if key is None:
        base = os.path.join(cachedir, os.path.normpath(bank))
        return os.path.isdir(base)
    else:
        keyfile = os.path.join(cachedir, os.path.normpath(bank), '{0}.p'.format(key))
        return os.path.isfile(keyfile)
1167879
def _verify(self):
        """"""
        if not self.keyid:
            raise ValueError('No GPG key specified for signing, did you mean to use --no-sign?')
        sign = self.gpg.sign('', keyid=self.keyid)
        if 'secret key not available' in sign.stderr:
            raise ValueError('Key not found')
        elif 'NEED_PASSPHRASE' in sign.stderr:
            self.passphrase = getpass.getpass('Passphrase for GPG key: ')
80803
def verify(backup_path, fast):
    """"""
    from PyHardLinkBackup.phlb.verify import verify_backup

    verify_backup(backup_path, fast)
655370
def check_key(self, key: str) -> bool:
        
        keys = self.get_keys()
        return key in keys
10634
def verify(self, sig, msg):
        '''
        
        '''
        return lib.ed25519_VerifySignature(
            sig, self.__verifyingkey, msg, len(msg)) == 1
863977
def detect_member(row, key):
    '''  '''
    (target, tkey, tvalue) = dict_crawl(row, key)
    if target:
        return True
    return False
804633
def check_key(self, key):
        
        if self.key_size and len(key) not in self.key_size:
            raise TypeError('invalid key size %s, must be one of %s' %
                            (len(key), self.key_size))
90353
def _authGetDBusCookie(self, cookie_context, cookie_id):
        
        # XXX   Ensure we obtain the correct directory for the
        #       authenticating user and that that user actually
        #       owns the keyrings directory

        if self.cookie_dir is None:
            cookie_dir = os.path.expanduser('~/.dbus-keyrings')
        else:
            cookie_dir = self.cookie_dir

        dstat = os.stat(cookie_dir)

        if dstat.st_mode & 0x36:  # 066
            raise Exception('User keyrings directory is writeable by other users. Aborting authentication')

        import pwd
        if dstat.st_uid != pwd.getpwuid(os.geteuid()).pw_uid:
            raise Exception('Keyrings directory is not owned by the current user. Aborting authentication!')
        
        f = open(os.path.join(cookie_dir, cookie_context), 'r')

        try:
            for line in f:
                try:
                    k_id, k_time, k_cookie_hex = line.split()
                    if k_id == cookie_id:
                        return k_cookie_hex
                except:
                    pass
        finally:
            f.close()
1129427
def check_password(self, passwd, group):
        # This provides authentication via CADC.
        """"""
        return gms.isMember(self.login, passwd, group)
1155599
def get_from_human_key(self, key):
        """"""
        if key in self._identifier_map:
            return self._identifier_map[key]
        raise KeyError(key)
701327
def verify_directory(dir):
    """"""

    tries = 0

    while not os.path.exists(dir):
        try:
            tries += 1
            os.makedirs(dir, compat.octal("0775"))
        except:
            if tries > 5:
                raise
25430
def auto_key():
    """"""
    import uuid
    import time
    import random
    import hashlib

    node = uuid.getnode()

    h = hashlib.md5()
    h.update(str("%s" % node).encode('utf-8'))
    key1 = h.hexdigest()

    time.sleep(random.uniform(0, 0.5))
    node = uuid.getnode()

    h = hashlib.md5()
    h.update(str("%s" % node).encode('utf-8'))
    key2 = h.hexdigest()

    time.sleep(random.uniform(0, 0.5))
    node = uuid.getnode()

    h = hashlib.md5()
    h.update(str("%s" % node).encode('utf-8'))
    key3 = h.hexdigest()

    if key1 == key2 and key2 == key3:
        return key1

    return False
507410
def contains(bank, key):
    '''
    
    '''
    _init_client()
    etcd_key = '{0}/{1}/{2}'.format(path_prefix, bank, key)
    try:
        r = client.read(etcd_key)
        # return True for keys, not dirs
        return r.dir is False
    except etcd.EtcdKeyNotFound:
        return False
    except Exception as exc:
        raise SaltCacheError(
            'There was an error getting the key, {0}: {1}'.format(
                etcd_key, exc
            )
        )