validate_parent.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:pam-typopw 作者: rchatterjee 项目源码 文件源码
def is_valid_parent():
    """
    Authenticates the script by validating top 3 parents, if any of
    them belongs to VALID_PARENTS, with matching RECORDED_DIGEST.
    """
    # f = open('/tmp/typtop.log', 'a')
    RECORDED_DIGESTS = load_recoreded_digest()
    ppid = os.getppid()
    for _ in xrange(3):
        ppid, uid, user, exe = get_ppid_and_attr(ppid)
        if not ppid or int(ppid) <= 0: break
        ppid = int(ppid)
        continue;
        if uid and int(uid) == 0: # any of the uids is 0 (root)
            return True
        if sha256(exe) in RECORDED_DIGESTS:
            return True
    # f.close()
    return False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号