Bug#939291: grub-common: /etc/grub.d/10_linux not properly escaping paths

Valentin Petzel valentin.petzel at gmail.com
Mon Sep 2 21:54:54 BST 2019


Package: grub-common
Version: 2.04-3
Severity: normal
Tags: patch

Dear Maintainer,

The grub helper script for linux menu entries does not escape strings relevant to paths &c. This can lead to problems if a system is
installed on a btrfs subvolume that contains whitespaces in its name,
resulting in a entry like this:

menuentry 'siduction 2014.1.0 indiansummer (kde) GNU/Linux' --class siduction --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-acfcc995-6784-4033-ac1e-182c11772bef' {
	load_video
	insmod gzio
	if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
	insmod part_gpt
	insmod btrfs
	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root  acfcc995-6784-4033-ac1e-182c11772bef
	else
	  search --no-floppy --fs-uuid --set=root acfcc995-6784-4033-ac1e-182c11772bef
	fi
	echo	'Loading Linux 5.2.11-towo.2-siduction-amd64 ...'
	linux	/Debian Root/boot/vmlinuz-5.2.11-towo.2-siduction-amd64 root=UUID=acfcc995-6784-4033-ac1e-182c11772bef ro rootflags=subvol=Debian Root  quiet
	echo	'Loading initial ramdisk ...'
	initrd	/Debian Root/boot/initrd.img-5.2.11-towo.2-siduction-amd64
}

This can be easily fixed by escaping the lines
linux	${rel_dirname}/${basename}.efi.signed root=${linux_root_device_thisversion} ro ${args}
linux	${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}
to
linux	'${rel_dirname}/${basename}.efi.signed' root=${linux_root_device_thisversion} ro ${args}
linux	'${rel_dirname}/${basename}' root=${linux_root_device_thisversion} ro ${args}

and the line
initrd	$(echo $initrd_path)
to
initrd	'$(echo $initrd_path)'

and the line
GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}"
to
GRUB_CMDLINE_LINUX="rootflags=subvol='${rootsubvol}' ${GRUB_CMDLINE_LINUX}"

Regards,
Valentin Petzel


-- Package-specific info:

*********************** BEGIN /proc/mounts
/dev/nvme0n1p2 / btrfs rw,relatime,ssd,space_cache,subvolid=257,subvol=/Debian\040Root 0 0
/dev/sda1 /disks/disk1part1 ext4 rw,nosuid,nodev,relatime,data=ordered 0 0
/dev/sda3 /disks/disk1part3 fuseblk rw,nosuid,nodev,noexec,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096 0 0
/dev/sda6 /disks/disk1part6 ext4 rw,nosuid,nodev,relatime,data=ordered 0 0
/dev/sda7 /disks/disk1part7 fuseblk rw,nosuid,nodev,noexec,relatime,user_id=0,group_id=0,allow_other,blksize=4096 0 0
/dev/nvme0n1p2 /disks/disk2part3 btrfs rw,nosuid,nodev,relatime,ssd,space_cache,subvolid=259,subvol=/Fast\040Storage 0 0
/dev/nvme0n1p3 /disks/disk2part4 fuseblk rw,nosuid,nodev,noexec,relatime,user_id=0,group_id=0,allow_other,blksize=4096 0 0
/dev/nvme0n1p2 /home btrfs rw,noatime,ssd,space_cache,subvolid=258,subvol=/Home 0 0
/dev/sda2 /var ext4 rw,relatime,errors=remount-ro,data=ordered 0 0
/dev/sda2 /tmp ext4 rw,nosuid,nodev,noexec,relatime,errors=remount-ro,data=ordered 0 0
/dev/nvme0n1p1 /boot/efi vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro 0 0
*********************** END /proc/mounts

*********************** BEGIN /boot/grub/grub.cfg
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
  set have_grubenv=true
  load_env
fi
if [ "${next_entry}" ] ; then
   set default="${next_entry}"
   set next_entry=
   save_env next_entry
   set boot_once=true
else
   set default="gnulinux-advanced-7ee5bbdd-21e0-4755-bec4-a03785b3fcd7>gnulinux-4.9.11-towo.2-siduction-amd64-advanced-7ee5bbdd-21e0-4755-bec4-a03785b3fcd7"
fi

