summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2016-01-01 23:51:34 +0100
committermakefu <github@syntax-fehler.de>2016-01-01 23:51:34 +0100
commit0a3905e101326382c1be51f519f6086e1bb1d955 (patch)
tree87f44e2cc16cf7f11fac4049ee687da165fd8603
parent3903ee56c081a02b2864dba0fee486d6b49139d2 (diff)
build-host: add --create-passwords
-rw-r--r--build-stuff/build-host.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/build-stuff/build-host.py b/build-stuff/build-host.py
index 6e7b435..40fbc20 100644
--- a/build-stuff/build-host.py
+++ b/build-stuff/build-host.py
@@ -123,11 +123,17 @@ location via cli options (--help)")
log.error(__doc__)
sys.exit(1)
-def create_passwords(sec):
+def create_passwords(sec,usernames):
import crypt
- with open(path_join(sec,"hashedPasswords.nix")):
- #python3 -c 'import crypt; print(crypt.crypt("test",
- #crypt.mksalt(crypt.METHOD_SHA512)))'
+ from getpass import getpass
+ with open(path_join(sec,"hashedPasswords.nix"),"w+") as f:
+ f.write("{\n")
+ for usr in usernames:
+ # TODO: do not block, set password via another channel
+ pw = getpass("Password for {}:".format(usr))
+ crypted = crypt.crypt(pw, crypt.mksalt(crypt.METHOD_SHA512))
+ f.write(' {} = "{}";\n'.format(usr,crypted))
+ f.write("}\n")
def main():
@@ -155,7 +161,8 @@ def main():
write_stockholm_1systems(ret,stockholm_dir)
print_stockholm_krebs_entry(ret)
- pass
+ if args["--create-passwords"]:
+ create_passwords(host_secrets,["root",username])
if __name__ == '__main__':
main()