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
Release / release (push) Failing after 8s
This commit is contained in:
1 parent
a649331aa2
commit
a7bfabcb89
97 files changed
+4498
-1834
No files matched your search
@@ -54,17 +54,20 @@ Pages:
|
||||
/sites the web sites Caddy serves: the settings of sites, list, add, change and remove (see sites()),
|
||||
and the files of each: list, download, upload, extract a zip archive, create a folder, rename and
|
||||
remove (see Handler.site_files()); a member of a site's editors group may use the site's files
|
||||
/components
|
||||
the installable components, the VPN, the router, the name server and WebDAV: their switches and
|
||||
whether their packages are installed (see components())
|
||||
/dns the primary name server of the server's domains: its settings, and the domains: add, change and
|
||||
remove, each with the records it serves and its manual records (see dns())
|
||||
/postgresql
|
||||
the databases of each PostgreSQL cluster on the server with their sizes, as JSON (see
|
||||
postgresql_databases()); /config has the clusters' settings
|
||||
/.well-known/openid-configuration, /oidc/...
|
||||
while oidc.enabled is true, the OpenID Provider (linuxmanager_oidc), answered only on the
|
||||
loopback address, where Caddy passes the requests of the HTTPS site; POST /oidc/login counts
|
||||
towards the limit of /auth calls
|
||||
while oidc.enabled is true, the OpenID Provider (linuxmanager_oidc), answered only for Caddy's
|
||||
calls of the HTTPS site, from the loopback address with X-Forwarded-Proto https; POST
|
||||
/oidc/login counts towards the limit of /auth calls
|
||||
|
||||
/status/full, /config, /metrics/history, /metrics/settings, /postgresql, /users, /service-accounts, /groups, /site-to-site, /backup, /remote-access, /ca, /logs, /sites, /dns, /shell and /account need an HS256 JWT in an Authorization: Bearer header signed
|
||||
/status/full, /config, /metrics/history, /metrics/settings, /postgresql, /users, /service-accounts, /groups, /site-to-site, /backup, /remote-access, /ca, /logs, /sites, /dns, /components, /shell and /account need an HS256 JWT in an Authorization: Bearer header signed
|
||||
with linuxmanager_auth.WEB_KEY (see linuxmanager_auth.verify). A token of /auth names a user in sub;
|
||||
/account serves that user, and the other paths need a member of linuxmanager_users.ADMIN_GROUP. A
|
||||
token of linux-manager-token has the admin claim and names no user; it may call every path but
|
||||
|
||||
@@ -36,7 +36,7 @@ def backup(method, path, body):
|
||||
current secret
|
||||
POST /backup/run start a backup now, without waiting for it; 409 while one runs
|
||||
|
||||
A change is made as /site-to-site makes one, and applied by restarting linux-manager-setup without waiting for it.
|
||||
A change is made as /site-to-site makes one, and applied by a run of linux-manager-setup, without waiting for it.
|
||||
"""
|
||||
if body == 'invalid' or (body is not None and not isinstance(body, dict)):
|
||||
return 400, {'error': 'the body must be a JSON object'}
|
||||
@@ -80,5 +80,5 @@ def backup(method, path, body):
|
||||
return 500, {'error': f'the configuration cannot be written: {exc}'}
|
||||
except SystemExit as exc:
|
||||
return 500, {'error': str(exc.code)}
|
||||
run('systemctl', 'restart', '--no-block', 'linux-manager-setup.service')
|
||||
linuxmanager.request_setup()
|
||||
return 200, {'settings': backup_settings(cfg['backup'])}
|
||||
@@ -1,6 +1,6 @@
|
||||
"""What the modules of the web service share: the paths of the configuration and of the state linux-manager-setup writes,
|
||||
the limit of request bodies, the HTTP statuses of the failures of the server's modules, reading the configuration and
|
||||
the state, changing a section of the configuration, the state of a unit, and the log."""
|
||||
the state, changing settings of the configuration, the state of a unit, and the log."""
|
||||
|
||||
import json
|
||||
import sys
|
||||
@@ -59,15 +59,17 @@ def unit_state(unit):
|
||||
return result.stdout.strip() if result and result.stdout.strip() else 'unknown'
|
||||
|
||||
|
||||
def section_change(name, body):
|
||||
"""Change any of the settings of the configuration's section as /backup changes its own; the section, or the HTTP
|
||||
status and the error document as a tuple."""
|
||||
settings = {option: body[option] for option in linuxmanager.SCHEMA[name] if option in body}
|
||||
def settings_change(changes):
|
||||
"""Change settings of sections of the configuration in one step, section -> {setting: value}, keeping only the
|
||||
settings of SCHEMA, validated as a whole, and run setup; the configuration, or the HTTP status and the error document
|
||||
as a tuple."""
|
||||
try:
|
||||
with linuxmanager.config_lock():
|
||||
data = linuxmanager.read_settings()
|
||||
current = data.get(name)
|
||||
data[name] = {**(current if isinstance(current, dict) else {}), **settings}
|
||||
for name, body in changes.items():
|
||||
current = data.get(name)
|
||||
data[name] = {**(current if isinstance(current, dict) else {}),
|
||||
**{option: body[option] for option in linuxmanager.SCHEMA[name] if option in body}}
|
||||
cfg = linuxmanager.with_defaults(data)
|
||||
linuxmanager.validate(cfg)
|
||||
linuxmanager.save_config(data)
|
||||
@@ -77,8 +79,15 @@ def section_change(name, body):
|
||||
return 500, {'error': f'the configuration cannot be written: {exc}'}
|
||||
except SystemExit as exc:
|
||||
return 500, {'error': str(exc.code)}
|
||||
run('systemctl', 'restart', '--no-block', 'linux-manager-setup.service')
|
||||
return cfg[name]
|
||||
linuxmanager.request_setup()
|
||||
return cfg
|
||||
|
||||
|
||||
def section_change(name, body):
|
||||
"""Change any of the settings of the configuration's section as /backup changes its own; the section, or the HTTP
|
||||
status and the error document as a tuple."""
|
||||
changed = settings_change({name: body})
|
||||
return changed if isinstance(changed, tuple) else changed[name]
|
||||
|
||||
|
||||
def log(message):
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
"""/components: the installable components of the server, which the Manager's System tab switches."""
|
||||
|
||||
import linuxmanager
|
||||
import linuxmanager_net
|
||||
|
||||
from .common import settings_change, unit_state
|
||||
|
||||
|
||||
def router_choices(cfg):
|
||||
"""The interfaces the router may take as its internal one: the NICs but the external interface."""
|
||||
external = cfg['interfaces']['external'].strip()
|
||||
if not external and (cfg['general']['mode'] or 'manual') == 'auto':
|
||||
try:
|
||||
external, _ = linuxmanager_net.detect_interfaces(internal=False)
|
||||
except linuxmanager_net.ConfigError:
|
||||
external = ''
|
||||
return [name for name in linuxmanager_net.nics() if name != external]
|
||||
|
||||
|
||||
def listing(cfg):
|
||||
"""Each component of linuxmanager.COMPONENTS: {name, enabled, state}, state being installing or failed while its
|
||||
installation unit is, else installed or not installed; the router also has available, whether the server has an
|
||||
interface for its internal side or the router is on, the interfaces to choose from, general.mode and its current
|
||||
internal_interface, int_addr and int_gateway_ip."""
|
||||
found = []
|
||||
for name, (_, packages) in linuxmanager.COMPONENTS.items():
|
||||
unit = unit_state(f'linux-manager-install@{name}.service')
|
||||
state = {'activating': 'installing', 'active': 'installing', 'failed': 'failed'}.get(unit) or \
|
||||
('installed' if linuxmanager.packages_installed(packages) else 'not installed')
|
||||
entry = {'name': name, 'enabled': linuxmanager.component_on(cfg, name), 'state': state}
|
||||
if name == 'router':
|
||||
choices = router_choices(cfg)
|
||||
entry.update({'available': entry['enabled'] or bool(choices), 'interfaces': choices,
|
||||
'mode': cfg['general']['mode'] or 'manual',
|
||||
'internal_interface': cfg['interfaces']['internal'].strip(),
|
||||
'int_addr': cfg['local']['int_addr'].strip(),
|
||||
'int_gateway_ip': cfg['local']['int_gateway_ip'].strip()})
|
||||
found.append(entry)
|
||||
return found
|
||||
|
||||
|
||||
def components(method, path, body):
|
||||
"""Answer a /components request: the HTTP status and the JSON document.
|
||||
|
||||
GET /components {"components": [...]} (listing)
|
||||
PUT /components/<name> switch a component: {"enabled"}, for the router switched on also "internal_interface",
|
||||
"int_addr" and "int_gateway_ip" as general.mode needs them; {"components": [...]}
|
||||
|
||||
A switched-on component's packages are installed by linux-manager-setup (linux-manager-install@<name>), which a
|
||||
change starts without waiting for it; switching a component off removes no package. The configuration's validation
|
||||
refuses a change it does not allow, such as the VPN off while IKEv2, OpenVPN or WireGuard is on.
|
||||
"""
|
||||
if body == 'invalid' or (body is not None and not isinstance(body, dict)):
|
||||
return 400, {'error': 'the body must be a JSON object'}
|
||||
body = body or {}
|
||||
parts = path.strip('/').split('/')
|
||||
cfg = linuxmanager.load_config()
|
||||
if method in ('GET', 'HEAD') and parts == ['components']:
|
||||
return 200, {'components': listing(cfg)}
|
||||
if method != 'PUT' or len(parts) != 2 or parts[1] not in linuxmanager.COMPONENTS:
|
||||
return 404, {'error': f'no route {method} {path}'}
|
||||
name, enabled = parts[1], body.get('enabled')
|
||||
if not isinstance(enabled, bool):
|
||||
return 400, {'error': 'enabled must be true or false'}
|
||||
(section, setting), _ = linuxmanager.COMPONENTS[name]
|
||||
changes = {section: {setting: enabled}}
|
||||
if name == 'router' and enabled and not cfg['router']['enabled']:
|
||||
choices = router_choices(cfg)
|
||||
if not choices:
|
||||
return 409, {'error': 'the router needs a second network interface; the server has only one'}
|
||||
values = {key: body.get(key, '') for key in ('internal_interface', 'int_addr', 'int_gateway_ip')}
|
||||
if any(not isinstance(value, str) for value in values.values()):
|
||||
return 400, {'error': 'internal_interface, int_addr and int_gateway_ip must be strings'}
|
||||
if values['internal_interface'] and values['internal_interface'] not in choices:
|
||||
return 400, {'error': f'internal_interface must be one of {", ".join(choices)}'}
|
||||
if values['internal_interface']:
|
||||
changes['interfaces'] = {'internal': values['internal_interface']}
|
||||
if values['int_addr'] or values['int_gateway_ip']:
|
||||
changes['local'] = {'int_addr': values['int_addr'].strip(), 'int_gateway_ip': values['int_gateway_ip'].strip()}
|
||||
changed = settings_change(changes)
|
||||
if isinstance(changed, tuple):
|
||||
return changed
|
||||
return 200, {'components': listing(changed)}
|
||||
@@ -3,7 +3,7 @@
|
||||
import ipaddress
|
||||
|
||||
import linuxmanager
|
||||
from linuxmanager_status import established_each, run
|
||||
from linuxmanager_status import established_each
|
||||
|
||||
from .common import section
|
||||
|
||||
@@ -37,7 +37,7 @@ def site_to_site(method, path, body):
|
||||
DELETE /site-to-site/<name> remove the connection
|
||||
|
||||
A change is made holding linuxmanager.config_lock, checked as linux-manager-setup checks the configuration (400 with
|
||||
the reason), written with linuxmanager.save_config, and applied by restarting linux-manager-setup without waiting for it.
|
||||
the reason), written with linuxmanager.save_config, and applied by a run of linux-manager-setup, without waiting for it.
|
||||
"""
|
||||
if body == 'invalid' or (body is not None and not isinstance(body, dict)):
|
||||
return 400, {'error': 'the body must be a JSON object'}
|
||||
@@ -84,7 +84,7 @@ def site_to_site(method, path, body):
|
||||
return 500, {'error': f'the configuration cannot be written: {exc}'}
|
||||
except SystemExit as exc:
|
||||
return 500, {'error': str(exc.code)}
|
||||
run('systemctl', 'restart', '--no-block', 'linux-manager-setup.service')
|
||||
linuxmanager.request_setup()
|
||||
if method == 'DELETE':
|
||||
return 200, {'name': name, 'removed': True}
|
||||
return (201 if method == 'POST' else 200), connection_of(name, cfg['site_to_site'][name], None)
|
||||
@@ -121,7 +121,7 @@ def remote_access(state, method, path, body):
|
||||
configuration needs of the server (wireguard_server)
|
||||
PUT /remote-access/<system> change any of the settings of the system's section; answers the section
|
||||
|
||||
A change is made as /site-to-site makes one, and applied by restarting linux-manager-setup without waiting for it.
|
||||
A change is made as /site-to-site makes one, and applied by a run of linux-manager-setup, without waiting for it.
|
||||
"""
|
||||
if body == 'invalid' or (body is not None and not isinstance(body, dict)):
|
||||
return 400, {'error': 'the body must be a JSON object'}
|
||||
@@ -151,5 +151,5 @@ def remote_access(state, method, path, body):
|
||||
return 500, {'error': f'the configuration cannot be written: {exc}'}
|
||||
except SystemExit as exc:
|
||||
return 500, {'error': str(exc.code)}
|
||||
run('systemctl', 'restart', '--no-block', 'linux-manager-setup.service')
|
||||
linuxmanager.request_setup()
|
||||
return 200, cfg[system]
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
import linuxmanager
|
||||
import linuxmanager_dns
|
||||
from linuxmanager_status import run
|
||||
|
||||
from .common import section_change, unit_state
|
||||
|
||||
@@ -30,7 +29,7 @@ def dns(method, path, query, body):
|
||||
DELETE /dns/domains/<domain>/records
|
||||
remove the manual records of name= and type=, with content= only that one
|
||||
|
||||
A change is applied by restarting linux-manager-setup without waiting for it.
|
||||
A change is applied by a run of linux-manager-setup, without waiting for it.
|
||||
"""
|
||||
if body == 'invalid' or (body is not None and not isinstance(body, dict)):
|
||||
return 400, {'error': 'the body must be a JSON object'}
|
||||
@@ -80,5 +79,5 @@ def dns(method, path, query, body):
|
||||
return 500, {'error': str(exc)}
|
||||
except SystemExit as exc:
|
||||
return 500, {'error': str(exc.code)}
|
||||
run('systemctl', 'restart', '--no-block', 'linux-manager-setup.service')
|
||||
linuxmanager.request_setup()
|
||||
return code, document
|
||||
@@ -18,11 +18,12 @@ import linuxmanager_sites
|
||||
from .auth import auth, auth_wait, refusal
|
||||
from .backup import backup
|
||||
from .common import BODY_LIMIT, CONFIG_FILE, current, log, read_json, section
|
||||
from .components import components
|
||||
from .connectivity import remote_access, site_to_site
|
||||
from .dns import dns
|
||||
from .identities import account, groups, service_accounts, users
|
||||
from .logs import logs
|
||||
from .https import https_settings
|
||||
from .https import PATHS as HTTPS_PATHS, https
|
||||
from .metrics import metrics_history, metrics_settings
|
||||
from .pki import PUBLISHED, ca
|
||||
from .shell import EDITOR_BODY_LIMIT, shell, shell_editor, shell_passkey, shell_ticket
|
||||
@@ -65,14 +66,14 @@ class Handler(BaseHTTPRequestHandler):
|
||||
if self.command not in ('GET', 'HEAD'):
|
||||
self.close_connection = True
|
||||
directory = next((name for name in ('users', 'service-accounts', 'groups', 'account', 'site-to-site', 'backup',
|
||||
'ca', 'shell', 'remote-access', 'logs', 'sites', 'dns')
|
||||
'ca', 'shell', 'remote-access', 'logs', 'sites', 'dns', 'components')
|
||||
if path == f'/{name}' or path.startswith(f'/{name}/')), None)
|
||||
protected = path in ('/status/full', '/config', '/metrics/history', '/metrics/settings', '/https/settings',
|
||||
protected = path in ('/status/full', '/config', '/metrics/history', '/metrics/settings', *HTTPS_PATHS,
|
||||
'/postgresql') or \
|
||||
directory is not None
|
||||
signing = path in ('/auth', '/auth/passkey', '/auth/passkey/complete', '/auth/refresh', '/auth/logout')
|
||||
oidc = (path == '/.well-known/openid-configuration' or path.startswith('/oidc/')) and \
|
||||
self.server.server_address[0] == linuxmanager_net.LOOPBACK
|
||||
self.client_address[0] == linuxmanager_net.LOOPBACK and self.headers.get('X-Forwarded-Proto') == 'https'
|
||||
files = SITE_FILES.match(path) if directory == 'sites' else None
|
||||
query = urllib.parse.parse_qs(urllib.parse.urlsplit(self.path).query)
|
||||
state = current() if protected or signing else {}
|
||||
@@ -115,8 +116,8 @@ class Handler(BaseHTTPRequestHandler):
|
||||
elif path == '/metrics/settings':
|
||||
code, document = metrics_settings(self.command, payload)
|
||||
body, kind = json.dumps(document, indent=2).encode() + b'\n', 'application/json'
|
||||
elif path == '/https/settings':
|
||||
code, document = https_settings(self.command, payload)
|
||||
elif path in HTTPS_PATHS:
|
||||
code, document = https(self.command, path, payload)
|
||||
body, kind = json.dumps(document, indent=2).encode() + b'\n', 'application/json'
|
||||
elif directory == 'shell' and (path, self.command) == ('/shell', 'GET'):
|
||||
return shell(self, claims.get('sub'))
|
||||
@@ -160,6 +161,9 @@ class Handler(BaseHTTPRequestHandler):
|
||||
elif directory == 'dns':
|
||||
code, document = dns(self.command, path, query, payload)
|
||||
body, kind = json.dumps(document, indent=2).encode() + b'\n', 'application/json'
|
||||
elif directory == 'components':
|
||||
code, document = components(self.command, path, payload)
|
||||
body, kind = json.dumps(document, indent=2).encode() + b'\n', 'application/json'
|
||||
elif directory == 'service-accounts':
|
||||
code, document = service_accounts(self.command, path, payload)
|
||||
body, kind = json.dumps(document, indent=2).encode() + b'\n', 'application/json'
|
||||
|
||||
@@ -1,33 +1,82 @@
|
||||
"""/https/settings: the settings of HTTPS, of which the API changes the CA of Caddy's certificates."""
|
||||
"""/https: the settings of HTTPS and the server's own HTTPS certificate."""
|
||||
|
||||
import base64
|
||||
import binascii
|
||||
|
||||
import ldap
|
||||
|
||||
import linuxmanager
|
||||
import linuxmanager_pki
|
||||
|
||||
from .common import section_change
|
||||
from .common import PKI_STATUS, section_change
|
||||
|
||||
#: The settings of the https section PUT /https/settings changes.
|
||||
CHANGEABLE = ('acme_staging',)
|
||||
CHANGEABLE = ('acme_staging', 'certificate', 'self_signed_days', 'acme_provider', 'acme_url', 'acme_eab_key_id',
|
||||
'acme_eab_mac_key', 'zerossl_api_key')
|
||||
|
||||
#: The secrets of the https section, which the answers give as <name>_set instead.
|
||||
SECRETS = ('acme_eab_mac_key', 'zerossl_api_key')
|
||||
|
||||
#: The paths of /https.
|
||||
PATHS = ('/https/settings', '/https/csr', '/https/certificate', '/https/pfx')
|
||||
|
||||
|
||||
def https_settings(method, body):
|
||||
"""Answer a /https/settings request: the HTTP status and the JSON document.
|
||||
def shown(settings):
|
||||
"""The https section without its secrets, each replaced by whether it is set."""
|
||||
return {**{key: value for key, value in settings.items() if key not in SECRETS},
|
||||
**{f'{key}_set': bool(settings[key]) for key in SECRETS}}
|
||||
|
||||
GET /https/settings {"settings"}: the https section
|
||||
PUT /https/settings change acme_staging; the other settings of the section are changed on the server with
|
||||
linux-manager-config-edit, and a body naming one is 400
|
||||
|
||||
A change is applied by restarting linux-manager-setup without waiting for it.
|
||||
def https(method, path, body):
|
||||
"""Answer a /https request: the HTTP status and the JSON document.
|
||||
|
||||
GET /https/settings {"settings", "certificate"}: the https section, its secrets as <name>_set, and the
|
||||
server's HTTPS certificate (linuxmanager_pki.https_status)
|
||||
PUT /https/settings change any of CHANGEABLE; the other settings of the section are changed on the server
|
||||
with linux-manager-config-edit, and a body naming one is 400
|
||||
POST /https/csr make a key and a CSR for wan.local_fqdn: {"csr"}
|
||||
PUT /https/certificate take the certificate another CA signed for the CSR, PEM with its chain: {"certificate"}
|
||||
PUT /https/pfx take a PKCS#12 file of another CA's certificate: {"pfx" in base64, "password"}
|
||||
|
||||
A change is applied by a run of linux-manager-setup, without waiting for it.
|
||||
"""
|
||||
if body == 'invalid' or (body is not None and not isinstance(body, dict)):
|
||||
return 400, {'error': 'the body must be a JSON object'}
|
||||
if method in ('GET', 'HEAD'):
|
||||
try:
|
||||
return 200, {'settings': linuxmanager.load_config()['https']}
|
||||
except SystemExit as exc:
|
||||
return 500, {'error': str(exc.code)}
|
||||
if method != 'PUT':
|
||||
return 404, {'error': f'no route {method} /https/settings'}
|
||||
others = sorted(set(body or {}) - set(CHANGEABLE))
|
||||
if others:
|
||||
return 400, {'error': f'https.{", https.".join(others)}: changed on the server with linux-manager-config-edit only'}
|
||||
changed = section_change('https', body or {})
|
||||
return changed if isinstance(changed, tuple) else (200, {'settings': changed})
|
||||
body = body or {}
|
||||
try:
|
||||
cfg = linuxmanager.load_config()
|
||||
if path == '/https/settings' and method in ('GET', 'HEAD'):
|
||||
return 200, {'settings': shown(cfg['https']), 'certificate': linuxmanager_pki.https_status(cfg)}
|
||||
if path == '/https/settings' and method == 'PUT':
|
||||
others = sorted(set(body) - set(CHANGEABLE))
|
||||
if others:
|
||||
return 400, {'error': f'https.{", https.".join(others)}: changed on the server with '
|
||||
'linux-manager-config-edit only'}
|
||||
if 'certificate' in body and body['certificate'] not in linuxmanager.HTTPS_CERTIFICATES:
|
||||
return 400, {'error': f'https.certificate must be one of {", ".join(linuxmanager.HTTPS_CERTIFICATES)}'}
|
||||
changed = section_change('https', body)
|
||||
return changed if isinstance(changed, tuple) else (200, {'settings': shown(changed)})
|
||||
with linuxmanager_pki.locked():
|
||||
if (path, method) == ('/https/csr', 'POST'):
|
||||
return 200, linuxmanager_pki.https_csr(cfg)
|
||||
if (path, method) == ('/https/certificate', 'PUT'):
|
||||
document = linuxmanager_pki.import_https_certificate(cfg, body.get('certificate'))
|
||||
elif (path, method) == ('/https/pfx', 'PUT'):
|
||||
try:
|
||||
data = base64.b64decode(body.get('pfx') or '', validate=True)
|
||||
except (binascii.Error, TypeError):
|
||||
return 400, {'error': 'pfx must be a PKCS#12 file in base64'}
|
||||
password = body.get('password')
|
||||
if password is not None and not isinstance(password, str):
|
||||
return 400, {'error': 'password must be a string'}
|
||||
document = linuxmanager_pki.import_https_pfx(cfg, data, password)
|
||||
else:
|
||||
return 404, {'error': f'no route {method} {path}'}
|
||||
except linuxmanager_pki.Failure as failure:
|
||||
return PKI_STATUS.get(failure.status, 500), {'error': str(failure)}
|
||||
except ldap.LDAPError as exc:
|
||||
return 500, {'error': f'the directory, which holds the certificate, failed: {exc}'}
|
||||
except SystemExit as exc:
|
||||
return 500, {'error': str(exc.code)}
|
||||
linuxmanager.request_setup()
|
||||
return 200, document
|
||||
@@ -7,7 +7,7 @@ import linuxmanager
|
||||
|
||||
#: The units whose journal /logs/journal shows, besides the whole journal: the package's own and the services it runs.
|
||||
JOURNAL_UNITS = ('linux-manager-setup', 'linux-manager-web', 'linux-manager-metrics', 'linux-manager-pki', 'linux-manager-backup',
|
||||
'linux-manager-caddy', 'linux-manager-ui', 'caddy', 'slapd', 'nslcd', 'postgresql', 'strongswan',
|
||||
'linux-manager-ui', 'caddy', 'slapd', 'nslcd', 'postgresql', 'strongswan',
|
||||
'wg-quick@wg0', 'openvpn-server@linux-manager', 'ssh', 'linux-manager-resolver', 'linux-manager-webdav', 'pdns')
|
||||
|
||||
#: The most lines /logs answers, the number it answers without lines, and the most bytes it reads from the end of a file.
|
||||
|
||||
@@ -35,7 +35,7 @@ def metrics_settings(method, body):
|
||||
PUT /metrics/settings change any of the settings of the metrics section; an empty or absent otlp_password keeps
|
||||
the current secret, and an empty otlp_username removes it
|
||||
|
||||
A change is applied by restarting linux-manager-setup without waiting for it.
|
||||
A change is applied by a run of linux-manager-setup, without waiting for it.
|
||||
"""
|
||||
if body == 'invalid' or (body is not None and not isinstance(body, dict)):
|
||||
return 400, {'error': 'the body must be a JSON object'}
|
||||
|
||||
@@ -4,7 +4,6 @@ import ldap
|
||||
|
||||
import linuxmanager
|
||||
import linuxmanager_pki
|
||||
from linuxmanager_status import run
|
||||
|
||||
from .common import PKI_STATUS
|
||||
|
||||
@@ -38,7 +37,7 @@ def ca(method, path, body):
|
||||
answers {"upstream", "expires"}
|
||||
|
||||
A change of the settings is made as /site-to-site makes one; it, a revoked router certificate, an imported root
|
||||
or issuing CA certificate and a new Simple CA token are applied by restarting linux-manager-setup without waiting
|
||||
or issuing CA certificate and a new Simple CA token are applied by a run of linux-manager-setup, without waiting
|
||||
for it.
|
||||
"""
|
||||
if body == 'invalid' or (body is not None and not isinstance(body, dict)):
|
||||
@@ -66,7 +65,7 @@ def ca(method, path, body):
|
||||
with linuxmanager_pki.directory() as connection:
|
||||
linuxmanager_pki.check_source(cfg, linuxmanager_pki.authority(connection, 'root'))
|
||||
linuxmanager.save_config(data)
|
||||
run('systemctl', 'restart', '--no-block', 'linux-manager-setup.service')
|
||||
linuxmanager.request_setup()
|
||||
return 200, {'settings': cfg['pki'], 'templates': linuxmanager.pki_templates(cfg)}
|
||||
with linuxmanager_pki.locked():
|
||||
if route == ('POST', 'certificates'):
|
||||
@@ -98,5 +97,5 @@ def ca(method, path, body):
|
||||
except SystemExit as exc:
|
||||
return 500, {'error': str(exc.code)}
|
||||
if route[1] in ('issuing', 'root') or document.get('reissue'):
|
||||
run('systemctl', 'restart', '--no-block', 'linux-manager-setup.service')
|
||||
linuxmanager.request_setup()
|
||||
return 200, document
|
||||
@@ -10,7 +10,6 @@ import ldap
|
||||
|
||||
import linuxmanager
|
||||
import linuxmanager_sites
|
||||
from linuxmanager_status import run
|
||||
|
||||
from .common import MIB, SITE_STATUS, section_change
|
||||
|
||||
@@ -31,7 +30,7 @@ def sites(method, path, query, body):
|
||||
PUT /sites/<name> change any of the settings of POST but name; an empty or absent private_key keeps the key
|
||||
DELETE /sites/<name> remove the site, with content=true also its folder
|
||||
|
||||
A change is applied by restarting linux-manager-setup without waiting for it.
|
||||
A change is applied by a run of linux-manager-setup, without waiting for it.
|
||||
"""
|
||||
if body == 'invalid' or (body is not None and not isinstance(body, dict)):
|
||||
return 400, {'error': 'the body must be a JSON object'}
|
||||
@@ -68,7 +67,7 @@ def sites(method, path, query, body):
|
||||
return 500, {'error': f'the site cannot be changed: {exc}'}
|
||||
except SystemExit as exc:
|
||||
return 500, {'error': str(exc.code)}
|
||||
run('systemctl', 'restart', '--no-block', 'linux-manager-setup.service')
|
||||
linuxmanager.request_setup()
|
||||
return code, document
|
||||
|
||||
|
||||
|
||||
@@ -232,7 +232,7 @@ def postgresql_databases():
|
||||
|
||||
def details(state):
|
||||
"""What /config shows: the configuration without its secrets, and what the server resolved and runs; caddy is the
|
||||
installed Caddy, {version, source, service}, service the state of caddy.service, null when it is not installed; oidc
|
||||
installed Caddy, {version, service}, service the state of caddy.service, null when it is not installed; oidc
|
||||
is {enabled, issuer} of the OpenID Provider, issuer null while it is disabled; docker.installed is whether
|
||||
docker.service is installed, as docker_status finds it."""
|
||||
configuration = state.get('configuration', {})
|
||||
@@ -252,9 +252,7 @@ def details(state):
|
||||
'rules': lines_of('iptables', '-S', 'LINUX-MANAGER-DOCKER'),
|
||||
},
|
||||
'postgresql': postgresql_configuration(),
|
||||
# Caddy is upstream's once its repository is configured (linux-manager-caddy).
|
||||
'caddy': {'version': caddy, 'source': 'upstream' if linuxmanager.CADDY_APT_SOURCE.is_file() else 'ubuntu',
|
||||
'service': unit_state('caddy.service')} if caddy else None,
|
||||
'caddy': {'version': caddy, 'service': unit_state('caddy.service')} if caddy else None,
|
||||
'oidc': {'enabled': oidc, 'issuer': linuxmanager.oidc_issuer(configuration) if oidc else None},
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user