Add registration code
This commit is contained in:
parent
9df4ff1af6
commit
a4820fae58
2 changed files with 7 additions and 3 deletions
4
adduser
4
adduser
|
@ -33,9 +33,9 @@ else:
|
||||||
if interactive:
|
if interactive:
|
||||||
password = os.popen('tr -dc A-Za-z0-9 </dev/urandom | head -c 16; echo ""').read()[:-1]
|
password = os.popen('tr -dc A-Za-z0-9 </dev/urandom | head -c 16; echo ""').read()[:-1]
|
||||||
print('Password:', password)
|
print('Password:', password)
|
||||||
else:
|
|
||||||
password = sys.argv[5]
|
|
||||||
hashedpassword = os.popen('slappasswd -s ' + password).read()[:-1]
|
hashedpassword = os.popen('slappasswd -s ' + password).read()[:-1]
|
||||||
|
else:
|
||||||
|
hashedpassword = sys.argv[5]
|
||||||
|
|
||||||
|
|
||||||
# Construct LDIF
|
# Construct LDIF
|
||||||
|
|
6
register
6
register
|
@ -9,7 +9,10 @@ class S(BaseHTTPRequestHandler):
|
||||||
content_length = int(self.headers['Content-Length'])
|
content_length = int(self.headers['Content-Length'])
|
||||||
data = loads(self.rfile.read(content_length).decode('utf-8'))
|
data = loads(self.rfile.read(content_length).decode('utf-8'))
|
||||||
print(data)
|
print(data)
|
||||||
os.system('adduser ' + data['username'] + ' ' + data['firstname'] + ' ' + data['lastname'] + ' ' + data['email'] + ' ' + data['password'] + ' "' + ldap_pass + '"')
|
if data['code'] != code:
|
||||||
|
return
|
||||||
|
hashedpassword = os.popen('slappasswd -s ' + data['password']).read()[:-1]
|
||||||
|
os.system('adduser ' + data['username'] + ' ' + data['firstname'] + ' ' + data['lastname'] + ' ' + data['email'] + ' ' + hashedpassword + ' "' + ldap_pass + '"')
|
||||||
|
|
||||||
self.send_response(200)
|
self.send_response(200)
|
||||||
self.send_header('Content-type', 'text/html')
|
self.send_header('Content-type', 'text/html')
|
||||||
|
@ -21,4 +24,5 @@ def run(server_class=HTTPServer, handler_class=S):
|
||||||
httpd.serve_forever()
|
httpd.serve_forever()
|
||||||
|
|
||||||
ldap_pass = input('LDAP password: ')
|
ldap_pass = input('LDAP password: ')
|
||||||
|
code = input('Registration code: ')
|
||||||
run()
|
run()
|
||||||
|
|
Loading…
Reference in a new issue