From 6258a7f311321c04a16e86d58faa45c29841cb32 Mon Sep 17 00:00:00 2001 From: Joshua Tauberer Date: Thu, 18 Jun 2015 11:01:11 +0000 Subject: [PATCH] status checks were broken if sshd was not present, fixes #444 --- CHANGELOG.md | 1 + management/status_checks.py | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0789ba9..de6e1c94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ DNS: Control panel: * Resetting a user's password now forces them to log in again everywhere. +* Status checks were not working if an ssh server was not installed. System: * The munin system monitoring tool is now installed and accessible at /admin/munin. diff --git a/management/status_checks.py b/management/status_checks.py index 749b4a3b..addd070c 100755 --- a/management/status_checks.py +++ b/management/status_checks.py @@ -42,16 +42,22 @@ def run_checks(rounded_values, env, output, pool): def get_ssh_port(): # Returns ssh port + try: + output = shell('check_output', ['sshd', '-T']) + except FileNotFoundError: + # sshd is not installed. That's ok. + return None - output = shell('check_output', ['sshd', '-T']) returnNext = False - for e in output.split(): if returnNext: return int(e) if e == "port": returnNext = True + # Did not find port! + return None + def run_services_checks(env, output, pool): # Check that system services are running. @@ -82,6 +88,7 @@ def run_services_checks(env, output, pool): fatal = False ret = pool.starmap(check_service, ((i, service, env) for i, service in enumerate(services)), chunksize=1) for i, running, fatal2, output2 in sorted(ret): + if output2 is None: continue # skip check (e.g. no port was set, e.g. no sshd) all_running = all_running and running fatal = fatal or fatal2 output2.playback(output) @@ -92,6 +99,10 @@ def run_services_checks(env, output, pool): return not fatal def check_service(i, service, env): + if not service["port"]: + # Skip check (no port, e.g. no sshd). + return (i, None, None, None) + import socket output = BufferedOutput() running = False