[pve-devel] [PATCH v2 kernel-meta] fix #2403: exclude initrd entries from /proc/cmdline

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Oct 16 11:25:15 CEST 2019


On 10/15/19 4:45 PM, Oguz Bektas wrote:
> if we fallback to /proc/cmdline, it can include the booted initrd.
> 
> to avoid loader entries with initrd 'options' lines, we have to parse
> them out.
> 
> Signed-off-by: Oguz Bektas <o.bektas at proxmox.com>
> ---
>  efiboot/zz-pve-efiboot | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/efiboot/zz-pve-efiboot b/efiboot/zz-pve-efiboot
> index 4756555..0a22721 100755
> --- a/efiboot/zz-pve-efiboot
> +++ b/efiboot/zz-pve-efiboot
> @@ -50,7 +50,8 @@ update_esps() {
>  		CMDLINE="$(cat /etc/kernel/cmdline)"
>  	else
>  		warn "No /etc/kernel/cmdline found - falling back to /proc/cmdline"
> -		CMDLINE="$(cat /proc/cmdline)"
> +		# remove initrd entries
> +		CMDLINE="$(awk '{gsub(/\yinitrd=([0-9a-zA-Z\\.-])*\s/,x)}1' /proc/cmdline)"

above doesn't removes initrd= entries at end of line, as they are not
followed by a whitespace character (\s), maybe add a * quantifier to
that? Also forward slashes? (may not happen normally with EFI fat
partitions, but still shouldn't hurt):

awk '{ gsub(/\yinitrd=([0-9a-zA-Z\\.-\/])*\s*/,x) }1'

my test case:
# echo "initrd=/pathto\strange/file BOOT_IMAGE=/boot/vmlinuz-5.3.1-1-pve root=/dev/mapper/pve-root ro noinitrd=asdasd initrd=fooo initrd=bar" | awk '{ gsub(/\yinitrd=([0-9a-zA-Z\\.-\/])*\s*/,x) }1'

should output:
BOOT_IMAGE=/boot/vmlinuz-5.3.1-1-pve root=/dev/mapper/pve-root ro noinitrd=asdasd

>  	fi
>  
>  	loop_esp_list update_esp_func
> 





More information about the pve-devel mailing list