Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: firstrun.sh: line72: unexpected eof while looking for matching `'' #956

Open
1 task done
jujax opened this issue Nov 3, 2024 · 7 comments · May be fixed by #959
Open
1 task done

[BUG]: firstrun.sh: line72: unexpected eof while looking for matching `'' #956

jujax opened this issue Nov 3, 2024 · 7 comments · May be fixed by #959
Labels
bug Something isn't working

Comments

@jujax
Copy link

jujax commented Nov 3, 2024

What happened?

Hello,
I flashed raspberry os lite (I tried 64 and 32bits) on a raspberry pi 3 with imager v1.8.5 and with personnal settings like ssh key, wifi credentials etc ...
My raspberry stop at boot after lanching firstrun.sh, this is the error I see on my screen:

/boot/firmware/firstrun.sh: line72: unexpected eof while looking for matching `''

after that line kernel-command-line.service failed to start and the os is powered off with shutdown.target

I also tried to flash raspbian with my settings and it's working

Version

1.8.5

What host operating system were you using?

macOS

Host OS Version

Sequoia, 15.1

Selected OS

Raspberry Pi OS Lite Bookworm 64 bits

Which Raspberry Pi Device are you using?

Raspberry Pi 3B, 3A+, 3B+, and Compute Module 3, 3+

What kind of storage device are you using?

microSD Card in an internal reader

OS Customisation

  • Yes, I was using OS Customisation when the bug occurred.

Relevant log output

/boot/firmware/firstrun.sh: line72: unexpected eof while looking for matching `''
@jujax jujax added the bug Something isn't working label Nov 3, 2024
@jujax
Copy link
Author

jujax commented Nov 3, 2024

tdewey-rpi note: Edited for formatting, key removal

This is firstrun.sh file on my sd card:

#!/bin/bash

set +e

FIRSTUSER=`getent passwd 1000 | cut -d: -f1`
FIRSTUSERHOME=`getent passwd 1000 | cut -d: -f6`
if [ -f /usr/lib/raspberrypi-sys-mods/imager_custom ]; then
   /usr/lib/raspberrypi-sys-mods/imager_custom enable_ssh -k 'dD"'"'"'É<ssh-public-key>'
else
   install -o "$FIRSTUSER" -m 700 -d "$FIRSTUSERHOME/.ssh"
   install -o "$FIRSTUSER" -m 600 <(printf "dD"'É<ssh-public-key>") "$FIRSTUSERHOME/.ssh/authorized_keys"
   echo 'PasswordAuthentication no' >>/etc/ssh/sshd_config
   systemctl enable ssh
fi
if [ -f /usr/lib/userconf-pi/userconf ]; then
   /usr/lib/userconf-pi/userconf 'julien' '****'
else
   echo "$FIRSTUSER:"'****' | chpasswd -e
   if [ "$FIRSTUSER" != "julien" ]; then
      usermod -l "julien" "$FIRSTUSER"
      usermod -m -d "/home/julien" "julien"
      groupmod -n "julien" "$FIRSTUSER"
      if grep -q "^autologin-user=" /etc/lightdm/lightdm.conf ; then
         sed /etc/lightdm/lightdm.conf -i -e "s/^autologin-user=.*/autologin-user=julien/"
      fi
      if [ -f /etc/systemd/system/[email protected]/autologin.conf ]; then
         sed /etc/systemd/system/[email protected]/autologin.conf -i -e "s/$FIRSTUSER/julien/"
      fi
      if [ -f /etc/sudoers.d/010_pi-nopasswd ]; then
         sed -i "s/^$FIRSTUSER /julien /" /etc/sudoers.d/010_pi-nopasswd
      fi
   fi
fi
if [ -f /usr/lib/raspberrypi-sys-mods/imager_custom ]; then
   /usr/lib/raspberrypi-sys-mods/imager_custom set_wlan '****' '****' 'FR'
else
cat >/etc/wpa_supplicant/wpa_supplicant.conf <<'WPAEOF'
country=FR
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
ap_scan=1

update_config=1
network={
	ssid="****"
	psk=****
}

WPAEOF
   chmod 600 /etc/wpa_supplicant/wpa_supplicant.conf
   rfkill unblock wifi
   for filename in /var/lib/systemd/rfkill/*:wlan ; do
       echo 0 > $filename
   done
fi
if [ -f /usr/lib/raspberrypi-sys-mods/imager_custom ]; then
   /usr/lib/raspberrypi-sys-mods/imager_custom set_keymap 'fr'
   /usr/lib/raspberrypi-sys-mods/imager_custom set_timezone 'Europe/Paris'
else
   rm -f /etc/localtime
   echo "Europe/Paris" >/etc/timezone
   dpkg-reconfigure -f noninteractive tzdata
cat >/etc/default/keyboard <<'KBEOF'
XKBMODEL="pc105"
XKBLAYOUT="fr"
XKBVARIANT=""
XKBOPTIONS=""

KBEOF
   dpkg-reconfigure -f noninteractive keyboard-configuration
fi
rm -f /boot/firstrun.sh
sed -i 's| systemd.run.*||g' /boot/cmdline.txt
exit 0

@jujax
Copy link
Author

jujax commented Nov 3, 2024

my ssh public key was corrupted ...

@jujax jujax closed this as not planned Won't fix, can't repro, duplicate, stale Nov 3, 2024
@jujax jujax reopened this Nov 3, 2024
@tdewey-rpi
Copy link
Collaborator

Thanks for the report, @jujax.

Can you confirm if you can reproduce this issue?

@jujax
Copy link
Author

jujax commented Nov 6, 2024

Yes I put qffsefesf'""'"test in ssh input and boot is falling again

@lurch
Copy link
Contributor

lurch commented Nov 6, 2024

What a strange password to choose... 😉 😂

@jujax
Copy link
Author

jujax commented Nov 6, 2024

It's in ssh public key input and not password sorry for the mistake

@lurch
Copy link
Contributor

lurch commented Nov 6, 2024

Those characters aren't valid in SSH public keys anyway, so perhaps the correct fix here is to add better input-validation in the OS Customisation dialog, rather than trying to fix firstrun.sh to cope with escaping extra characters?

tdewey-rpi added a commit to tdewey-rpi/rpi-imager that referenced this issue Nov 8, 2024
Fixes raspberrypi#956

Previously we would just trust that users would include a correct SSH public key. Unfortunately, this isn't a viable stategy.

So, let's introduce a regex to perform some light validation of the ssh-key, to avoid having boot failures.
@tdewey-rpi tdewey-rpi linked a pull request Nov 8, 2024 that will close this issue
tdewey-rpi added a commit to tdewey-rpi/rpi-imager that referenced this issue Nov 8, 2024
Fixes raspberrypi#956

Previously we would just trust that users would include a correct SSH public key. Unfortunately, this isn't a viable stategy.

So, let's introduce a regex to perform some light validation of the ssh-key, to avoid having boot failures.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants