summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerge Schneider <serge@raspberrypi.com>2022-07-26 12:08:25 +0100
committerSerge Schneider <serge@raspberrypi.com>2022-07-26 12:08:25 +0100
commitfb582e2e670a0b5fbc40d4329a7e56e15d944774 (patch)
tree0cf70760beb0f1d376ff28ce13dab8b09754cb5b
parentca06d62f2ef63bd00b5729e48c64a2688e46ae14 (diff)
parent01b2432007766a6a1acc942f62d4ece7b25e560d (diff)
Merge remote-tracking branch 'origin/master' into arm64
-rw-r--r--README.md13
-rwxr-xr-xbuild.sh12
-rwxr-xr-xexport-image/01-user-rename/01-run.sh8
3 files changed, 28 insertions, 5 deletions
diff --git a/README.md b/README.md
index 2ef35e8..a86f951 100644
--- a/README.md
+++ b/README.md
@@ -175,14 +175,23 @@ The following environment variables are supported:
To get the current value from a running system, look in
`/etc/timezone`.
- * `FIRST_USER_NAME` (Default: "pi" )
+ * `FIRST_USER_NAME` (Default: `pi`)
- Username for the first user
+ Username for the first user. This user only exists during the image creation process. Unless
+ `DISABLE_FIRST_BOOT_USER_RENAME` is set to `1`, this user will be renamed on the first boot with
+ a name chosen by the final user. This security feature is designed to prevent shipping images
+ with a default username and help prevent malicious actors from taking over your devices.
* `FIRST_USER_PASS` (Default: unset)
Password for the first user. If unset, the account is locked.
+ * `DISABLE_FIRST_BOOT_USER_RENAME` (Default: `0`)
+
+ Disable the renaming of the first user during the first boot. This make it so `FIRST_USER_NAME`
+ 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.
+
* `WPA_ESSID`, `WPA_PASSWORD` and `WPA_COUNTRY` (Default: unset)
If these are set, they are use to configure `wpa_supplicant.conf`, so that the Raspberry Pi can automatically connect to a wireless network on first boot. If `WPA_ESSID` is set and `WPA_PASSWORD` is unset an unprotected wireless network will be configured. If set, `WPA_PASSWORD` must be between 8 and 63 characters.
diff --git a/build.sh b/build.sh
index 014035c..135da35 100755
--- a/build.sh
+++ b/build.sh
@@ -225,6 +225,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 RELEASE=${RELEASE:-bullseye}
export WPA_ESSID
export WPA_PASSWORD
@@ -290,6 +291,17 @@ if [[ ! "$FIRST_USER_NAME" =~ ^[a-z][-a-z0-9_]*$ ]]; then
exit 1
fi
+if [[ "$DISABLE_FIRST_BOOT_USER_RENAME" == "1" ]] && [ -z "${FIRST_USER_PASS}" ]; then
+ echo "To disable user rename on first boot, FIRST_USER_PASS needs to be set"
+ echo "Not setting FIRST_USER_PASS makes your system vulnerable and open to cyberattacks"
+ exit 1
+fi
+
+if [[ "$DISABLE_FIRST_BOOT_USER_RENAME" == "1" ]]; then
+ echo "User rename on the first boot is disabled"
+ echo "Be advised of the security risks linked to shipping a device with default username/password set."
+fi
+
if [[ -n "${APT_PROXY}" ]] && ! curl --silent "${APT_PROXY}" >/dev/null ; then
echo "Could not reach APT_PROXY server: ${APT_PROXY}"
exit 1
diff --git a/export-image/01-user-rename/01-run.sh b/export-image/01-user-rename/01-run.sh
index 8a5617b..f3f900f 100755
--- a/export-image/01-user-rename/01-run.sh
+++ b/export-image/01-user-rename/01-run.sh
@@ -1,5 +1,7 @@
#!/bin/bash -e
-on_chroot << EOF
- SUDO_USER="${FIRST_USER_NAME}" rename-user -f -s
-EOF
+if [[ "${DISABLE_FIRST_BOOT_USER_RENAME}" == "0" ]]; then
+ on_chroot <<- EOF
+ SUDO_USER="${FIRST_USER_NAME}" rename-user -f -s
+ EOF
+fi