summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerge Schneider <serge@raspberrypi.com>2026-02-10 10:06:37 +0000
committerSerge Schneider <serge@raspberrypi.com>2026-03-02 16:05:33 +0000
commitc020178c01c882cc827d42132ca436edf7985031 (patch)
tree57edf5c77b84087cbd9fef3a9a0ed203725b0af7
parent164ddbb39de3f9efde1869108343fbede4f6fbf6 (diff)
Add PASSWORDLESS_SUDO option
raspberrypi-sys-mods no longer ships 010_pi-nopasswd. This adds an option to re-enable passwordless sudo.
-rw-r--r--README.md8
-rwxr-xr-xbuild.sh1
-rwxr-xr-xstage2/01-sys-tweaks/01-run.sh6
3 files changed, 13 insertions, 2 deletions
diff --git a/README.md b/README.md
index f2ec148..5fa13b5 100644
--- a/README.md
+++ b/README.md
@@ -186,6 +186,14 @@ The following environment variables are supported:
stays activated. `FIRST_USER_PASS` must be set for this to work. Please be aware of the implied
security risk of defining a default username and password for your devices.
+ * `PASSWORDLESS_SUDO` (Default: `0`)
+
+ Setting to `1` will enable passwordless sudo for the first user. This allows
+ the user to run commands with sudo without entering a password. Note that
+ this is a security risk and should only be enabled if you understand the
+ implications. The user will still be able to use sudo with a password even
+ when this is set to `0`.
+
* `WPA_COUNTRY` (Default: unset)
Sets the default WLAN regulatory domain and unblocks WLAN interfaces. This should be a 2-letter ISO/IEC 3166 country Code, i.e. `GB`
diff --git a/build.sh b/build.sh
index 8e7215a..3c5d7fb 100755
--- a/build.sh
+++ b/build.sh
@@ -207,6 +207,7 @@ export TARGET_HOSTNAME=${TARGET_HOSTNAME:-raspberrypi}
export FIRST_USER_NAME=${FIRST_USER_NAME:-pi}
export FIRST_USER_PASS
export DISABLE_FIRST_BOOT_USER_RENAME=${DISABLE_FIRST_BOOT_USER_RENAME:-0}
+export PASSWORDLESS_SUDO="${PASSWORDLESS_SUDO:-0}"
export WPA_COUNTRY
export ENABLE_SSH="${ENABLE_SSH:-0}"
export PUBKEY_ONLY_SSH="${PUBKEY_ONLY_SSH:-0}"
diff --git a/stage2/01-sys-tweaks/01-run.sh b/stage2/01-sys-tweaks/01-run.sh
index 6da2876..a3d8729 100755
--- a/stage2/01-sys-tweaks/01-run.sh
+++ b/stage2/01-sys-tweaks/01-run.sh
@@ -38,8 +38,10 @@ on_chroot <<- EOF
done
EOF
-if [ -f "${ROOTFS_DIR}/etc/sudoers.d/010_pi-nopasswd" ]; then
- sed -i "s/^pi /$FIRST_USER_NAME /" "${ROOTFS_DIR}/etc/sudoers.d/010_pi-nopasswd"
+if [ "${PASSWORDLESS_SUDO}" = "1" ]; then
+ on_chroot <<- EOF
+ SUDO_USER="${FIRST_USER_NAME}" raspi-config do_sudo_pass 0
+ EOF
fi
on_chroot << EOF