[pve-devel] [PATCH installer v3 1/3] low level: config: filter out kernel cmdline on word boundaries

Christoph Heiss c.heiss at proxmox.com
Mon Nov 11 12:05:15 CET 2024


Otherwise, substrings might get replaced, e.g. the replacement
`proxmox-start-auto-installer` -> `pxmox-start-auto-installer` would be
done.

Fixes: a02a78a ("fix #4747: pass kernel cmdline parameters to target system")
Suggested-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
Signed-off-by: Christoph Heiss <c.heiss at proxmox.com>
---
Changes v2 -> v3:
  * rebased on latest master

Changes v1 -> v2:
  * split commandline along whitespace and filter individually, to avoid
    problems with regexes and word boundaries

 Proxmox/Install/Config.pm | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/Proxmox/Install/Config.pm b/Proxmox/Install/Config.pm
index d604676..4152a77 100644
--- a/Proxmox/Install/Config.pm
+++ b/Proxmox/Install/Config.pm
@@ -43,10 +43,12 @@ my sub parse_kernel_cmdline {
 	}
     }
 
-    $cmdline =~ s/(?:BOOT_IMAGE|root|ramdisk_size|splash|vga)=\S+\s?//gi;
-    $cmdline =~ s/ro|rw|quiet|proxdebug|proxtui//gi;
+    my @filtered = grep {
+	$_ !~ m/^(BOOT_IMAGE|root|ramdisk_size|splash|vga)=\S+$/ &&
+	$_ !~ m/^(ro|rw|quiet|proxdebug|proxtui)$/
+    } split(/\s+/, $cmdline);
 
-    $cfg->{target_cmdline}= $cmdline;
+    $cfg->{target_cmdline} = join(' ', @filtered);
 
     return $cfg;
 }
-- 
2.47.0





More information about the pve-devel mailing list