mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-27 10:44:33 +00:00
openvpn: Apply empty file check to private key also
When downloading user's profile, if user's private key is empty, regenerate user's key. Minor styling fixes too.
This commit is contained in:
parent
fcd2499092
commit
f9bd2542a7
@ -148,8 +148,8 @@ def _create_certificates():
|
|||||||
subprocess.check_call(['/usr/share/easy-rsa/clean-all'], **COMMON_ARGS)
|
subprocess.check_call(['/usr/share/easy-rsa/clean-all'], **COMMON_ARGS)
|
||||||
subprocess.check_call(['/usr/share/easy-rsa/pkitool', '--initca'],
|
subprocess.check_call(['/usr/share/easy-rsa/pkitool', '--initca'],
|
||||||
**COMMON_ARGS)
|
**COMMON_ARGS)
|
||||||
subprocess.check_call(['/usr/share/easy-rsa/pkitool', '--server', 'server'],
|
subprocess.check_call(['/usr/share/easy-rsa/pkitool', '--server',
|
||||||
**COMMON_ARGS)
|
'server'], **COMMON_ARGS)
|
||||||
subprocess.check_call(['/usr/share/easy-rsa/build-dh'], **COMMON_ARGS)
|
subprocess.check_call(['/usr/share/easy-rsa/build-dh'], **COMMON_ARGS)
|
||||||
|
|
||||||
|
|
||||||
@ -164,7 +164,8 @@ def subcommand_get_profile(arguments):
|
|||||||
user_certificate = USER_CERTIFICATE_PATH.format(username=username)
|
user_certificate = USER_CERTIFICATE_PATH.format(username=username)
|
||||||
user_key = USER_KEY_PATH.format(username=username)
|
user_key = USER_KEY_PATH.format(username=username)
|
||||||
|
|
||||||
if not _is_non_empty_file(user_certificate) or not os.path.isfile(user_key):
|
if not _is_non_empty_file(user_certificate) or \
|
||||||
|
not _is_non_empty_file(user_key):
|
||||||
subprocess.check_call(['/usr/share/easy-rsa/pkitool', username],
|
subprocess.check_call(['/usr/share/easy-rsa/pkitool', username],
|
||||||
**COMMON_ARGS)
|
**COMMON_ARGS)
|
||||||
|
|
||||||
@ -186,8 +187,8 @@ def _read_file(filename):
|
|||||||
|
|
||||||
|
|
||||||
def _is_non_empty_file(filepath):
|
def _is_non_empty_file(filepath):
|
||||||
|
"""Return wheather a file exists and is not zero size."""
|
||||||
return os.path.isfile(filepath) and os.path.getsize(filepath) > 0
|
return os.path.isfile(filepath) and os.path.getsize(filepath) > 0
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user