From 52ae9c9e16b7d6d7a8be8a3575a2f2e7237da493 Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Thu, 12 Nov 2026 05:12:30 +0100 Subject: [PATCH] Fix profile installedargs on Debian, Ubuntu and SUSE On Debian and Ubuntu 18.04 the installedargs line of profile.yaml was added to GRUB_CMDLINE_LINUX with its "installedargs:" key still in front, and update-grub was not run for it, so the arguments only took effect with a later grub update, as a broken first argument. All Debian and Ubuntu profiles also put the arguments into a sed replacement unescaped, so an argument containing a slash, such as rd.lvm.lv=vg/root, made sed fail and left the grub defaults unchanged. SUSE 16 put the arguments into a JSON string unescaped, so an argument containing a double quote or backslash produced an invalid autoinstall.json, and one containing "!" or "&" broke the sed command that fills it in. SUSE 15 put them into the AutoYaST XML unescaped, so an argument containing "&" or "<" made the whole profile invalid and stopped the install. --- confluent_osdeploy/debian/profiles/default/scripts/post.sh | 4 +++- .../suse15/initramfs/opt/confluent/bin/suseagent | 1 + confluent_osdeploy/suse16/profiles/server/scripts/pre.sh | 1 + .../ubuntu18.04/profiles/default/scripts/post.sh | 4 +++- .../ubuntu20.04/profiles/default/scripts/post.sh | 1 + .../ubuntu22.04/profiles/default/scripts/post.sh | 1 + 6 files changed, 10 insertions(+), 2 deletions(-) diff --git a/confluent_osdeploy/debian/profiles/default/scripts/post.sh b/confluent_osdeploy/debian/profiles/default/scripts/post.sh index f30d980f..2c8c6923 100755 --- a/confluent_osdeploy/debian/profiles/default/scripts/post.sh +++ b/confluent_osdeploy/debian/profiles/default/scripts/post.sh @@ -41,9 +41,11 @@ if [ "$textcons" = "true" ] && ! grep console= /proc/cmdline > /dev/null; then updategrub=1 fi fi -kargs=$(python3 /opt/confluent/bin/apiclient /confluent-public/os/$confluent_profile/profile.yaml | grep ^installedargs: | sed -e 's/#.*//') +kargs=$(python3 /opt/confluent/bin/apiclient /confluent-public/os/$confluent_profile/profile.yaml | grep ^installedargs: | sed -e 's/^installedargs:[[:space:]]*//' -e 's/#.*//') if [ ! -z "$kargs" ]; then + kargs=$(printf '%s' "$kargs" | sed -e 's/[\/&]/\\&/g') sed -i 's/GRUB_CMDLINE_LINUX="\([^"]*\)"/GRUB_CMDLINE_LINUX="\1 '"${kargs}"'"/' /etc/default/grub + updategrub=1 fi if [ 1 = $updategrub ]; then diff --git a/confluent_osdeploy/suse15/initramfs/opt/confluent/bin/suseagent b/confluent_osdeploy/suse15/initramfs/opt/confluent/bin/suseagent index 9b26dfdf..48b0672f 100755 --- a/confluent_osdeploy/suse15/initramfs/opt/confluent/bin/suseagent +++ b/confluent_osdeploy/suse15/initramfs/opt/confluent/bin/suseagent @@ -229,6 +229,7 @@ append=$(grep ^installedargs: /tmp/profile.yaml | sed -e 's/^installedargs: //' if grep console= /etc/fakecmdline >& /dev/null && [[ "$append" != *console=* ]]; then append="$append console=${autocons#*/dev/}" fi +append=$(printf '%s' "$append" | sed -e 's/&/\&/g' -e 's//\>/g') if [ -z "$append" ]; then echo "" > /tmp/bootloader.xml else diff --git a/confluent_osdeploy/suse16/profiles/server/scripts/pre.sh b/confluent_osdeploy/suse16/profiles/server/scripts/pre.sh index db23ef73..102a78e4 100644 --- a/confluent_osdeploy/suse16/profiles/server/scripts/pre.sh +++ b/confluent_osdeploy/suse16/profiles/server/scripts/pre.sh @@ -46,6 +46,7 @@ sed -i 's@%%ROOTPASSWORD%%@'"$rootpw"'@g' /tmp/autoinstall.json sed -i s!%%NODENAME%%!$(hostname)!g /tmp/autoinstall.json python3 /opt/confluent/bin/apiclient /confluent-public/os/$profile/profile.yaml > /tmp/instprofile.yaml blargs=$(grep ^installedargs: /tmp/instprofile.yaml | sed -e 's/#.*//' -e 's/^installedargs: //') +blargs=$(printf '%s' "$blargs" | sed -e 's/[\\"]/\\&/g' -e 's/[\\&!]/\\&/g') sed -i 's!%%INSTALLEDARGS%%!'"$blargs"'!g' /tmp/autoinstall.json python3 /opt/confluent/bin/apiclient /confluent-public/os/$profile/scripts/getinstalldisk > /tmp/getinstalldisk locale=$(grep ^locale: /etc/confluent/confluent.deploycfg) diff --git a/confluent_osdeploy/ubuntu18.04/profiles/default/scripts/post.sh b/confluent_osdeploy/ubuntu18.04/profiles/default/scripts/post.sh index f30d980f..2c8c6923 100755 --- a/confluent_osdeploy/ubuntu18.04/profiles/default/scripts/post.sh +++ b/confluent_osdeploy/ubuntu18.04/profiles/default/scripts/post.sh @@ -41,9 +41,11 @@ if [ "$textcons" = "true" ] && ! grep console= /proc/cmdline > /dev/null; then updategrub=1 fi fi -kargs=$(python3 /opt/confluent/bin/apiclient /confluent-public/os/$confluent_profile/profile.yaml | grep ^installedargs: | sed -e 's/#.*//') +kargs=$(python3 /opt/confluent/bin/apiclient /confluent-public/os/$confluent_profile/profile.yaml | grep ^installedargs: | sed -e 's/^installedargs:[[:space:]]*//' -e 's/#.*//') if [ ! -z "$kargs" ]; then + kargs=$(printf '%s' "$kargs" | sed -e 's/[\/&]/\\&/g') sed -i 's/GRUB_CMDLINE_LINUX="\([^"]*\)"/GRUB_CMDLINE_LINUX="\1 '"${kargs}"'"/' /etc/default/grub + updategrub=1 fi if [ 1 = $updategrub ]; then diff --git a/confluent_osdeploy/ubuntu20.04/profiles/default/scripts/post.sh b/confluent_osdeploy/ubuntu20.04/profiles/default/scripts/post.sh index 7f234737..4ec66bdd 100755 --- a/confluent_osdeploy/ubuntu20.04/profiles/default/scripts/post.sh +++ b/confluent_osdeploy/ubuntu20.04/profiles/default/scripts/post.sh @@ -48,6 +48,7 @@ if [ "$textcons" = "true" ] && ! grep console= /proc/cmdline > /dev/null; then fi kargs=$(curl https://$confluent_mgr/confluent-public/os/$confluent_profile/profile.yaml | grep ^installedargs: | sed -e 's/^installedargs:[[:space:]]*//' -e 's/#.*//') if [ ! -z "$kargs" ]; then + kargs=$(printf '%s' "$kargs" | sed -e 's/[\/&]/\\&/g') sed -i 's/GRUB_CMDLINE_LINUX="\([^"]*\)"/GRUB_CMDLINE_LINUX="\1 '"${kargs}"'"/' /target/etc/default/grub updategrub=1 fi diff --git a/confluent_osdeploy/ubuntu22.04/profiles/default/scripts/post.sh b/confluent_osdeploy/ubuntu22.04/profiles/default/scripts/post.sh index 9c07cd14..e30bf732 100755 --- a/confluent_osdeploy/ubuntu22.04/profiles/default/scripts/post.sh +++ b/confluent_osdeploy/ubuntu22.04/profiles/default/scripts/post.sh @@ -48,6 +48,7 @@ if [ "$textcons" = "true" ] && ! grep console= /proc/cmdline > /dev/null; then fi kargs=$(curl https://$confluent_mgr/confluent-public/os/$confluent_profile/profile.yaml | grep ^installedargs: | sed -e 's/^installedargs:[[:space:]]*//' -e 's/#.*//') if [ ! -z "$kargs" ]; then + kargs=$(printf '%s' "$kargs" | sed -e 's/[\/&]/\\&/g') sed -i 's/GRUB_CMDLINE_LINUX="\([^"]*\)"/GRUB_CMDLINE_LINUX="\1 '"${kargs}"'"/' /target/etc/default/grub updategrub=1 fi