Fix shutdown command by using full path to /sbin/shutdown
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user