summaryrefslogtreecommitdiff
path: root/src/conf_mode
diff options
context:
space:
mode:
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-xsrc/conf_mode/vpn_l2tp.py9
-rwxr-xr-xsrc/conf_mode/vpn_sstp.py34
2 files changed, 21 insertions, 22 deletions
diff --git a/src/conf_mode/vpn_l2tp.py b/src/conf_mode/vpn_l2tp.py
index a8b183bef..06803e7e0 100755
--- a/src/conf_mode/vpn_l2tp.py
+++ b/src/conf_mode/vpn_l2tp.py
@@ -364,12 +364,9 @@ def generate(l2tp):
def apply(l2tp):
if not l2tp:
call('systemctl stop accel-ppp@l2tp.service')
-
- if os.path.exists(l2tp_conf):
- os.unlink(l2tp_conf)
-
- if os.path.exists(l2tp_chap_secrets):
- os.unlink(l2tp_chap_secrets)
+ for file in [l2tp_chap_secrets, l2tp_conf]:
+ if os.path.exists(file):
+ os.unlink(file)
return None
diff --git a/src/conf_mode/vpn_sstp.py b/src/conf_mode/vpn_sstp.py
index 438731972..7c96241b1 100755
--- a/src/conf_mode/vpn_sstp.py
+++ b/src/conf_mode/vpn_sstp.py
@@ -259,21 +259,22 @@ def verify(sstp):
raise ConfigError('SSTP local auth mode requires local users to be configured!')
for user in sstp['local_users']:
+ username = user['name']
if not user['password']:
- raise ConfigError(f"Password required for user {user['name']}")
+ raise ConfigError(f'Password required for local user "{username}"')
# if up/download is set, check that both have a value
if user['upload'] and not user['download']:
- raise ConfigError(f"Download speed value required for user {user['name']}")
+ raise ConfigError(f'Download speed value required for local user "{username}"')
if user['download'] and not user['upload']:
- raise ConfigError(f"Upload speed value required for user {user['name']}")
+ raise ConfigError(f'Upload speed value required for local user "{username}"')
if not sstp['client_ip_pool']:
- raise ConfigError("Client IP subnet required")
+ raise ConfigError('Client IP subnet required')
if not sstp['client_gateway']:
- raise ConfigError("Client gateway IP address required")
+ raise ConfigError('Client gateway IP address required')
if len(sstp['dnsv4']) > 2:
raise ConfigError('Not more then two IPv4 DNS name-servers can be configured')
@@ -282,21 +283,25 @@ def verify(sstp):
raise ConfigError('One or more SSL certificates missing')
if not os.path.exists(sstp['ssl_ca']):
- raise ConfigError(f"CA cert file {sstp['ssl_ca']} does not exist")
+ file = sstp['ssl_ca']
+ raise ConfigError(f'SSL CA certificate file "{file}" does not exist')
if not os.path.exists(sstp['ssl_cert']):
- raise ConfigError(f"SSL cert file {sstp['ssl_cert']} does not exist")
+ file = sstp['ssl_cert']
+ raise ConfigError(f'SSL public key file "{file}" does not exist')
if not os.path.exists(sstp['ssl_key']):
- raise ConfigError(f"SSL key file {sstp['ssl_key']} does not exist")
+ file = sstp['ssl_key']
+ raise ConfigError(f'SSL private key file "{file}" does not exist')
if sstp['auth_mode'] == 'radius':
if len(sstp['radius_server']) == 0:
- raise ConfigError("RADIUS authentication requires at least one server")
+ raise ConfigError('RADIUS authentication requires at least one server')
for radius in sstp['radius_server']:
if not radius['key']:
- raise ConfigError(f"Missing RADIUS secret for server {{ radius['key'] }}")
+ server = radius['server']
+ raise ConfigError(f'Missing RADIUS secret key for server "{{ server }}"')
def generate(sstp):
if not sstp:
@@ -321,12 +326,9 @@ def generate(sstp):
def apply(sstp):
if not sstp:
call('systemctl stop accel-ppp@sstp.service')
-
- if os.path.exists(sstp_conf):
- os.unlink(sstp_conf)
-
- if os.path.exists(sstp_chap_secrets):
- os.unlink(sstp_chap_secrets)
+ for file in [sstp_chap_secrets, sstp_conf]:
+ if os.path.exists(file):
+ os.unlink(file)
return None