if [ x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
else
  menuentry_id_option=""
fi

export menuentry_id_option

if [ "${prev_saved_entry}" ]; then
  set saved_entry="${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z "${boot_once}" ]; then
    saved_entry="${chosen}"
    save_env saved_entry
  fi
}
function load_video {
  if [ x$feature_all_video_module = xy ]; then
    insmod all_video
  else
    insmod efi_gop
    insmod efi_uga
    insmod ieee1275_fb
    insmod vbe
    insmod vga
    insmod video_bochs
    insmod video_cirrus
  fi
}

if [ x$feature_default_font_path = xy ] ; then
   font=unicode
else
insmod part_gpt
insmod btrfs
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root  acfcc995-6784-4033-ac1e-182c11772bef
else
  search --no-floppy --fs-uuid --set=root acfcc995-6784-4033-ac1e-182c11772bef
fi
    font="/Debian Root/usr/share/grub/unicode.pf2"
fi

if loadfont $font ; then
  set gfxmode=auto
  load_video
  insmod gfxterm
  set locale_dir=$prefix/locale
  set lang=C
  insmod gettext
fi
terminal_output gfxterm
if [ "${recordfail}" = 1 ] ; then
  set timeout=30
else
  if [ x$feature_timeout_style = xy ] ; then
    set timeout_style=menu
    set timeout=5
  # Fallback normal timeout code in case the timeout_style feature is
  # unavailable.
  else
    set timeout=5
  fi
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=cyan/blue
set menu_color_highlight=white/blue
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/10_linux ###
function gfxmode {
	set gfxpayload="${1}"
}
set linux_gfx_mode=
export linux_gfx_mode
menuentry 'siduction 2014.1.0 indiansummer (kde) GNU/Linux' --class siduction --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-acfcc995-6784-4033-ac1e-182c11772bef' {
	load_video
	insmod gzio
	if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
	insmod part_gpt
	insmod btrfs
	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root  acfcc995-6784-4033-ac1e-182c11772bef
	else
	  search --no-floppy --fs-uuid --set=root acfcc995-6784-4033-ac1e-182c11772bef
	fi
	echo	'Loading Linux 5.2.11-towo.2-siduction-amd64 ...'
	linux	/Debian Root/boot/vmlinuz-5.2.11-towo.2-siduction-amd64 root=UUID=acfcc995-6784-4033-ac1e-182c11772bef ro rootflags=subvol=Debian Root  quiet
	echo	'Loading initial ramdisk ...'
	initrd	/Debian Root/boot/initrd.img-5.2.11-towo.2-siduction-amd64
}
submenu 'Advanced options for siduction 2014.1.0 indiansummer (kde) GNU/Linux' $menuentry_id_option 'gnulinux-advanced-acfcc995-6784-4033-ac1e-182c11772bef' {
	menuentry 'siduction 2014.1.0 indiansummer (kde) GNU/Linux, with Linux 5.2.11-towo.2-siduction-amd64' --class siduction --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.2.11-towo.2-siduction-amd64-advanced-acfcc995-6784-4033-ac1e-182c11772bef' {
		load_video
		insmod gzio
		if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
		insmod part_gpt
		insmod btrfs
		if [ x$feature_platform_search_hint = xy ]; then
		  search --no-floppy --fs-uuid --set=root  acfcc995-6784-4033-ac1e-182c11772bef
		else
		  search --no-floppy --fs-uuid --set=root acfcc995-6784-4033-ac1e-182c11772bef
		fi
		echo	'Loading Linux 5.2.11-towo.2-siduction-amd64 ...'
		linux	/Debian Root/boot/vmlinuz-5.2.11-towo.2-siduction-amd64 root=UUID=acfcc995-6784-4033-ac1e-182c11772bef ro rootflags=subvol=Debian Root  quiet
		echo	'Loading initial ramdisk ...'
		initrd	/Debian Root/boot/initrd.img-5.2.11-towo.2-siduction-amd64
	}
}

### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/20_memtest86+ ###
menuentry "Memory test (memtest86+)" {
	insmod part_gpt
	insmod btrfs
	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root  acfcc995-6784-4033-ac1e-182c11772bef
	else
	  search --no-floppy --fs-uuid --set=root acfcc995-6784-4033-ac1e-182c11772bef
	fi
	linux16	/Debian Root/boot/memtest86+.bin
}
menuentry "Memory test (memtest86+, serial console 115200)" {
	insmod part_gpt
	insmod btrfs
	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root  acfcc995-6784-4033-ac1e-182c11772bef
	else
	  search --no-floppy --fs-uuid --set=root acfcc995-6784-4033-ac1e-182c11772bef
	fi
	linux16	/Debian Root/boot/memtest86+.bin console=ttyS0,115200n8
}
menuentry "Memory test (memtest86+, experimental multiboot)" {
	insmod part_gpt
	insmod btrfs
	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root  acfcc995-6784-4033-ac1e-182c11772bef
	else
	  search --no-floppy --fs-uuid --set=root acfcc995-6784-4033-ac1e-182c11772bef
	fi
	multiboot	/Debian Root/boot/memtest86+_multiboot.bin
}
menuentry "Memory test (memtest86+, serial console 115200, experimental multiboot)" {
	insmod part_gpt
	insmod btrfs
	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root  acfcc995-6784-4033-ac1e-182c11772bef
	else
	  search --no-floppy --fs-uuid --set=root acfcc995-6784-4033-ac1e-182c11772bef
	fi
	multiboot	/Debian Root/boot/memtest86+_multiboot.bin console=ttyS0,115200n8
}
### END /etc/grub.d/20_memtest86+ ###

### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/30_uefi-firmware ###
menuentry 'System setup' $menuentry_id_option 'uefi-firmware' {
	fwsetup
}
### END /etc/grub.d/30_uefi-firmware ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
#menuentry "Windows 7" {
#        insmod ntfs
#        set root=(hd0,1)
#        chainloader +1
#}### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###
if [ -f  ${config_directory}/custom.cfg ]; then
  source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then
  source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###
*********************** END /boot/grub/grub.cfg

*********************** BEGIN /proc/mdstat
Personalities : 
unused devices: <none>
*********************** END /proc/mdstat

*********************** BEGIN /dev/disk/by-id
total 0
lrwxrwxrwx 1 root root  9 Sep  2 21:10 ata-WDC_WD5000BPKT-75PK4T0_WD-WXS1E32RDVVX -> ../../sda
lrwxrwxrwx 1 root root 10 Sep  2 21:10 ata-WDC_WD5000BPKT-75PK4T0_WD-WXS1E32RDVVX-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10 Sep  2 21:10 ata-WDC_WD5000BPKT-75PK4T0_WD-WXS1E32RDVVX-part2 -> ../../sda2
lrwxrwxrwx 1 root root 10 Sep  2 21:10 ata-WDC_WD5000BPKT-75PK4T0_WD-WXS1E32RDVVX-part3 -> ../../sda3
lrwxrwxrwx 1 root root 10 Sep  2 21:10 ata-WDC_WD5000BPKT-75PK4T0_WD-WXS1E32RDVVX-part4 -> ../../sda4
lrwxrwxrwx 1 root root 10 Sep  2 21:10 ata-WDC_WD5000BPKT-75PK4T0_WD-WXS1E32RDVVX-part5 -> ../../sda5
lrwxrwxrwx 1 root root 10 Sep  2 21:10 ata-WDC_WD5000BPKT-75PK4T0_WD-WXS1E32RDVVX-part6 -> ../../sda6
lrwxrwxrwx 1 root root 10 Sep  2 21:10 ata-WDC_WD5000BPKT-75PK4T0_WD-WXS1E32RDVVX-part7 -> ../../sda7
lrwxrwxrwx 1 root root 13 Sep  2 21:10 nvme-Samsung_SSD_970_EVO_Plus_1TB_S4EWNF0M716332T -> ../../nvme0n1
lrwxrwxrwx 1 root root 15 Sep  2 21:10 nvme-Samsung_SSD_970_EVO_Plus_1TB_S4EWNF0M716332T-part1 -> ../../nvme0n1p1
lrwxrwxrwx 1 root root 15 Sep  2 21:10 nvme-Samsung_SSD_970_EVO_Plus_1TB_S4EWNF0M716332T-part2 -> ../../nvme0n1p2
lrwxrwxrwx 1 root root 15 Sep  2 21:10 nvme-Samsung_SSD_970_EVO_Plus_1TB_S4EWNF0M716332T-part3 -> ../../nvme0n1p3
lrwxrwxrwx 1 root root 13 Sep  2 21:10 nvme-eui.0025385791b29f24 -> ../../nvme0n1
lrwxrwxrwx 1 root root 15 Sep  2 21:10 nvme-eui.0025385791b29f24-part1 -> ../../nvme0n1p1
lrwxrwxrwx 1 root root 15 Sep  2 21:10 nvme-eui.0025385791b29f24-part2 -> ../../nvme0n1p2
lrwxrwxrwx 1 root root 15 Sep  2 21:10 nvme-eui.0025385791b29f24-part3 -> ../../nvme0n1p3
lrwxrwxrwx 1 root root  9 Sep  2 21:10 usb-SanDisk_Ultra_4C531001370526102152-0:0 -> ../../sdb
lrwxrwxrwx 1 root root 10 Sep  2 21:10 usb-SanDisk_Ultra_4C531001370526102152-0:0-part1 -> ../../sdb1
lrwxrwxrwx 1 root root  9 Sep  2 21:10 wwn-0x50014ee602ced08c -> ../../sda
lrwxrwxrwx 1 root root 10 Sep  2 21:10 wwn-0x50014ee602ced08c-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10 Sep  2 21:10 wwn-0x50014ee602ced08c-part2 -> ../../sda2
lrwxrwxrwx 1 root root 10 Sep  2 21:10 wwn-0x50014ee602ced08c-part3 -> ../../sda3
lrwxrwxrwx 1 root root 10 Sep  2 21:10 wwn-0x50014ee602ced08c-part4 -> ../../sda4
lrwxrwxrwx 1 root root 10 Sep  2 21:10 wwn-0x50014ee602ced08c-part5 -> ../../sda5
lrwxrwxrwx 1 root root 10 Sep  2 21:10 wwn-0x50014ee602ced08c-part6 -> ../../sda6
lrwxrwxrwx 1 root root 10 Sep  2 21:10 wwn-0x50014ee602ced08c-part7 -> ../../sda7
*********************** END /dev/disk/by-id

