Cleanup #46484 » 0001-add-sepia-new-client.patch
new-client | ||
---|---|---|
#!/usr/bin/python
|
||
#!/usr/bin/python3
|
||
# How to set up a client (on Ubuntu/Debian):
|
||
#
|
||
... | ... | |
if not re.match(r'^[a-zA-Z0-9_.@-]+$', user):
|
||
raise SystemExit('new-client: Invalid characters in username')
|
||
salt = base64.b64encode(os.urandom(16)).rstrip('=')
|
||
secret = base64.b64encode(os.urandom(64)).rstrip('=')
|
||
salt = base64.b64encode(os.urandom(16))
|
||
secret = base64.b64encode(os.urandom(64))
|
||
inner = hashlib.new('sha256')
|
||
inner.update(salt)
|
||
... | ... | |
outer.update(inner.digest())
|
||
outer.update(salt)
|
||
hashed = outer.hexdigest()
|
||
secret = secret.decode("utf-8").rstrip("==")
|
||
salt = salt.decode("utf-8").rstrip("==")
|
||
with file('secret', 'wb') as f:
|
||
os.fchmod(f.fileno(), 0600)
|
||
with open('secret', 'w') as f:
|
||
os.chmod(f.fileno(), 0o600)
|
||
f.write('{user}\n{secret}\n'.format(user=user, secret=secret))
|
||
base = os.path.basename(path)
|
||
os.symlink(os.path.join(base, 'client.conf'), '../sepia.conf')
|
||
print ' Please submit the following line to the OpenVPN admin:'
|
||
print
|
||
print user, salt, hashed
|
||
print("Please submit the following line to the OpenVPN admin:")
|
||
print("")
|
||
print(user, salt, hashed)
|
||
print
|