I am building some rootfs images based on generic-efi
profile. When booting the minimal
image It throws and error about the terminal because the TERM
variable is not properly set by getty systemd service.
I have tracked the issue to here. In that function $TERM
is being substituted by the build host. I am building the images on GitHub and the TERM
variable is being replaced by unknown
in this case.
The variable needs to be escaped in that configure_cli_autologin function.
This function was introduced in this MR maybe @linux-aarhus can take a look at it.
BTW, I tried to open the issue and send the fix as merge request on gitlab but I was unable to sign up. It does not seem to allow new registrations.
Thank you for reporting this. I am not the proper maintainer - I just jump in when assistance is required - and I am not an expert on bash - my apologies for the error.
The MR you mention worked as expected in local tests (buildarmimg - tested on RPI - no errors) but I can see that an unintended variable expansion could happen.
I have created a merge request with a proposed fix - escaping the \$TERM
variable and for good measure the %I
variable as well.
I also removed a doubled //
slash in the path and added a necessary check for host architecture as a qemu package required on x86_64 has been made an optional dependency.
05:35:08 ○ [fh@tiger] ~
$ [[ $(uname -r) == "x86_64" ]] && [[ $(which qemu-aarch64-static) =~ "qemu-aarch64-static" ]] || echo "This utility requires package qemu-user-static-binfmt"
This utility requires package qemu-user-static-binfmt
Can you test if this fixes your issue?
See → FIX: unintended variable expansion (!18) · Merge requests · manjaro-arm / applications / manjaro-arm-tools · GitLab
@Darksky will merge if it works as intended.
Thank you for the quick reply!
I don’t think that % symbol needs to be escaped here. In that case the output is ExecStart=-/sbin/agetty -o '-p -f -- \\u' --noclear --autologin root \%I $TERM
.
Maybe the easiest fix is to use ‘EOF’ to disable variable expansion inside the whole block:
configure_cli_autologin() {
mkdir -p $ROOTFS_IMG/rootfs_$ARCH/etc/systemd/system/getty@tty1.service.d
cat << 'EOF' >> $ROOTFS_IMG/rootfs_$ARCH/etc/systemd/system/getty@tty1.service.d/autologin.conf
[Service]
ExecStart=
ExecStart=-/sbin/agetty -o '-p -f -- \\u' --noclear --autologin root %I $TERM
EOF
}
Thank you for that tip - I will update the MR
Patch (took the opportunity to revise the x86_64 dependency check)
diff --git a/lib/functions.sh b/lib/functions.sh
index bcad9b0..fd24ff5 100755
--- a/lib/functions.sh
+++ b/lib/functions.sh
@@ -195,8 +195,11 @@ check_root () {
echo "This utility requires root permissions to run"
exit
fi
- # check if x86_64 and qemu-aarch64-static is available
- check_host_arch
+ # check if host is x86_64 and qemu-aarch64-static is available
+ [[ $(uname -r) == "x86_64" ]] && \
+ [[ $(which qemu-aarch64-static) =~ "qemu-aarch64-static" ]] || \
+ echo "ERROR: This utility requires package 'qemu-user-static-binfmt'\n" && exit 1
+
}
check_branch () {
@@ -293,16 +296,12 @@ create_rootfs_pkg() {
$NSPAWN $CHROOTDIR pacman -Syy --noprogressbar $PACMAN_COLORS
}
-check_host_arch() {
- [[ $(uname -r) == "x86_64" ]] && [[ $(which qemu-aarch64-static) =~ "qemu-aarch64-static" ]] || echo "ERROR: This utility requires package 'qemu-user-static-binfmt'\n" && exit 1
-}
-
configure_cli_autologin() {
- mkdir $ROOTFS_IMG/rootfs_$ARCH/etc/systemd/system/getty@tty1.service.d
- cat << EOF >> $ROOTFS_IMG/rootfs_$ARCH/etc/systemd/system/getty@tty1.service.d/autologin.conf
+ mkdir -p $ROOTFS_IMG/rootfs_$ARCH/etc/systemd/system/getty@tty1.service.d
+ cat << 'EOF' >> $ROOTFS_IMG/rootfs_$ARCH/etc/systemd/system/getty@tty1.service.d/autologin.conf
[Service]
ExecStart=
-ExecStart=-/sbin/agetty -o '-p -f -- \\u' --noclear --autologin root \%I \$TERM
+ExecStart=-/sbin/agetty -o '-p -f -- \\u' --noclear --autologin root %I $TERM
EOF
}
Thank you!
BTW, I have also seen that after running the OEM install script the system keeps login as root automatically on every boot. I guess that this line was supposed to delete the autologin.conf
file but the path is wrong:
rm -rf /etc/systemd/getty\@tty1.service.d
Shouldn’t it be /etc/systemd/system/getty\@tty1.service.d
?
You are correct - I remember I fixed - I must have forgotten to add it to the repo
MR for that error too.
→ Fix path (!2) · Merge requests · manjaro-arm / packages / community / manjaro-arm-oem-install · GitLab
Thank your reporting this - and letting me know
Patch
diff --git a/manjaro-arm-oem-install b/manjaro-arm-oem-install
index de3be3a..9fa2f3b 100644
--- a/manjaro-arm-oem-install
+++ b/manjaro-arm-oem-install
@@ -303,7 +303,7 @@ esac
create_oem_install
msg "Configuration complete. Cleaning up..."
-rm -rf /etc/systemd/getty\@tty1.service.d
+rm -rf /etc/systemd/system/getty\@tty1.service.d
rm /root/.bash_profile
sed -i s/"PermitRootLogin yes"/"#PermitRootLogin prohibit-password"/g /etc/ssh/sshd_config
sed -i s/"PermitEmptyPasswords yes"/"#PermitEmptyPasswords no"/g /etc/ssh/sshd_config
1 Like
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.