34 lines
1.3 KiB
Bash
Executable File
34 lines
1.3 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Toggle passwordless sudo for the current user.
|
|
# First run: enables passwordless sudo (after confirmation).
|
|
# Second run: disables it.
|
|
|
|
NOPASSWD_FILE="/etc/sudoers.d/99-omarchy-nopasswd-${USER}"
|
|
|
|
# Check for the file directly — sudo -n can stay cached or be granted by other rules
|
|
if sudo test -f "$NOPASSWD_FILE"; then
|
|
sudo rm "$NOPASSWD_FILE"
|
|
echo "Passwordless sudo has been DISABLED. Sudo will require a password again."
|
|
else
|
|
echo ""
|
|
echo "⚠️ WARNING: This will allow ANY process running as your user to"
|
|
echo "execute ANY command as root WITHOUT a password."
|
|
echo ""
|
|
echo "This is useful for AI agents that need to run sudo commands,"
|
|
echo "but it significantly weakens the security of your system."
|
|
echo "Anyone or anything with access to your user account gets full root."
|
|
echo ""
|
|
echo "Only enable this while actively using an AI agent, then run"
|
|
echo "this command again to disable it."
|
|
echo ""
|
|
|
|
if gum confirm "Enable passwordless sudo? This is a significant security risk!"; then
|
|
echo "${USER} ALL=(ALL) NOPASSWD: ALL" | sudo tee "$NOPASSWD_FILE" > /dev/null
|
|
sudo chmod 440 "$NOPASSWD_FILE"
|
|
echo "Passwordless sudo has been ENABLED. Run this command again to disable it."
|
|
else
|
|
echo "Aborted. No changes made."
|
|
fi
|
|
fi
|