*********************** BEGIN /dev/disk/by-uuid
total 0
lrwxrwxrwx 1 root root 10 Sep  2 21:10 02650073-723c-4bce-996c-fa220599753d -> ../../sda2
lrwxrwxrwx 1 root root 10 Sep  2 21:10 12b07fd7-5b11-47cf-bf8b-eef0697b56aa -> ../../sda1
lrwxrwxrwx 1 root root 15 Sep  2 21:10 507C80AB614DDF57 -> ../../nvme0n1p3
lrwxrwxrwx 1 root root 10 Sep  2 21:10 539727D31408F97F -> ../../sda3
lrwxrwxrwx 1 root root 10 Sep  2 21:10 5DA8C1E27B89A054 -> ../../sda7
lrwxrwxrwx 1 root root 10 Sep  2 21:10 6d35c2c7-0879-4702-b363-7377876e038d -> ../../sda6
lrwxrwxrwx 1 root root 10 Sep  2 21:10 98C1-9FA0 -> ../../sdb1
lrwxrwxrwx 1 root root 15 Sep  2 21:10 BF81-3D26 -> ../../nvme0n1p1
lrwxrwxrwx 1 root root 15 Sep  2 21:10 acfcc995-6784-4033-ac1e-182c11772bef -> ../../nvme0n1p2
lrwxrwxrwx 1 root root 10 Sep  2 21:10 d79986c1-464a-4b63-84b0-647ec3785dd8 -> ../../sda5
*********************** END /dev/disk/by-uuid

