Stuff
This commit is contained in:
parent
d28c6375c8
commit
ac92458573
8 changed files with 327 additions and 0 deletions
30
update_keys.py
Executable file
30
update_keys.py
Executable file
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env python3
|
||||
import subprocess
|
||||
import hashlib
|
||||
import sys
|
||||
|
||||
destfile = "authkeyfile/authorized_keys"
|
||||
|
||||
p = subprocess.Popen(["./ldap_query.py"], stdout=subprocess.PIPE, stdin=subprocess.PIPE)
|
||||
(po, pr) = p.communicate()
|
||||
if(p.returncode != 0):
|
||||
print("Data from ldap_query.py seems to be invalid. QUIT")
|
||||
sys.exit(1)
|
||||
|
||||
newhash = hashlib.md5(po).hexdigest()
|
||||
#print(newhash)
|
||||
|
||||
try:
|
||||
f = open(destfile, "rb")
|
||||
oldhash = hashlib.md5(f.read()).hexdigest()
|
||||
f.close()
|
||||
# print(oldhash)
|
||||
except:
|
||||
oldhash = None
|
||||
print("cannot open auth key file for read")
|
||||
|
||||
if newhash != oldhash:
|
||||
# print("Updating file")
|
||||
f = open(destfile, "wb")
|
||||
f.write(po)
|
||||
f.close()
|
Loading…
Add table
Add a link
Reference in a new issue