diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f8bdc9d..88b4840e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ CHANGELOG ========= +* When a reboot is required (due to Ubuntu security updates automatically installed), a Reboot Box button now appears. + v0.17 (February 25, 2016) ------------------------- diff --git a/management/daemon.py b/management/daemon.py index b416b3ee..ded40a41 100755 --- a/management/daemon.py +++ b/management/daemon.py @@ -456,10 +456,12 @@ def do_updates(): "DEBIAN_FRONTEND": "noninteractive" }) + @app.route('/system/reboot', methods=["GET"]) @authorized_personnel_only def needs_reboot(): - if os.path.isfile("/var/run/reboot-required"): + from status_checks import is_reboot_needed_due_to_package_installation + if is_reboot_needed_due_to_package_installation(): return json_response(True) else: return json_response(False) @@ -467,10 +469,12 @@ def needs_reboot(): @app.route('/system/reboot', methods=["POST"]) @authorized_personnel_only def do_reboot(): - if os.path.isfile("/var/run/reboot-required"): + # To keep the attack surface low, we don't allow a remote reboot if one isn't necessary. + from status_checks import is_reboot_needed_due_to_package_installation + if is_reboot_needed_due_to_package_installation(): return utils.shell("check_output", ["/sbin/shutdown", "-r", "now"], capture_stderr=True) else: - return "No reboot is required" + return "No reboot is required, so it is not allowed." @app.route('/system/backup/status') diff --git a/management/status_checks.py b/management/status_checks.py index 1feea68a..36a87ea1 100755 --- a/management/status_checks.py +++ b/management/status_checks.py @@ -185,10 +185,13 @@ def check_ssh_password(env, output): else: output.print_ok("SSH disallows password-based login.") +def is_reboot_needed_due_to_package_installation(): + return os.path.exists("/var/run/reboot-required") + def check_software_updates(env, output): # Check for any software package updates. pkgs = list_apt_updates(apt_update=False) - if os.path.exists("/var/run/reboot-required"): + if is_reboot_needed_due_to_package_installation(): output.print_error("System updates have been installed and a reboot of the machine is required.") elif len(pkgs) == 0: output.print_ok("System software is up to date.") diff --git a/management/templates/system-status.html b/management/templates/system-status.html index efc8ad90..dc9233a5 100644 --- a/management/templates/system-status.html +++ b/management/templates/system-status.html @@ -1,9 +1,5 @@

System Status Checks

- - +
+
+ + + +
+
+ @@ -61,6 +59,9 @@
+
+
+