-- System Information:
Debian Release: bullseye/sid
  APT prefers oldstable-proposed-updates
  APT policy: (500, 'oldstable-proposed-updates'), (500, 'unstable'), (500, 'oldstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.15.0-54-generic (SMP w/12 CPU cores)
Locale: LANG=de_AT.UTF-8, LC_CTYPE=de_AT.UTF-8 (charmap=UTF-8), LANGUAGE=de_AT.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages grub-common depends on:
ii  gettext-base        0.19.8.1-9
ii  libc6               2.28-10
ii  libdevmapper1.02.1  2:1.02.155-3
ii  libefiboot1         37-2
ii  libefivar1          37-2
ii  libfreetype6        2.9.1-4
ii  libfuse2            2.9.9-2
ii  liblzma5            5.2.4-1+b1

Versions of packages grub-common recommends:
ii  os-prober  1.77

Versions of packages grub-common suggests:
ii  console-setup  1.193
pn  desktop-base   <none>
pn  grub-emu       <none>
pn  multiboot-doc  <none>
ii  xorriso        1.5.0-1+b1

-- Configuration Files:
/etc/grub.d/10_linux changed:
set -e
prefix="/usr"
exec_prefix="/usr"
datarootdir="/usr/share"
ubuntu_recovery="0"
quiet_boot="0"
quick_boot="0"
gfxpayload_dynamic="0"
vt_handoff="0"
. "$pkgdatadir/grub-mkconfig_lib"
export TEXTDOMAIN=grub
export TEXTDOMAINDIR="${datarootdir}/locale"
CLASS="--class gnu-linux --class gnu --class os"
SUPPORTED_INITS="sysvinit:/lib/sysvinit/init systemd:/lib/systemd/systemd upstart:/sbin/upstart"
if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
  OS=GNU/Linux
else
  case ${GRUB_DISTRIBUTOR} in
    Ubuntu|Kubuntu)
      OS="${GRUB_DISTRIBUTOR}"
      ;;
    *)
      OS="${GRUB_DISTRIBUTOR} GNU/Linux"
      ;;
  esac
  CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1|LC_ALL=C sed 's,[^[:alnum:]_],_,g') ${CLASS}"
