From 416d437aef832fbb24a55b907e222f3fc4cd2979 Mon Sep 17 00:00:00 2001 From: grabowski Date: Wed, 29 Oct 2025 17:45:01 +0700 Subject: [PATCH] Fix shutdown command by using full path to /sbin/shutdown MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updated shutdown and reboot commands to use absolute paths to ensure they work correctly with the sudoers configuration. Also updated the sudoers file to allow shutdown with specific arguments. Changes: - Use /sbin/shutdown instead of just shutdown - Use /sbin/reboot instead of just reboot - Updated sudoers to allow both 'shutdown -h +1' and 'shutdown -h now' - Ensures commands match sudoers whitelist exactly The restart was working because reboot might be in PATH, but shutdown needs the full path to match the sudoers entry. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- rotary_phone_web.py | 4 ++-- wedding-phone-shutdown | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/rotary_phone_web.py b/rotary_phone_web.py index 4bbf6bd..16ca732 100644 --- a/rotary_phone_web.py +++ b/rotary_phone_web.py @@ -981,7 +981,7 @@ def api_system_shutdown(): try: import subprocess # Schedule shutdown in 1 minute to allow response to be sent - subprocess.Popen(['sudo', 'shutdown', '-h', '+1']) + subprocess.Popen(['sudo', '/sbin/shutdown', '-h', '+1']) return jsonify({"success": True, "message": "System will shutdown in 1 minute"}) except Exception as e: return jsonify({"success": False, "error": str(e)}), 500 @@ -992,7 +992,7 @@ def api_system_restart(): try: import subprocess # Schedule restart to allow response to be sent - subprocess.Popen(['sudo', 'reboot']) + subprocess.Popen(['sudo', '/sbin/reboot']) return jsonify({"success": True, "message": "System will restart shortly"}) except Exception as e: return jsonify({"success": False, "error": str(e)}), 500 diff --git a/wedding-phone-shutdown b/wedding-phone-shutdown index aa0c141..59845fd 100644 --- a/wedding-phone-shutdown +++ b/wedding-phone-shutdown @@ -4,5 +4,6 @@ # Then: sudo chmod 0440 /etc/sudoers.d/wedding-phone-shutdown # Allow user to run shutdown and reboot commands without password -berwn ALL=(ALL) NOPASSWD: /sbin/shutdown +berwn ALL=(ALL) NOPASSWD: /sbin/shutdown -h +1 +berwn ALL=(ALL) NOPASSWD: /sbin/shutdown -h now berwn ALL=(ALL) NOPASSWD: /sbin/reboot