negativo17 / nvidia-kmod-common

NVIDIA's proprietary driver kernel module common files
4 stars 5 forks source link

Missing quotes in /etc/default/grub #7

Closed roshanshariff closed 2 years ago

roshanshariff commented 2 years ago

https://github.com/negativo17/nvidia-kmod-common/blob/71d5b9605a30fba8e1d902dee36af5d0f39ed11e/nvidia-kmod-common.spec#L85

After installing nvidia-kmod-common, my /etc/default/grub file contains the line

GRUB_CMDLINE_LINUX=rd.driver.blacklist=nouveau modprobe.blacklist=nouveau

Note the lack of double quotes, which means this is interpreted as running the command modprobe.blacklist=nouveau. This causes grub2-mkconfig to signal an error when it sources that file.

scaronni commented 2 years ago

Hello, what you pasted is not what the assembled SPEC scriptlet looks like in the rpm:

# rpm -q --scripts nvidia-kmod-common | grep "echo GRUB"
    echo GRUB_CMDLINE_LINUX="rd.driver.blacklist=nouveau" >> /etc/default/grub

And is also only done if GRUB_CMDLINE_LINUX is not already available (-z), as a safe measure in a very unlikely case the file /etc/default/grub does not contain the variable:

# rpm -q --scripts nvidia-kmod-common 
postinstall scriptlet (using /bin/sh):
/usr/sbin/grubby --update-kernel=ALL --args='rd.driver.blacklist=nouveau' --remove-args='nomodeset gfxpayload=vga=normal nouveau.modeset=0 nvidia-drm.modeset=1' &>/dev/null
if [ ! -f /run/ostree-booted ]; then
  . /etc/default/grub
  if [ -z "${GRUB_CMDLINE_LINUX}" ]; then
    echo GRUB_CMDLINE_LINUX="rd.driver.blacklist=nouveau" >> /etc/default/grub
  else
[...]
roshanshariff commented 2 years ago

That code also runs if GRUB_CMDLINE_LINUX is defined but empty (which can happen if you disable the default "rhgb quiet" options.

The shell swallows the quotes, so you need an extra escaped pair of quotes:

$ echo FOO="bar baz"
FOO=bar baz
$ echo FOO=\""bar baz"\"
FOO="bar baz"

This was not a problem earlier because %{_dracutopts} expanded to a single word, but now it's got two words and so must be quoted.

scaronni commented 2 years ago

Thanks! https://github.com/negativo17/nvidia-kmod-common/commit/a883f8d9b0f843d5200b278961723dcc7c434c52