Пример #1
0
def ensureKeyPair():
    from os import chmod
    assertDirectory(authDirectory(),dirMode="700")
    if PY3:
        perm=eval("0o700")
    else:
        perm=eval("0700")

    if not path.exists(myPrivateKeyFile()) and not path.exists(myPublicKeyFile()):
        warning("No key pair in",authDirectory()," .... Creating")
        pubkey, privkey = keygen(2 ** 64)
        open(myPublicKeyFile(),"w").write(key_to_str(pubkey))
        open(myPrivateKeyFile(),"w").write(key_to_str(privkey))

    chmod(myPublicKeyFile(),perm)
    chmod(myPrivateKeyFile(),perm)

    if not path.exists(myAuthenticatedKeysFile()):
        f=open(myAuthenticatedKeysFile(),"w")
        f.close()
    chmod(myAuthenticatedKeysFile(),perm)
Пример #2
0
def myAuthenticatedKeysFile():
    return path.join(authDirectory(), "myAuthenticatedKeys")
Пример #3
0
def myPublicKeyFile():
    return path.join(authDirectory(), "publicKey")
Пример #4
0
def myPrivateKeyFile():
    return path.join(authDirectory(), "privateKey")