Ejemplo n.º 1
0
def create_auth_file():
    import stat, configmanager
    auth_file = configmanager.get_config_dir("auth")
    # Check for auth file and create if necessary
    if not os.path.exists(auth_file):
        fd = open(auth_file, "w")
        fd.flush()
        os.fsync(fd.fileno())
        fd.close()
        # Change the permissions on the file so only this user can read/write it
        os.chmod(auth_file, stat.S_IREAD | stat.S_IWRITE)
Ejemplo n.º 2
0
def create_localclient_account(append=False):
    import configmanager, random

    auth_file = configmanager.get_config_dir("auth")
    if not os.path.exists(auth_file):
        create_auth_file()

    try:
        from hashlib import sha1 as sha_hash
    except ImportError:
        from sha import new as sha_hash
    fd = open(auth_file, "a" if append else "w")
    fd.write(":".join(["localclient", sha_hash(str(random.random())).hexdigest(), str(AUTH_LEVEL_ADMIN)]) + "\n")
    fd.flush()
    os.fsync(fd.fileno())
    fd.close()
Ejemplo n.º 3
0
def create_localclient_account(append=False):
    import configmanager, random
    auth_file = configmanager.get_config_dir("auth")
    if not os.path.exists(auth_file):
        create_auth_file()

    try:
        from hashlib import sha1 as sha_hash
    except ImportError:
        from sha import new as sha_hash
    fd = open(auth_file, "a" if append else "w")
    fd.write(":".join([
        "localclient",
        sha_hash(str(random.random())).hexdigest(),
        str(AUTH_LEVEL_ADMIN)
    ]) + '\n')
    fd.flush()
    os.fsync(fd.fileno())
    fd.close()