feature: the VPN, the router, the name server and WebDAV are components switched on the System tab and installed on demand, Caddy from the Ubuntu archive is a dependency and serves every HTTP and HTTPS port, HTTPS is chosen at install, its certificate is of the Servers Issuing CA or self-signed by default, of ACME or of another CA, the issuing CAs are in one tab, a locked account is unlocked again, the name of a CA is fixed once the CA exists, and a run of setup is no longer cut short by a change.
Release / release (push) Failing after 8s

This commit is contained in:
slawek committed 2026-11-24 05:51:27 +01:00
1 parent a649331aa2
commit a7bfabcb89
97 files changed
+4498 -1834

No files matched your search

@@ -12,8 +12,10 @@ import os
import pathlib
import re
import shutil
import subprocess
import sys
import tempfile
import time
import urllib.parse
import jinja2
@@ -27,12 +29,21 @@ import linuxmanager_ldap
import linuxmanager_pki
import linuxmanager_platforms
import linuxmanager_status
from linuxmanager_net import DEFAULT_LISTEN, LISTEN_CHOICES, LOOPBACK, ConfigError, detect_interfaces, interface_addresses, ip_output
from linuxmanager_net import DEFAULT_LISTEN, LISTEN_CHOICES, LOOPBACK, MANAGER_LOOPBACK_PORT, METRICS_LOOPBACK_PORT, \
WEB_LOOPBACK_PORT, ConfigError, detect_interfaces, interface_addresses, ip_output
CONFIG_FILE = pathlib.Path('/etc/linux-manager/linux-manager.json')
CONFIG_LOCK = pathlib.Path('/run/linux-manager/config.lock')
#: What setup resolved and runs, for the web service (setup's refresh_web).
WEB_STATE = pathlib.Path('/run/linux-manager/web.json')
#: The unit of linux-manager-setup, which request_setup runs.
SETUP_UNIT = 'linux-manager-setup.service'
#: The lock under which a run of setup is requested and a run of setup decides whether to run again.
SETUP_LOCK = pathlib.Path('/run/linux-manager/setup.lock')
#: The lock a run of setup holds while it applies the configuration.
SETUP_RUNNING = pathlib.Path('/run/linux-manager/setup.running')
#: The file that asks a run of setup in progress to run once more when it ends.
SETUP_REQUEST = pathlib.Path('/run/linux-manager/setup.request')
TEMPLATE_DIR = pathlib.Path('/usr/share/linux-manager/templates')
SWANCTL_CONF_D = pathlib.Path('/etc/swanctl/conf.d')
@@ -68,14 +79,17 @@ SCHEMA = {
'status_content': 'basic', 'shell': False, 'shell_idle_minutes': 15, 'shell_auth_timeout': 15,
'log_files': []},
'ssh': {'ldap_login': False},
'https': {'enabled': True, 'email': '', 'web_port': 7444, 'manager_port': 7443, 'caddy_source': 'ubuntu',
'acme_staging': False},
'https': {'enabled': True, 'email': '', 'web_port': 7444, 'manager_port': 7443,
'disable_auto_redirect': False, 'acme_staging': False, 'certificate': 'self-signed', 'self_signed_days': 365,
'acme_provider': 'letsencrypt', 'acme_url': '', 'acme_eab_key_id': '', 'acme_eab_mac_key': '',
'zerossl_api_key': ''},
'oidc': {'enabled': False},
'sites': {'enabled': False, 'upload_max_mb': 512, 'webdav': False, 'webdav_port': 7445},
'dns': {'enabled': False, 'secondary': '', 'listen': 'external', 'ttl': 300},
'pki': {'root_name': 'Linux Manager Root CA', 'root_days': 7300, 'ca_days': 3650, 'key': 'rsa-4096',
'crl_days': 7, 'root_crl_days': 180, 'publish': ['http'], 'p2s_name': 'Linux Manager VPN CA',
's2s_name': 'Linux Manager Site-to-Site CA', 'issuing_cas': {}, 'templates': {},
's2s_name': 'Linux Manager Site-to-Site CA', 'servers_name': 'Linux Manager Servers CA',
'issuing_cas': {}, 'templates': {},
'extended_key_usages': {}, 'root': 'local', 'simple_ca_url': ''},
'metrics': {'enabled': True, 'listen': 'internal', 'port': 9464, 'https_port': 9465, 'service_account': 'metrics',
'otlp_endpoint': '', 'otlp_username': '', 'otlp_password': '',
@@ -143,6 +157,16 @@ LOG_FILES_MAX = 32
#: The port rclone serves WebDAV on, on the loopback address, behind Caddy.
WEBDAV_LOOPBACK_PORT = 7446
#: The installable components, managed on the Manager's System tab: name -> (section, setting) of their switch and the
#: packages linux-manager-install@<name> installs from the Ubuntu archive while the switch is on.
STRONGSWAN_PACKAGES = ('strongswan-swanctl', 'charon-systemd', 'libstrongswan-extra-plugins', 'libcharon-extra-plugins')
COMPONENTS = {
'vpn': (('vpn', 'enabled'), (*STRONGSWAN_PACKAGES, 'openvpn', 'openvpn-auth-ldap', 'wireguard-tools', 'dnsmasq-base')),
'router': (('router', 'enabled'), STRONGSWAN_PACKAGES),
'dns': (('dns', 'enabled'), ('pdns-server', 'pdns-backend-pgsql')),
'webdav': (('sites', 'webdav'), ('rclone',)),
}
#: The largest sites.upload_max_mb, 10 GiB.
UPLOAD_MAX_MB = 10240
@@ -167,17 +191,20 @@ BOOTSTRAP_PORTS = (17081,)
MANAGER_CONFIG = pathlib.Path('/etc/linux-manager/manager.json')
MANAGER_PORT = 7080
#: Where linux-manager-setup installs Caddy from, https.caddy_source: the Ubuntu archive or Caddy's own repository.
CADDY_SOURCES = ('ubuntu', 'upstream')
#: The ACME directory of Let's Encrypt's staging environment, Caddy's only CA while https.acme_staging is true.
ACME_STAGING_CA = 'https://acme-staging-v02.api.letsencrypt.org/directory'
#: Caddy's own repository, which https.caddy_source upstream configures: the source, its signing key and their URLs.
CADDY_APT_SOURCE = pathlib.Path('/etc/apt/sources.list.d/caddy-stable.sources')
CADDY_KEYRING = pathlib.Path('/etc/apt/keyrings/caddy-stable.asc')
CADDY_KEY_URL = 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key'
CADDY_REPOSITORY = 'https://dl.cloudsmith.io/public/caddy/stable/deb/debian'
#: The ACME directory of Let's Encrypt's production CA.
ACME_PRODUCTION_CA = 'https://acme-v02.api.letsencrypt.org/directory'
#: Where the certificate of wan.local_fqdn comes from, https.certificate: ACME, a self-signed certificate, the
#: Servers Issuing CA (servers), or a certificate of another CA, imported; self-signed when not set. A new installation's
#: configuration file has it empty (generate-config) until the first setup chooses ca or self-signed
#: (linuxmanager_pki.provision).
HTTPS_CERTIFICATES = ('acme', 'self-signed', 'ca', 'external')
#: The ACME CA of the server and of the web sites with TLS acme, https.acme_provider.
ACME_PROVIDERS = ('letsencrypt', 'zerossl', 'custom')
#: The key types of the CAs, pki.key, and of the templates.
PKI_KEYS = ('rsa-2048', 'rsa-3072', 'rsa-4096', 'ec-p256', 'ec-p384')
@@ -224,7 +251,7 @@ PKI_TEMPLATES = {
'vpn-server': {'key_usage': ['digital_signature', 'key_encipherment'],
'extended_key_usage': ['server_auth', 'ike_intermediate'], 'subject': 'dns', 'sans': ['dns', 'ip']},
'vpn-user': {'extended_key_usage': ['client_auth'], 'subject': 'name', 'sans': ['dns', 'email']},
'site-to-site': {'key_usage': ['digital_signature', 'key_encipherment'],
'mtls': {'key_usage': ['digital_signature', 'key_encipherment'],
'extended_key_usage': ['server_auth', 'client_auth'], 'subject': 'dns', 'sans': ['dns', 'ip']},
'server': {'key_usage': ['digital_signature', 'key_encipherment'], 'extended_key_usage': ['server_auth'],
'subject': 'dns', 'sans': ['dns', 'ip']},
@@ -234,8 +261,11 @@ PKI_TEMPLATES = {
#: The templates only the server issues: its VPN server certificate and the users' certificates.
ROUTER_TEMPLATES = ('vpn-server', 'vpn-user')
#: The built-in issuing CAs: name -> the pki option of the common name and the templates the CA issues.
BUILTIN_CAS = {'p2s': ('p2s_name', ['vpn-server', 'vpn-user']), 's2s': ('s2s_name', ['site-to-site'])}
#: The built-in issuing CAs: name -> the pki option of the common name and the templates the CA issues: the VPN, the
#: site-to-site connections, and the Servers Issuing CA of mTLS certificates, which also signs the server's HTTPS
#: certificate.
BUILTIN_CAS = {'p2s': ('p2s_name', ['vpn-server', 'vpn-user']), 's2s': ('s2s_name', ['mtls']),
'servers': ('servers_name', ['mtls'])}
#: A general-purpose issuing CA of pki.issuing_cas: option -> default, the type of the default being the required type.
ISSUING_CA = {'name': '', 'templates': [], 'acme': False}
@@ -350,6 +380,45 @@ def config_lock():
yield
def setup_lock():
"""The open SETUP_LOCK, held; closing it releases the lock."""
SETUP_LOCK.parent.mkdir(parents=True, exist_ok=True)
handle = open(SETUP_LOCK, 'a', encoding='utf-8')
fcntl.flock(handle, fcntl.LOCK_EX)
return handle
def request_setup(wait=False):
"""Have linux-manager-setup apply the configuration; with wait, True when it has applied it and its last run
succeeded, without wait, True when the run was requested.
A run in progress is not cut short: it holds SETUP_RUNNING, and the request, SETUP_REQUEST, has it run once more
when it ends, however many requests it got. Without a run in progress the unit is restarted. The request is made
under SETUP_LOCK, under which a run of setup also decides whether to end, so no request is missed.
"""
with setup_lock():
SETUP_REQUEST.touch()
with open(SETUP_RUNNING, 'a', encoding='utf-8') as running:
try:
fcntl.flock(running, fcntl.LOCK_EX | fcntl.LOCK_NB)
idle = True
except BlockingIOError:
idle = False
if idle:
restart = subprocess.run(['systemctl', 'restart', '--no-block', SETUP_UNIT], capture_output=True)
if restart.returncode != 0:
return False
# The unit's start job, the restarted run or the run in progress with its further runs, is waited for.
while wait:
state = subprocess.run(['systemctl', 'show', '-p', 'Job,ActiveState,Result', SETUP_UNIT],
capture_output=True, text=True).stdout
values = dict(line.partition('=')[::2] for line in state.splitlines())
if not values.get('Job') and values.get('ActiveState') != 'activating':
return values.get('ActiveState') == 'active' and values.get('Result') == 'success'
time.sleep(1)
return True
def save_config(data):
"""Write the settings to the configuration file, indented, with mode 0600, replacing it in one step.
@@ -366,6 +435,19 @@ def save_config(data):
raise
def choose_https_certificate(cfg, ctx, source):
"""Write https.certificate, empty until then, as source into the configuration file, and into cfg and ctx for the
rest of the run: the first setup's choice of the server's HTTPS certificate."""
with config_lock():
data = read_settings()
section = data.get('https')
data['https'] = {**(section if isinstance(section, dict) else {}), 'certificate': source}
save_config(data)
cfg['https']['certificate'] = source
ctx['https_certificate'] = source
warn(f'https.certificate is set to {source}, chosen by the first setup')
def _split_list(value):
return [item.strip() for item in value.split(',') if item.strip()]
@@ -586,9 +668,24 @@ def validate(cfg):
if not item.startswith('/') or '/../' in f'{item}/':
raise ConfigError(f'web.log_files: {item!r} is not an absolute path')
caddy_source = _get(cfg, 'https', 'caddy_source')
if caddy_source not in CADDY_SOURCES:
raise ConfigError(f'https.caddy_source: {caddy_source!r} is not one of {", ".join(CADDY_SOURCES)}')
if _get(cfg, 'https', 'certificate') not in ('', *HTTPS_CERTIFICATES):
raise ConfigError(f'https.certificate: {_get(cfg, "https", "certificate")!r} is not one of '
f'{", ".join(HTTPS_CERTIFICATES)}, or empty for the next setup to choose')
if not 1 <= _get(cfg, 'https', 'self_signed_days') <= 3650:
raise ConfigError('https.self_signed_days must be 1 to 3650 days')
provider = _get(cfg, 'https', 'acme_provider')
if provider not in ACME_PROVIDERS:
raise ConfigError(f'https.acme_provider: {provider!r} is not one of {", ".join(ACME_PROVIDERS)}')
acme_url = _get(cfg, 'https', 'acme_url')
if provider == 'custom' and not acme_url:
raise ConfigError('https.acme_url is required while https.acme_provider is custom')
if acme_url:
parts = urllib.parse.urlsplit(acme_url)
if parts.scheme != 'https' or not parts.hostname or parts.fragment:
raise ConfigError('https.acme_url must be an https:// URL without a fragment')
for option in ('email', 'acme_url', 'acme_eab_key_id', 'acme_eab_mac_key', 'zerossl_api_key'):
if any(character.isspace() or character in '{}"' for character in _get(cfg, 'https', option)):
raise ConfigError(f'https.{option} must not hold spaces, braces or quotes')
if _get(cfg, 'oidc', 'enabled') and not (_get(cfg, 'web', 'enabled') and _get(cfg, 'https', 'enabled')
and _get(cfg, 'wan', 'local_fqdn')):
@@ -634,7 +731,7 @@ def validate(cfg):
f'addresses is the resolver of the remote access clients (p2s.dns_listen {resolver_listen}) '
'while p2s.enabled, openvpn.enabled or wireguard.enabled is true')
for option in ('root_name', 'p2s_name', 's2s_name'):
for option in ('root_name', 'p2s_name', 's2s_name', 'servers_name'):
value = _get(cfg, 'pki', option)
if not value or len(value) > CA_NAME_MAX or not value.isprintable():
raise ConfigError(f'pki.{option} must have 1 to {CA_NAME_MAX} printable characters')
@@ -703,8 +800,8 @@ def validate(cfg):
prefix = f'pki.issuing_cas.{name}'
if not PKI_NAME.match(name) or name in BUILTIN_CAS or name in ('root', 'upstream'):
raise ConfigError(f'{prefix}: an issuing CA name starts with a lowercase letter and has at most 31 '
f'lowercase letters, digits and hyphens, and is not root, upstream, '
f'{" or ".join(BUILTIN_CAS)}')
f'lowercase letters, digits and hyphens, and is not root, upstream or '
f'{", ".join(BUILTIN_CAS)}')
if not isinstance(authority, dict):
raise ConfigError(f'{prefix} must be {TYPE_NAMES[dict]}')
_check_options(authority, ISSUING_CA, prefix)
@@ -727,6 +824,15 @@ def validate(cfg):
taken = {web_port: 'web.port', ACME_HTTP_PORT: 'the HTTP challenge',
https_ports[0]: 'https.web_port', https_ports[1]: 'https.manager_port'}
# Caddy serves the Manager's plain HTTP port and calls the services on their loopback ports.
for port, owner in ((manager_port(), f"the Manager's port in {MANAGER_CONFIG}"),
(WEB_LOOPBACK_PORT, 'the web service behind Caddy'),
(MANAGER_LOOPBACK_PORT, 'the Manager behind Caddy'),
(METRICS_LOOPBACK_PORT, 'the metrics service behind Caddy'),
(WEBDAV_LOOPBACK_PORT, 'WebDAV behind Caddy')):
if port in taken:
raise ConfigError(f'{taken[port]}: {port} is the port of {owner}')
taken[port] = owner
if 'https-default' in publish:
if HTTPS_DEFAULT_PORT in taken:
raise ConfigError(f'pki.publish: https-default takes port {HTTPS_DEFAULT_PORT}, the port of '
@@ -813,13 +919,12 @@ def validate(cfg):
f'docker.exposed_ports: {item!r} is not a port or a port range')
weight += 2 if ':' in item else 1
first, _, last = item.partition(':')
if _get(cfg, 'https', 'enabled'):
caddy_ports = (ACME_HTTP_PORT, *https_ports, *([HTTPS_DEFAULT_PORT] if 'https-default' in publish else []))
for port in caddy_ports:
if int(first) <= port <= int(last or first):
raise ConfigError(
f'docker.exposed_ports: {item!r} takes port {port}, which Caddy serves while '
'https.enabled is true')
caddy_ports = (web_port, manager_port(), _get(cfg, 'metrics', 'port'),
*((ACME_HTTP_PORT, *https_ports, *([HTTPS_DEFAULT_PORT] if 'https-default' in publish else []))
if _get(cfg, 'https', 'enabled') else ()))
for port in caddy_ports:
if int(first) <= port <= int(last or first):
raise ConfigError(f'docker.exposed_ports: {item!r} takes port {port}, which Caddy serves')
if weight > DOCKER_PORT_LIMIT:
raise ConfigError(
f'docker.exposed_ports: at most {DOCKER_PORT_LIMIT} ports are allowed, '
@@ -847,8 +952,8 @@ def extended_key_usages(cfg):
def issuing_cas(cfg):
"""The issuing CAs, name -> {name, templates, acme, builtin}: p2s and s2s (BUILTIN_CAS) with their common names from
the pki section, then those of pki.issuing_cas, each filled from ISSUING_CA."""
"""The issuing CAs, name -> {name, templates, acme, builtin}: p2s, s2s and servers (BUILTIN_CAS) with their common names
from the pki section, then those of pki.issuing_cas, each filled from ISSUING_CA."""
found = {name: {'name': _get(cfg, 'pki', option), 'templates': list(templates), 'acme': False, 'builtin': True}
for name, (option, templates) in BUILTIN_CAS.items()}
for name, options in cfg['pki']['issuing_cas'].items():
@@ -870,7 +975,8 @@ def pki_base_urls(cfg):
def manager_port():
"""The port of the Manager: port in its settings, or MANAGER_PORT when it is not set or not a port."""
"""The port of the Manager, Caddy's plain HTTP site of it: port in its settings, or MANAGER_PORT when it is not set
or not a port."""
try:
port = json.loads(MANAGER_CONFIG.read_text(encoding='utf-8')).get('port')
except (OSError, ValueError, AttributeError):
@@ -878,6 +984,16 @@ def manager_port():
return port if isinstance(port, int) and not isinstance(port, bool) and 1 <= port <= 65535 else MANAGER_PORT
def manager_listen():
"""The interfaces the firewall opens the Manager's port on: listen in its settings, one of LISTEN_CHOICES, or
DEFAULT_LISTEN when it is not set or not one."""
try:
choice = json.loads(MANAGER_CONFIG.read_text(encoding='utf-8')).get('listen')
except (OSError, ValueError, AttributeError):
return DEFAULT_LISTEN
return choice if choice in LISTEN_CHOICES else DEFAULT_LISTEN
def oidc_issuer(cfg):
"""The issuer of the OpenID Provider: the web service's HTTPS site, without the port when it is HTTPS_DEFAULT_PORT."""
port = _get(cfg, 'https', 'web_port')
@@ -1034,6 +1150,8 @@ def build_context(cfg, public_ip=None):
'mode': _get(cfg, 'general', 'mode') or 'manual',
'router_enabled': _get(cfg, 'router', 'enabled'),
'vpn_enabled': _get(cfg, 'vpn', 'enabled'),
'router_installed': packages_installed(COMPONENTS['router'][1]),
'vpn_installed': packages_installed(COMPONENTS['vpn'][1]),
'wan_iface': ext_iface,
'int_iface': int_iface,
'local_addrs': ', '.join(local_addrs),
@@ -1080,15 +1198,24 @@ def build_context(cfg, public_ip=None):
'ldap_users': linuxmanager_ldap.USERS,
'web_enabled': _get(cfg, 'web', 'enabled'),
'web_port': _get(cfg, 'web', 'port'),
'web_listen': _get(cfg, 'web', 'listen'),
'https_enabled': _get(cfg, 'https', 'enabled'),
'https_email': _get(cfg, 'https', 'email'),
'https_acme_ca': ACME_STAGING_CA if _get(cfg, 'https', 'acme_staging') else '',
'https_certificate': _get(cfg, 'https', 'certificate'),
'https_acme_provider': _get(cfg, 'https', 'acme_provider'),
'https_acme_url': (_get(cfg, 'https', 'acme_url') if _get(cfg, 'https', 'acme_provider') == 'custom'
else ACME_STAGING_CA if _get(cfg, 'https', 'acme_staging') else ACME_PRODUCTION_CA),
'https_acme_eab': ((_get(cfg, 'https', 'acme_eab_key_id'), _get(cfg, 'https', 'acme_eab_mac_key'))
if _get(cfg, 'https', 'acme_eab_key_id') and _get(cfg, 'https', 'acme_eab_mac_key')
else None),
'https_zerossl_api_key': _get(cfg, 'https', 'zerossl_api_key'),
'https_web_port': _get(cfg, 'https', 'web_port'),
'https_manager_port': _get(cfg, 'https', 'manager_port'),
'pki_publish': _get_list(cfg, 'pki', 'publish'),
'pki_acme': [name for name, authority in issuing_cas(cfg).items() if authority['acme']],
'metrics_enabled': _get(cfg, 'metrics', 'enabled'),
'metrics_port': _get(cfg, 'metrics', 'port'),
'metrics_listen': _get(cfg, 'metrics', 'listen'),
'metrics_https_port': _get(cfg, 'metrics', 'https_port'),
'metrics_service_account': _get(cfg, 'metrics', 'service_account'),
'sites_enabled': _get(cfg, 'sites', 'enabled'),
@@ -1101,8 +1228,8 @@ def build_context(cfg, public_ip=None):
def s2s_ready(ctx):
"""True when the router is on and any site_to_site connection is ready."""
return bool(ctx['router_enabled'] and any(connection['ready'] for connection in ctx['connections']))
"""True when the router is on and installed and any site_to_site connection is ready."""
return bool(ctx['router_enabled'] and ctx['router_installed'] and any(connection['ready'] for connection in ctx['connections']))
def routing_ready(ctx):
@@ -1112,19 +1239,21 @@ def routing_ready(ctx):
def p2s_ready(ctx):
"""IKEv2 access needs the VPN on, its settings and the server's VPN server certificate, which the P2S CA issues."""
return bool(ctx['vpn_enabled'] and ctx['p2s_enabled'] and ctx['p2s_address_pool'] and ctx['local_fqdn']
"""IKEv2 access needs the VPN on and installed, its settings and the server's VPN server certificate, which the P2S
CA issues."""
return bool(ctx['vpn_enabled'] and ctx['vpn_installed'] and ctx['p2s_enabled'] and ctx['p2s_address_pool'] and ctx['local_fqdn']
and ctx['server_certificate'])
def wg_ready(ctx):
"""WireGuard needs the VPN on and its settings."""
return bool(ctx['vpn_enabled'] and ctx['wg_enabled'] and ctx['wg_address'])
"""WireGuard needs the VPN on and installed and its settings."""
return bool(ctx['vpn_enabled'] and ctx['vpn_installed'] and ctx['wg_enabled'] and ctx['wg_address'])
def openvpn_ready(ctx):
"""OpenVPN needs the VPN on, its settings and the server's VPN server certificate, which the P2S CA issues."""
return bool(ctx['vpn_enabled'] and ctx['openvpn_enabled'] and ctx['openvpn_pool'] and ctx['local_fqdn']
"""OpenVPN needs the VPN on and installed, its settings and the server's VPN server certificate, which the P2S CA
issues."""
return bool(ctx['vpn_enabled'] and ctx['vpn_installed'] and ctx['openvpn_enabled'] and ctx['openvpn_pool'] and ctx['local_fqdn']
and ctx['server_certificate'])
@@ -1150,6 +1279,25 @@ def webdav_ready(ctx):
return bool(ctx['webdav_enabled'] and https_ready(ctx))
def packages_installed(packages):
"""Whether every one of the packages is installed, as dpkg knows them."""
result = subprocess.run(['dpkg-query', '-W', '-f=${db:Status-Status}\n', *packages], capture_output=True, text=True)
states = result.stdout.split()
return len(states) == len(packages) and all(state == 'installed' for state in states)
def packages_automatic(packages):
"""The packages apt marks as installed automatically, which apt autoremove removes once nothing depends on them."""
result = subprocess.run(['apt-mark', 'showauto', *packages], capture_output=True, text=True)
return result.stdout.split() if result.returncode == 0 else []
def component_on(cfg, name):
"""Whether the switch of the component of COMPONENTS is on in the configuration."""
section, setting = COMPONENTS[name][0]
return bool(cfg[section][setting])
def dns_ready(ctx):
"""The name server answers for its domains while dns.enabled is true."""
return bool(ctx['dns_enabled'])
@@ -1276,6 +1424,9 @@ def configure(cfg=None, public_ip=None):
fail(str(failure))
except ldap.LDAPError as exc:
notices = [f'the PKI is left as it is: the directory cannot be reached: {exc}']
# Without the directory the first setup has no Servers Issuing CA to choose.
if not cfg['https']['certificate']:
choose_https_certificate(cfg, ctx, 'self-signed')
for notice in notices:
warn(notice)
# The WireGuard peers of the users; None keeps those of wg0.conf while the directory cannot be reached.