fi
case ${GRUB_DEVICE} in
  /dev/loop/*|/dev/loop[0-9])
    GRUB_DEVICE=`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"`
    # We can't cope with devices loop-mounted from files here.
    case ${GRUB_DEVICE} in
      /dev/*) ;;
      *) exit 0 ;;
    esac
  ;;
esac
GRUB_DISABLE_LINUX_PARTUUID=${GRUB_DISABLE_LINUX_PARTUUID-true}
if ( [ "x${GRUB_DEVICE_UUID}" = "x" ] && [ "x${GRUB_DEVICE_PARTUUID}" = "x" ] ) \
    || ( [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \
	&& [ "x${GRUB_DISABLE_LINUX_PARTUUID}" = "xtrue" ] ) \
    || ( ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \
	&& ! test -e "/dev/disk/by-partuuid/${GRUB_DEVICE_PARTUUID}" ) \
    || ( test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm ); then
  LINUX_ROOT_DEVICE=${GRUB_DEVICE}
elif [ "x${GRUB_DEVICE_UUID}" = "x" ] \
    || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ]; then
  LINUX_ROOT_DEVICE=PARTUUID=${GRUB_DEVICE_PARTUUID}
else
  LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
fi
case x"$GRUB_FS" in
    xbtrfs)
	rootsubvol="`make_system_path_relative_to_its_root /`"
	rootsubvol="${rootsubvol#/}"
	if [ "x${rootsubvol}" != x ]; then
	    GRUB_CMDLINE_LINUX="rootflags=subvol='${rootsubvol}' ${GRUB_CMDLINE_LINUX}"
	fi;;
    xzfs)
	rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true`
	bootfs="`make_system_path_relative_to_its_root / | sed -e "s,@$,,"`"
	LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs%/}"
	;;
esac
title_correction_code=
if [ -x /lib/recovery-mode/recovery-menu ]; then
    GRUB_CMDLINE_LINUX_RECOVERY=recovery
else
    GRUB_CMDLINE_LINUX_RECOVERY=single
fi
if [ "$ubuntu_recovery" = 1 ]; then
    GRUB_CMDLINE_LINUX_RECOVERY="$GRUB_CMDLINE_LINUX_RECOVERY nomodeset"
fi
if [ "$vt_handoff" = 1 ]; then
  for word in $GRUB_CMDLINE_LINUX_DEFAULT; do
    if [ "$word" = splash ]; then
      GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT \$vt_handoff"
    fi
  done
fi
linux_entry ()
{
  os="$1"
  version="$2"
  type="$3"
  args="$4"
  if [ -z "$boot_device_id" ]; then
      boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
  fi
  if [ x$type != xsimple ] ; then
      case $type in
	  recovery)
	      title="$(gettext_printf "%s, with Linux %s (%s)" "${os}" "${version}" "$(gettext "${GRUB_RECOVERY_TITLE}")")" ;;
	  init-*)
	      title="$(gettext_printf "%s, with Linux %s (%s)" "${os}" "${version}" "${type#init-}")" ;;
	  *)
	      title="$(gettext_printf "%s, with Linux %s" "${os}" "${version}")" ;;
      esac
      if [ x"$title" = x"$GRUB_ACTUAL_DEFAULT" ] || [ x"Previous Linux versions>$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then
	  replacement_title="$(echo "Advanced options for ${OS}" | sed 's,>,>>,g')>$(echo "$title" | sed 's,>,>>,g')"
	  quoted="$(echo "$GRUB_ACTUAL_DEFAULT" | grub_quote)"
	  title_correction_code="${title_correction_code}if [ \"x\$default\" = '$quoted' ]; then default='$(echo "$replacement_title" | grub_quote)'; fi;"
	  grub_warn "$(gettext_printf "Please don't use old title \`%s' for GRUB_DEFAULT, use \`%s' (for versions before 2.00) or \`%s' (for 2.00 or later)" "$GRUB_ACTUAL_DEFAULT" "$replacement_title" "gnulinux-advanced-$boot_device_id>gnulinux-$version-$type-$boot_device_id")"
      fi
      echo "menuentry '$(echo "$title" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-$version-$type-$boot_device_id' {" | sed "s/^/$submenu_indentation/"
  else
      echo "menuentry '$(echo "$os" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-simple-$boot_device_id' {" | sed "s/^/$submenu_indentation/"
  fi      
  if [ "$quick_boot" = 1 ]; then
      echo "	recordfail" | sed "s/^/$submenu_indentation/"
  fi
  if [ x$type != xrecovery ] ; then
      save_default_entry | grub_add_tab
  fi
  # Use ELILO's generic "efifb" when it's known to be available.
  # FIXME: We need an interface to select vesafb in case efifb can't be used.
  if [ "x$GRUB_GFXPAYLOAD_LINUX" = x ]; then
      echo "	load_video" | sed "s/^/$submenu_indentation/"
  else
      if [ "x$GRUB_GFXPAYLOAD_LINUX" != xtext ]; then
	  echo "	load_video" | sed "s/^/$submenu_indentation/"
      fi
  fi
  if ([ "$ubuntu_recovery" = 0 ] || [ x$type != xrecovery ]) && \
     ([ "x$GRUB_GFXPAYLOAD_LINUX" != x ] || [ "$gfxpayload_dynamic" = 1 ]); then
      echo "	gfxmode \$linux_gfx_mode" | sed "s/^/$submenu_indentation/"
  fi
  echo "	insmod gzio" | sed "s/^/$submenu_indentation/"
  echo "	if [ x\$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi" | sed "s/^/$submenu_indentation/"
  if [ x$dirname = x/ ]; then
    if [ -z "${prepare_root_cache}" ]; then
      prepare_root_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE} | grub_add_tab)"
    fi
    printf '%s\n' "${prepare_root_cache}" | sed "s/^/$submenu_indentation/"
  else
    if [ -z "${prepare_boot_cache}" ]; then
      prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | grub_add_tab)"
    fi
    printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/"
  fi
  if [ x"$quiet_boot" = x0 ] || [ x"$type" != xsimple ]; then
    message="$(gettext_printf "Loading Linux %s ..." ${version})"
    sed "s/^/$submenu_indentation/" << EOF
	echo	'$(echo "$message" | grub_quote)'
EOF
  fi
  if test -d /sys/firmware/efi && test -e "${linux}.efi.signed"; then
    sed "s/^/$submenu_indentation/" << EOF
	linux	'${rel_dirname}/${basename}.efi.signed' root=${linux_root_device_thisversion} ro ${args}
EOF
  else
    sed "s/^/$submenu_indentation/" << EOF
	linux	'${rel_dirname}/${basename}' root=${linux_root_device_thisversion} ro ${args}
EOF
  fi
  if test -n "${initrd}" ; then
    # TRANSLATORS: ramdisk isn't identifier. Should be translated.
    if [ x"$quiet_boot" = x0 ] || [ x"$type" != xsimple ]; then
      message="$(gettext_printf "Loading initial ramdisk ...")"
      sed "s/^/$submenu_indentation/" << EOF
	echo	'$(echo "$message" | grub_quote)'
EOF
    fi
    initrd_path=
    for i in ${initrd}; do
      initrd_path="${initrd_path} ${rel_dirname}/${i}"
    done
    sed "s/^/$submenu_indentation/" << EOF
	initrd	'$(echo $initrd_path)'
EOF
  fi
  sed "s/^/$submenu_indentation/" << EOF
}
EOF
}
machine=`uname -m`
case "x$machine" in
    xi?86 | xx86_64)
	list=
	for i in /boot/vmlinuz-* /vmlinuz-* /boot/kernel-* ; do
	    if grub_file_is_not_garbage "$i" ; then list="$list $i" ; fi
	done ;;
    *) 
	list=
	for i in /boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* /boot/kernel-* ; do
                  if grub_file_is_not_garbage "$i" ; then list="$list $i" ; fi
	done ;;
esac
case "$machine" in
    i?86) GENKERNEL_ARCH="x86" ;;
    mips|mips64) GENKERNEL_ARCH="mips" ;;
    mipsel|mips64el) GENKERNEL_ARCH="mipsel" ;;
    arm*) GENKERNEL_ARCH="arm" ;;
    *) GENKERNEL_ARCH="$machine" ;;
esac
prepare_boot_cache=
prepare_root_cache=
boot_device_id=
title_correction_code=
cat << 'EOF'
function gfxmode {
	set gfxpayload="${1}"
EOF
if [ "$vt_handoff" = 1 ]; then
  cat << 'EOF'
	if [ "${1}" = "keep" ]; then
		set vt_handoff=vt.handoff=7
	else
		set vt_handoff=
	fi
EOF
fi
cat << EOF
}
EOF
if [ "x$GRUB_GFXPAYLOAD_LINUX" != x ] || [ "$gfxpayload_dynamic" = 0 ]; then
  echo "set linux_gfx_mode=$GRUB_GFXPAYLOAD_LINUX"
else
  cat << EOF
if [ "\${recordfail}" != 1 ]; then
  if [ -e \${prefix}/gfxblacklist.txt ]; then
    if hwmatch \${prefix}/gfxblacklist.txt 3; then
      if [ \${match} = 0 ]; then
        set linux_gfx_mode=keep
      else
        set linux_gfx_mode=text
      fi
    else
      set linux_gfx_mode=text
    fi
  else
    set linux_gfx_mode=keep
  fi
else
  set linux_gfx_mode=text
fi
EOF
fi
cat << EOF
export linux_gfx_mode
EOF
submenu_indentation=""
is_top_level=true
while [ "x$list" != "x" ] ; do
  linux=`version_find_latest $list`
  case $linux in
    *.efi.signed)
      # We handle these in linux_entry.
      list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
      continue
      ;;
  esac
  gettext_printf "Found linux image: %s\n" "$linux" >&2
  basename=`basename $linux`
  dirname=`dirname $linux`
  rel_dirname=`make_system_path_relative_to_its_root $dirname`
  version=`echo $basename | sed -e "s,^[^0-9]*-,,g"`
  alt_version=`echo $version | sed -e "s,\.old$,,g"`
  linux_root_device_thisversion="${LINUX_ROOT_DEVICE}"
  initrd_early=
  for i in ${GRUB_EARLY_INITRD_LINUX_STOCK} \
	   ${GRUB_EARLY_INITRD_LINUX_CUSTOM}; do
    if test -e "${dirname}/${i}" ; then
      initrd_early="${initrd_early} ${i}"
    fi
  done
  initrd_real=
  for i in "initrd.img-${version}" "initrd-${version}.img" "initrd-${version}.gz" \
	   "initrd-${version}" "initramfs-${version}.img" \
	   "initrd.img-${alt_version}" "initrd-${alt_version}.img" \
	   "initrd-${alt_version}" "initramfs-${alt_version}.img" \
	   "initramfs-genkernel-${version}" \
	   "initramfs-genkernel-${alt_version}" \
	   "initramfs-genkernel-${GENKERNEL_ARCH}-${version}" \
	   "initramfs-genkernel-${GENKERNEL_ARCH}-${alt_version}"; do
    if test -e "${dirname}/${i}" ; then
      initrd_real="${i}"
      break
    fi
  done
  initrd=
  if test -n "${initrd_early}" || test -n "${initrd_real}"; then
    initrd="${initrd_early} ${initrd_real}"
    initrd_display=
    for i in ${initrd}; do
      initrd_display="${initrd_display} ${dirname}/${i}"
    done
    gettext_printf "Found initrd image: %s\n" "$(echo $initrd_display)" >&2
  fi
  config=
  for i in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" ; do
    if test -e "${i}" ; then
      config="${i}"
      break
    fi
  done
  initramfs=
  if test -n "${config}" ; then
      initramfs=`grep CONFIG_INITRAMFS_SOURCE= "${config}" | cut -f2 -d= | tr -d \"`
  fi
  if test -z "${initramfs}" && test -z "${initrd_real}" ; then
    # "UUID=" and "ZFS=" magic is parsed by initrd or initramfs.  Since there's
    # no initrd or builtin initramfs, it can't work here.
    if [ "x${GRUB_DEVICE_PARTUUID}" = "x" ] \
	|| [ "x${GRUB_DISABLE_LINUX_PARTUUID}" = "xtrue" ]; then
	linux_root_device_thisversion=${GRUB_DEVICE}
    else
	linux_root_device_thisversion=PARTUUID=${GRUB_DEVICE_PARTUUID}
    fi
  fi
  if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then
    linux_entry "${OS}" "${version}" simple \
    "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
    submenu_indentation="$grub_tab"
    
    if [ -z "$boot_device_id" ]; then
	boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
    fi
    # TRANSLATORS: %s is replaced with an OS name
    echo "submenu '$(gettext_printf "Advanced options for %s" "${OS}" | grub_quote)' \$menuentry_id_option 'gnulinux-advanced-$boot_device_id' {"
    is_top_level=false
  fi
  linux_entry "${OS}" "${version}" advanced \
              "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
  for supported_init in ${SUPPORTED_INITS}; do
    init_path="${supported_init#*:}"
    if [ -x "${init_path}" ] && [ "$(readlink -f /sbin/init)" != "$(readlink -f "${init_path}")" ]; then
      linux_entry "${OS}" "${version}" "init-${supported_init%%:*}" \
		  "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT} init=${init_path}"
    fi
  done
  if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then
    linux_entry "${OS}" "${version}" recovery \
                "${GRUB_CMDLINE_LINUX_RECOVERY} ${GRUB_CMDLINE_LINUX}"
  fi
  list=`echo $list | tr ' ' '\n' | fgrep -vx "$linux" | tr '\n' ' '`
done
if [ x"$is_top_level" != xtrue ]; then
  echo '}'
fi
echo "$title_correction_code"

/etc/grub.d/40_custom changed:
exec tail -n +3 $0


-- no debconf information
-------------- next part --------------
--- /home/mint/Downloads/10_linux	2019-08-30 12:50:41.000000000 +0000
+++ /mnt/etc/grub.d/10_linux	2019-09-02 20:17:52.340385152 +0000
@@ -86,7 +86,7 @@
 	rootsubvol="`make_system_path_relative_to_its_root /`"
 	rootsubvol="${rootsubvol#/}"
 	if [ "x${rootsubvol}" != x ]; then
-	    GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}"
+	    GRUB_CMDLINE_LINUX="rootflags=subvol='${rootsubvol}' ${GRUB_CMDLINE_LINUX}"
 	fi;;
     xzfs)
 	rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true`
@@ -186,11 +186,11 @@
   fi
   if test -d /sys/firmware/efi && test -e "${linux}.efi.signed"; then
     sed "s/^/$submenu_indentation/" << EOF
-	linux	${rel_dirname}/${basename}.efi.signed root=${linux_root_device_thisversion} ro ${args}
+	linux	'${rel_dirname}/${basename}.efi.signed' root=${linux_root_device_thisversion} ro ${args}
 EOF
   else
     sed "s/^/$submenu_indentation/" << EOF
-	linux	${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}
+	linux	'${rel_dirname}/${basename}' root=${linux_root_device_thisversion} ro ${args}
 EOF
   fi
   if test -n "${initrd}" ; then
@@ -206,7 +206,7 @@
       initrd_path="${initrd_path} ${rel_dirname}/${i}"
     done
     sed "s/^/$submenu_indentation/" << EOF
-	initrd	$(echo $initrd_path)
+	initrd	'$(echo $initrd_path)'
 EOF
   fi
   sed "s/^/$submenu_indentation/" << EOF


More information about the Pkg-grub-devel mailing list