All of lore.kernel.org
 help / color / mirror / Atom feed
* avoiding quotes in kernel cmdline
@ 2020-03-13 11:02 Olaf Hering
  2020-03-13 11:59 ` Daniel Kiper
  0 siblings, 1 reply; 8+ messages in thread
From: Olaf Hering @ 2020-03-13 11:02 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 564 bytes --]

With code like this, the resulting kernel cmdline has backslashes before either ' or ".
I think var="\"str\"" or var="'str'" has to be used to place either " or ' into the variable.
How can I avoid the backslash in the kernel cmdline?

udev_rule="udev.rule=\"mac=${net_default_mac},name=uplink\""
udev_rule="udev.rule='mac=${net_default_mac},name=uplink'"
cmdline="${udev_rule} install=${install} start_shell linemode=1 console=ttyS0,115200"
menuentry "boot" {
 linux  (http,${ip})/path/to/linux ${cmdline}
 initrd (http,${ip})/path/to/initrd
}

Olaf

[-- Attachment #2: Digitale Signatur von OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: avoiding quotes in kernel cmdline
  2020-03-13 11:02 avoiding quotes in kernel cmdline Olaf Hering
@ 2020-03-13 11:59 ` Daniel Kiper
  2020-03-13 12:32   ` Olaf Hering
  0 siblings, 1 reply; 8+ messages in thread
From: Daniel Kiper @ 2020-03-13 11:59 UTC (permalink / raw)
  To: Olaf Hering; +Cc: grub-devel

On Fri, Mar 13, 2020 at 12:02:50PM +0100, Olaf Hering wrote:
> With code like this, the resulting kernel cmdline has backslashes before either ' or ".
> I think var="\"str\"" or var="'str'" has to be used to place either " or ' into the variable.
> How can I avoid the backslash in the kernel cmdline?
>
> udev_rule="udev.rule=\"mac=${net_default_mac},name=uplink\""
> udev_rule="udev.rule='mac=${net_default_mac},name=uplink'"
> cmdline="${udev_rule} install=${install} start_shell linemode=1 console=ttyS0,115200"
> menuentry "boot" {
>  linux  (http,${ip})/path/to/linux ${cmdline}
>  initrd (http,${ip})/path/to/initrd
> }

Both var="\"str\"" and var="'str'" should work. Does not they? Do you
still get backslashes in ${cmdline}?

Daniel


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: avoiding quotes in kernel cmdline
  2020-03-13 11:59 ` Daniel Kiper
@ 2020-03-13 12:32   ` Olaf Hering
  2020-03-13 14:07     ` Daniel Kiper
  0 siblings, 1 reply; 8+ messages in thread
From: Olaf Hering @ 2020-03-13 12:32 UTC (permalink / raw)
  To: Daniel Kiper; +Cc: grub-devel

