Ubuntu Pastebin

Paste from smoser at Tue, 26 Jul 2016 17:59:09 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
key_path = "/home/smoser/.ssh/authorized_keys" # assume that is set
key_dir = os.path.dirname(key_path)

if os.path.isdir(key_dir):
    if is_world_writable(key_dir):
        raise RunTimeError("WHAT! %s is world writable!" % key_dir)
    else:
        LOG.debug("leaving existing key directory %s alone" % key_dir)
elif os.path.exists(key_dir):
    raise RunTimeError("%s existed as a non-directory." % key_dir)
else:
    create with 0700 perms as before
Download as text