Archived
1
0
Fork 0
This repository has been archived on 2024-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
smartlock/Core.py

19 lines
766 B
Python

import shelve, subprocess
from os.path import isfile
class Main:
def __init__(self):
if not isfile("Settings.conf"):
subprocess.check_call(["sudo", "yhsm-generate-keys", "-D", "/etc/yubico/yhsm/keys.json", "--key-handle", "1", "--start-public-id", "interncccccc", "-c", "10"])
out = str(subprocess.check_output(["sudo", "ykval-gen-clients", "--urandom", "10"]))
out = out[2:-1].split("\\n")
keys = dict()
for i in out:
id = i.find(",")
keys[i[:id]] = i[id:] #Risque d'y avoir un \n ?
with shelve.open("Settings.conf") as settings:
settings["keys"] = keys
settings["register"] = list()
else:
pass