def find_paths_with_suid_sgid(root_path):
    """Finds all paths/files which have an suid/sgid bit enabled.

    Starting with the root_path, this will recursively find all paths which
    have an suid or sgid bit set.
    """
    cmd = ['find', root_path, '-perm', '-4000', '-o', '-perm', '-2000',
           '-type', 'f', '!', '-path', '/proc/*', '-print']

    p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    out, _ = p.communicate()
    return set(out.split('\n'))
Finds all paths/files which have an suid/sgid bit enabled.

    Starting with the root_path, this will recursively find all paths which
    have an suid or sgid bit set.