fix: a failing user directory or token database no longer leaves the tunnels down.
Release / release (push) Failing after 15m34s
Release / release (push) Failing after 15m34s
This commit is contained in:
1 parent
caf0e334f0
commit
4f1aa282f6
2 files changed
+28
-13
No files matched your search
@@ -1,3 +1,13 @@
|
|||||||
|
vpn-router (0.7.1-1) unstable; urgency=medium
|
||||||
|
|
||||||
|
fix: a failing user directory or token database no longer leaves the tunnels down.
|
||||||
|
|
||||||
|
* vpn-router-setup brings up strongSwan and WireGuard before it provisions
|
||||||
|
the user directory and the token database. A failure of either no
|
||||||
|
longer stops the other steps; setup reports it and fails at the end.
|
||||||
|
|
||||||
|
-- Slawomir Koszewski <slawek@koszewscy.waw.pl> Sun, 25 Oct 2026 02:00:00 +0200
|
||||||
|
|
||||||
vpn-router (0.7.0-1) unstable; urgency=medium
|
vpn-router (0.7.0-1) unstable; urgency=medium
|
||||||
|
|
||||||
feature: users sign in to the web service, and only members of admins manage the router.
|
feature: users sign in to the web service, and only members of admins manage the router.
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ import sys
|
|||||||
|
|
||||||
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)))
|
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)))
|
||||||
|
|
||||||
import ldap
|
|
||||||
|
|
||||||
import vpnrouter
|
import vpnrouter
|
||||||
import vpnrouter_auth
|
import vpnrouter_auth
|
||||||
import vpnrouter_ldap
|
import vpnrouter_ldap
|
||||||
@@ -349,22 +347,26 @@ def manage_wireguard(ctx, changed):
|
|||||||
|
|
||||||
|
|
||||||
def manage_directory():
|
def manage_directory():
|
||||||
"""Provision the user directory in slapd, whether or not a P2S system is configured."""
|
"""Provision the user directory in slapd, whether or not a P2S system is configured; the problem, or ''."""
|
||||||
if vpnrouter_ldap.ensure_services() or not unit_is_active('slapd'):
|
if vpnrouter_ldap.ensure_services() or not unit_is_active('slapd'):
|
||||||
run(['systemctl', 'restart', 'slapd'])
|
result = run(['systemctl', 'restart', 'slapd'], check=False)
|
||||||
|
if result.returncode != 0:
|
||||||
|
return f'slapd cannot be restarted: {result.stderr.strip()}'
|
||||||
try:
|
try:
|
||||||
vpnrouter_ldap.provision()
|
vpnrouter_ldap.provision()
|
||||||
except ldap.LDAPError as exc:
|
except Exception as exc:
|
||||||
fail(f'the user directory cannot be provisioned: {exc}')
|
return f'the user directory cannot be provisioned: {exc!r}'
|
||||||
|
return ''
|
||||||
|
|
||||||
|
|
||||||
def manage_tokens(cfg):
|
def manage_tokens(cfg):
|
||||||
"""Make the web service's signing key, and the database of its refresh tokens unless web.database names one."""
|
"""Make the web service's signing key, and the database of its refresh tokens unless web.database names one; the problem, or ''."""
|
||||||
vpnrouter_auth.ensure_key()
|
|
||||||
try:
|
try:
|
||||||
|
vpnrouter_auth.ensure_key()
|
||||||
vpnrouter_auth.provision(cfg)
|
vpnrouter_auth.provision(cfg)
|
||||||
except OSError as exc:
|
except Exception as exc:
|
||||||
fail(f'the token database cannot be provisioned: {exc}')
|
return f'the token database cannot be provisioned: {exc!r}'
|
||||||
|
return ''
|
||||||
|
|
||||||
|
|
||||||
def manage_openvpn(ctx, changed):
|
def manage_openvpn(ctx, changed):
|
||||||
@@ -473,10 +475,11 @@ def main():
|
|||||||
elif rules_changed:
|
elif rules_changed:
|
||||||
run(['ufw', 'reload'], check=False)
|
run(['ufw', 'reload'], check=False)
|
||||||
|
|
||||||
manage_directory()
|
|
||||||
manage_tokens(cfg)
|
|
||||||
manage_strongswan(ctx, changed)
|
manage_strongswan(ctx, changed)
|
||||||
manage_wireguard(ctx, changed)
|
manage_wireguard(ctx, changed)
|
||||||
|
|
||||||
|
# The tunnels are up before the directory and the tokens, whose problems end setup only after every other step.
|
||||||
|
problems = [problem for problem in (manage_directory(), manage_tokens(cfg)) if problem]
|
||||||
manage_openvpn(ctx, changed)
|
manage_openvpn(ctx, changed)
|
||||||
|
|
||||||
if 'resolved' in changed:
|
if 'resolved' in changed:
|
||||||
@@ -485,7 +488,9 @@ def main():
|
|||||||
run_platform_setup(cfg, ctx)
|
run_platform_setup(cfg, ctx)
|
||||||
refresh_docker_rules()
|
refresh_docker_rules()
|
||||||
refresh_web(cfg, ctx)
|
refresh_web(cfg, ctx)
|
||||||
return 0
|
for problem in problems:
|
||||||
|
print(f'vpn-router: error: {problem}', file=sys.stderr)
|
||||||
|
return 1 if problems else 0
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
Reference in new issue
Block a user