are posix-shell-compliant continuation lines valid/supported, or not, in /etc/default/grub ?
a recent grub package update, in ubuntu 18LTS, is breaking /etc/default/grub by mangling/overwriting users' entries, in the specific case of using continuation lines in the file/config. and, subsequently, the upgrade process on these servers.
as stated clearly at
https://www.gnu.org/software/grub/manual/grub/html_node/Simple-configuration.html#Simple-configuration-handling "... The file /etc/default/grub controls the operation of grub-mkconfig. It is sourced by a shell script, and so must be valid POSIX shell input; normally, it will just be a sequence of ‘KEY=value’ lines, but if the value contains spaces or other special characters then it must be quoted ..."
per POSIX
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_02_01 "... Escape Character (Backslash) A <backslash> that is not quoted shall preserve the literal value of the following character, with the exception of a <newline>. If a <newline> follows the <backslash>, the shell shall interpret this as line continuation. The <backslash> and <newline> shall be removed before splitting the input into tokens. Since the escaped <newline> is removed entirely from the input and is not replaced by any white space, it cannot serve as a token separator. ..."
all that's to say that continuation lines appear to be supported in posix-shell-compliant /etc/default/grub
they've been in use here, on 100s of servers, in grub configs for ages.
with grub 2.04 on other, non Ubu OS, it continues to work fine.
re: the use of continuation lines, ubu dev states that
"Regardless of what the POSIX spec says, this is highly unusual abuse of POSIX shell semantics, and I do not see a need to support it"
it'd be useful/helpful to get clear on what the 'official' grub project support for use of posix-shell-compliant continuation lines is ...
are they 'supported' as valid use in /etc/default/grub, or not?
also useful to know/understand whether any grub update can/should mangle a user's /etc/default/grub. allowed? expected?
thx!
Quoted 2 lines · PGNet Dev
a recent grub package update, in ubuntu 18LTS, is breaking
/etc/default/grubby mangling/overwriting users' entries, in the specific case of using continuation lines in the file/config. and, subsequently, the upgrade process on these servers.
This sounds like an issue you should hash out with your distro maintainer. How Ubuntu manages package upgrades is not within the scope of this mailing list.
Quoted 2 lines
it'd be useful/helpful to get clear on what the 'official' grub project support for use of posix-shell-compliant continuation lines is ... are they 'supported' as valid use in
/etc/default/grub, or not?
The manual section you quoted seems pretty clear to me: it must be valid POSIX shell input. Backslash-escaped newlines are valid POSIX shell input.
Technically speaking, /etc/default/grub is sourced by grub-mkconfig, which is executed by /bin/sh. So long as /bin/sh is able to correctly process both grub-mkconfig and /etc/default/grub, you probably wont have a problem. If /bin/sh happens to be bash, you could probably get away with putting bash-specific code in /etc/default/grub if you really wanted to.
What your distro chooses to support is really up to them, however.
Quoted 1 line
also useful to know/understand whether any grub update can/should mangle a user's
/etc/default/grub. allowed? expected?
I think this is not something the grub developers care about; work it out with your distro maintainer.
Have you opened a launchpad bug report against the grub2 package with both configs before and after? What is the bug number there?
In general, we do parse and rewrite configs using debconf which is Perl / C / Shell processing using tools external to grub. In general, we advise to customize via grub.d drop-in files instead of modifying etc/default/grub file itself.
This is a bit out of scope for the upstream mailing list, as debconf integration is downstream specific on Ubuntu/Debian systems.
Quoted 65 lines · On Thu, 19 Mar 2020, 21:20 PGNet Dev, <[email protected]> wrote:
a recent grub package update, in ubuntu 18LTS, is breaking
/etc/default/grubby mangling/overwriting users' entries, in the specific case of using continuation lines in the file/config. and, subsequently, the upgrade process on these servers.as stated clearly at
"...
The file/etc/default/grubcontrols the operation of
grub-mkconfig. It is sourced by a shell script, and so must be valid POSIX shell input; normally, it will just be a sequence of ‘KEY=value’ lines, but if the value contains spaces or other special characters then it must be quoted..."per POSIX
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_02_01
"...
Escape Character (Backslash)A <backslash> that is not quoted shall preserve the literal value
of the following character, with the exception of a <newline>. If a <newline> follows the <backslash>, the shell shall interpret this as line continuation. The <backslash> and <newline> shall be removed before splitting the input into tokens. Since the escaped <newline> is removed entirely from the input and is not replaced by any white space, it cannot serve as a token separator...."all that's to say that continuation lines appear to be supported in posix-shell-compliant
/etc/default/grubthey've been in use here, on 100s of servers, in grub configs for ages.
with grub 2.04 on other, non Ubu OS, it continues to work fine.
re: the use of continuation lines, ubu dev states that
"Regardless of what the POSIX spec says, this is highly unusual
abuse of POSIX shell semantics, and I do not see a need to support it"it'd be useful/helpful to get clear on what the 'official' grub project support for use of posix-shell-compliant continuation lines is ...
are they 'supported' as valid use in
/etc/default/grub, or not?also useful to know/understand whether any grub update can/should mangle a user's
/etc/default/grub. allowed? expected?thx!
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
hi
Quoted 1 line · Dimitri John Ledkov
What is the bug number there?
https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1868138
Quoted 1 line
In general, we advise to customize via grub.d drop-in files instead of modifying etc/default/grub file itself.
Sure, that's fine as advice. Fwiw, it's different for different distros.
Declarations that using posix-compliant continuations is "highly unusual abuse of POSIX shell semantics" is a different matter.
Changing/breaking behavior in managing valid/working grub configs, and rationalizing it by "I do not see a need to support it"
is ... unhelpful.
Particularly if Grub project/devs say that its usage *is* OK & compliant. Which is why I asked _here_; and, iiuc, seems that it *is*.
Grub's stability, reproducibility and portability are critical. It all works great, particularly when the excellent docs are followed.
Happy to take ongoing conversation to the bug.
Quoted 10 lines · Dimitri John Ledkov
Have you opened a launchpad bug report against the grub2 package with both configs before and after? What is the bug number there?
In general, we do parse and rewrite configs using debconf which is Perl / C / Shell processing using tools external to grub. In general, we advise to customize via grub.d drop-in files instead of modifying etc/default/grub file itself.
This is a bit out of scope for the upstream mailing list, as debconf integration is downstream specific on Ubuntu/Debian systems.
In general, other distros avoid parsing and rewriting configs because this should be the user's responsibility. :p
The OP should consider that maybe such distros are more stable than Ubuntu?
...
Anyway, it seems clear-cut to me, as per the question which is NOT about what should be done with debconf. The OP's question is very simple:
"Does the grub project consider /etc/default/grub as a shell-compatible file which is sourced, to be the PUBLIC INTERFACE of this configuration file?"
It seems clear-cut to me. The quoted manual section explicitly documents that it is POSIX shell format, then calls out the idea of KEY=VALUE assignments and declares this to be *merely* "normally", thus highlighting the possibility that it isn't exclusively so.
Compare this to, for example, the os-release(5) man page which states the following format for /etc/os-release:
"""
The basic file format of os-release is a newline-separated list of environment-like shell-compatible variable assignments. It is possible to source the configuration from shell scripts, however, beyond mere variable assignments, no shell features are supported (this means variable expansion is explicitly not supported), allowing applications to read the file without implementing a shell compatible execution engine. """
Note how os-release(5) explicitly goes to some lengths to declare the need for parsing this file in C, that it is *not* valid to simply use shell code, and then continues on to enumerate which subset of shell code it supports.
The conclusion is simple enough: if you are going to automatically rewrite this grub file, you must do so using a parser engine that implements POSIX shell and knows how to properly tokenize and rewrite the full range of language features permitted by POSIX shell.
Doing otherwise is YOLO, rash, buggy, and prone to breakage as demonstrated by the OP's bug report.
If a downstream project making use of grub, then goes ahead and calls the use of backslash escapes for the very simple purpose of line continuation across multiple lines (of all the things one might do in a POSIX sh formatted configuration file, this is pretty tame), an issue of "highly unusual abuse of POSIX shell semantics", this is pretty bad I have to say. Also, it's victim blaming.
Just my $0.02 as a distro person (not a grub dev).
Signature · 2 lines
Eli Schwartz Arch Linux Bug Wrangler and Trusted User
hi,
Quoted 4 lines · Eli Schwartz
In general, other distros avoid parsing and rewriting configs because this should be the user's responsibility. :p
The OP should consider that maybe such distros are more stable than Ubuntu?
I do. Where I directly control them, they're in use. It includes my own spins ... All use Grub. "Happily". ;-)
Ubu's a not-infrequent reality nonetheless.
Quoted 5 lines
The OP's question is
"Does the grub project consider
/etc/default/grubas a shell-compatible file which is sourced, to be the PUBLIC INTERFACE of this configuration file?"
yep. well restated.
Quoted 2 lines
The conclusion is simple enough: if you are going to automatically rewrite this grub file,
i'd thought that non-mangling of it would be a reasonable position; that, apparently, is not a mandate, iiuc.
tbh, i'm not clear _why_ it's being written at all. i agree with the "this should be the user's responsibility", and would add "only the user's prerogative".
but that's me. well, maybe not JUST me ...
Quoted 7 lines
you must do so using a parser engine that
implements POSIX shell and knows how to properly tokenize and rewrite the full range of language features permitted by POSIX shell.Doing otherwise is YOLO, rash, buggy, and prone to breakage as demonstrated by the OP's bug report.
Quoted 6 lines
If a downstream project making use of grub, then goes ahead and calls the use of backslash escapes for the very simple purpose of line continuation across multiple lines (of all the things one might do in a POSIX sh formatted configuration file, this is pretty tame), an issue of "highly unusual abuse of POSIX shell semantics", this is pretty bad I have to say.
+1
Quoted 1 line
Just my $0.02 as a distro person (not a grub dev).
heh. cheap at twice the price! ;-)
thx.
I am sorry which email are the "quoted" phrases from?
Because that's nothing that I have said. I hope you do understand that it is intended for all of the Ubuntu installer & upgrade integrations to keep valid configs compatible. And in general, distros do not intentially break their users for no reason. I simply stated what are the most typical and the most tested customisation and integration point for grub configs on Ubuntu, without making any statements about supportability of the configs that you have observed getting malformed.
Quoted 48 lines · On Fri, 20 Mar 2020, 01:08 PGNet Dev, <[email protected]> wrote:
hi
Quoted 1 line · Dimitri John Ledkov
What is the bug number there?
https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1868138
Quoted 1 line
In general, we advise to customize via grub.d drop-in files instead of
modifying etc/default/grub file itself.
Sure, that's fine as advice. Fwiw, it's different for different distros.
Declarations that using posix-compliant continuations is "highly unusual abuse of POSIX shell semantics" is a different matter.
Changing/breaking behavior in managing valid/working grub configs, and rationalizing it by "I do not see a need to support it"
is ... unhelpful.
Particularly if Grub project/devs say that its usage *is* OK & compliant. Which is why I asked _here_; and, iiuc, seems that it *is*.
Grub's stability, reproducibility and portability are critical. It all works great, particularly when the excellent docs are followed.
Happy to take ongoing conversation to the bug.
Quoted 9 lines · Dimitri John Ledkov
I am sorry which email are the "quoted" phrases from?
Because that's nothing that I have said. I hope you do understand that it is intended for all of the Ubuntu installer & upgrade integrations to keep valid configs compatible. And in general, distros do not intentially break their users for no reason. I simply stated what are the most typical and the most tested customisation and integration point for grub configs on Ubuntu, without making any statements about supportability of the configs that you have observed getting malformed.
It is the position of the Ubuntu developer who responded to the OP's launchpad.net bug which motivated this cross-post to the grub-devel list.
Direct link to the quoted phrases:
https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1868138/comments/4
Signature · 2 lines
Eli Schwartz Arch Linux Bug Wrangler and Trusted User
Quoted 2 lines · Eli Schwartz
Quoted 1 line · Dimitri John Ledkov
I am sorry which email are the "quoted" phrases from?
not from an email.
directly from the bug I referenced, prior to coming here:
https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1868138/comments/4
, subsequent to chats in #irc
Quoted 1 line
Quoted 1 line
Because that's nothing that I have said.
sure. that's clear, and certainly not assumed!
Quoted 3 lines
Quoted 3 lines
I hope you do understand that it
is intended for all of the Ubuntu installer & upgrade integrations to keep valid configs compatible.
That's the assumption -- or at least the hope -- for all the mainstream distros.
And Grub's certainly about as consistent/portable/reliable/cross-everything as it gets. And appears to include aforementioned Posix script compliance for the config script.
Ubu dev's proclaimation as otherwise is what caused the ... surprise ... & the questions here.
Bottom line ... Grub continues to work exactly reliably/predictably, as it should.
Ubu's install should be fixed, not hand-waved away for specious reasons.
That can be dealt with best in the bug itself.
thx.
Quoted 5 lines · PGNet Dev
Quoted 4 lines · Eli Schwartz
Quoted 3 lines · Dimitri John Ledkov
I hope you do understand that it
is intended for all of the Ubuntu installer & upgrade integrations to keep valid configs compatible.
For anyone similarly interested, it looks like Ubu 18 *LTS* will NOT be getting a fast fix for 'this' Posix support for a bit, if at all, as it remains a ... "highly unusual configuration".
https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1868138/comments/8
"So given that 8.13 is affected - which was released a year ago, and it's a highly unusual configuration, this is not in need of an urgent hotfix."
::facepalm::
Eli, your admonition to consider a more 'stable' option moves to the front of the line. Migrations to Grub + Arch & OpenSUSE spinning up today.
Thx for the comments folks.