[-- Attachment #1: Type: text/plain, Size: 700 bytes --]

Am Fri, 13 Mar 2020 12:59:32 +0100
schrieb Daniel Kiper <dkiper@net-space.pl>:

> Both var="\"str\"" and var="'str'" should work. Does not they? Do you
> still get backslashes in ${cmdline}?

Yes. I think the issue might be the "final expansion" in the menuentry and/or linux command?

# grub.cfg 
insmod part_msdos
insmod ext2
serial --unit=0 --speed=115200
terminal_input serial
terminal_output serial

var="\"str\""
cmdline="${var} console=ttyS0,115200 quiet"
menuentry 'ROOT' {
 search --no-floppy --label --set=root ROOT
linux ($root)/boot/vmlinuz ${cmdline}
initrd ($root)/boot/initrd
}

BOOT_IMAGE=(hd0,msdos2)/boot/vmlinuz \"str\" console=ttyS0,115200 quiet


Olaf

[-- Attachment #2: Digitale Signatur von OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: avoiding quotes in kernel cmdline
  2020-03-13 12:32   ` Olaf Hering
@ 2020-03-13 14:07     ` Daniel Kiper
  2020-03-13 14:20       ` Olaf Hering
  0 siblings, 1 reply; 8+ messages in thread
From: Daniel Kiper @ 2020-03-13 14:07 UTC (permalink / raw)
  To: Olaf Hering; +Cc: grub-devel

On Fri, Mar 13, 2020 at 01:32:12PM +0100, Olaf Hering wrote:
> Am Fri, 13 Mar 2020 12:59:32 +0100
> schrieb Daniel Kiper <dkiper@net-space.pl>:
>
> > Both var="\"str\"" and var="'str'" should work. Does not they? Do you
> > still get backslashes in ${cmdline}?
>
> Yes. I think the issue might be the "final expansion" in the menuentry and/or linux command?
>
> # grub.cfg
> insmod part_msdos
> insmod ext2
> serial --unit=0 --speed=115200
> terminal_input serial
> terminal_output serial
>
> var="\"str\""
> cmdline="${var} console=ttyS0,115200 quiet"
> menuentry 'ROOT' {
>  search --no-floppy --label --set=root ROOT
> linux ($root)/boot/vmlinuz ${cmdline}
> initrd ($root)/boot/initrd
> }
>
> BOOT_IMAGE=(hd0,msdos2)/boot/vmlinuz \"str\" console=ttyS0,115200 quiet

Hmmm... Strange... When I was testing similar thing some time ago it
worked without any issue. However, IIRC, I was just testing how it works
with the echo command. Anyway, could you check what is going on and
prepare a patch if needed?

Daniel


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: avoiding quotes in kernel cmdline
  2020-03-13 14:07     ` Daniel Kiper
@ 2020-03-13 14:20       ` Olaf Hering
  2020-03-13 14:26         ` Daniel Kiper
  0 siblings, 1 reply; 8+ messages in thread
From: Olaf Hering @ 2020-03-13 14:20 UTC (permalink / raw)
  To: Daniel Kiper; +Cc: grub-devel

[-- Attachment #1: Type: text/plain, Size: 355 bytes --]

Am Fri, 13 Mar 2020 15:07:57 +0100
schrieb Daniel Kiper <dkiper@net-space.pl>:

>  Anyway, could you check what is going on and prepare a patch if needed?

Sure I can wipe the offending lines from grub_create_loader_cmdline().
The question is rather what the purpose of the new code added in  
25953e10553dad2e378541a68686fc094603ec54 is.

Olaf

[-- Attachment #2: Digitale Signatur von OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: avoiding quotes in kernel cmdline
  2020-03-13 14:20       ` Olaf Hering
@ 2020-03-13 14:26         ` Daniel Kiper
  2020-03-13 14:47           ` Olaf Hering
  2020-03-18 11:14           ` Olaf Hering
  0 siblings, 2 replies; 8+ messages in thread
From: Daniel Kiper @ 2020-03-13 14:26 UTC (permalink / raw)
  To: Olaf Hering; +Cc: grub-devel, phcoder

On Fri, Mar 13, 2020 at 03:20:08PM +0100, Olaf Hering wrote:
> Am Fri, 13 Mar 2020 15:07:57 +0100
> schrieb Daniel Kiper <dkiper@net-space.pl>:
>
> >  Anyway, could you check what is going on and prepare a patch if needed?
>
> Sure I can wipe the offending lines from grub_create_loader_cmdline().
> The question is rather what the purpose of the new code added in
> 25953e10553dad2e378541a68686fc094603ec54 is.

Adding Vladimir. There is a chance that he knows why it was added...

Daniel


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: avoiding quotes in kernel cmdline
  2020-03-13 14:26         ` Daniel Kiper
@ 2020-03-13 14:47           ` Olaf Hering
  2020-03-18 11:14           ` Olaf Hering
  1 sibling, 0 replies; 8+ messages in thread
From: Olaf Hering @ 2020-03-13 14:47 UTC (permalink / raw)
  To: Daniel Kiper; +Cc: grub-devel, phcoder

[-- Attachment #1: Type: text/plain, Size: 845 bytes --]

Am Fri, 13 Mar 2020 15:26:33 +0100
schrieb Daniel Kiper <dkiper@net-space.pl>:

> Adding Vladimir. There is a chance that he knows why it was added...

I just checked why this did not show up earlier.

With 20190718T143316.4e75b2ae3 and command "linux ($root)/file var='str'" nothing is escaped.
The command "linux ($root)/boot/vmlinuz ${cmdline} var="str" var='str'" from my earlier example results in this cmdline:

BOOT_IMAGE=(hd0,msdos2)/boot/vmlinuz \"str1\" \'str2\' console=ttyS0,115200 quiet var=str var=str

I just noticed now that in the production code I use since months the single quotes disappeared, and the consumers of /proc/cmdline do not care about this detail.

So in the end I may just remove the existing single quote from my code any everything should work fine for the consumers of /proc/cmdline.


Olaf

[-- Attachment #2: Digitale Signatur von OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: avoiding quotes in kernel cmdline
  2020-03-13 14:26         ` Daniel Kiper
  2020-03-13 14:47           ` Olaf Hering
@ 2020-03-18 11:14           ` Olaf Hering
  1 sibling, 0 replies; 8+ messages in thread
From: Olaf Hering @ 2020-03-18 11:14 UTC (permalink / raw)
  To: Daniel Kiper; +Cc: grub-devel, phcoder

[-- Attachment #1: Type: text/plain, Size: 254 bytes --]

Am Fri, 13 Mar 2020 15:26:33 +0100
schrieb Daniel Kiper <dkiper@net-space.pl>:

> Adding Vladimir. There is a chance that he knows why it was added...

In the end this knowledge does not matter much I think.
I sent a patch to fix the bug.

Olaf

[-- Attachment #2: Digitale Signatur von OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-03-18 11:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-13 11:02 avoiding quotes in kernel cmdline Olaf Hering
2020-03-13 11:59 ` Daniel Kiper
2020-03-13 12:32   ` Olaf Hering
2020-03-13 14:07     ` Daniel Kiper
2020-03-13 14:20       ` Olaf Hering
2020-03-13 14:26         ` Daniel Kiper
2020-03-13 14:47           ` Olaf Hering
2020-03-18 11:14           ` Olaf Hering

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.