[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Busybox 1.27 breaks kernel cmdline preseeding



On Mon, 27 Nov 2017, Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com> wrote:
> On Mon, Nov 27, 2017 at 3:08 PM, Raphael Hertzog <hertzog@debian.org> wrote:
> [...]
>> I pushed a pu/kernel-cmdline-preseed branch implementing the preseeding
>> out of /proc/cmdline. It's more elaborate than Mathieu's patch
>> (https://paste.ubuntu.com/26034695/) in that it is able to handle
>> multi-word values.
>>
>> I tested it locally and it fixes the rescue mode for me. For
>> consistency, I renamed the command and the udeb, but the only place
>> where it matters is in "debian-installer" itself where we have to update
>> the package name.
>>
>
> That will work on most arches, but not on kfreebsd/*. That said, the
> easy fix would be to look at both environment and /proc/cmdline.
>
> I *think* you only really need -e 's/\([^ =]*=[^ "]\)/\n\1/g'  -e
> "s/\([^ =]*=[^ ']\)/\n\1/g" to multiline the entries and appropriately
> handle any multiword. With my limited testing it seemed to work well,
> and would be less complex than your solution ;)
>
> Did I miss some important corner-case?

I'm not sure its important, but when testing a similar script I came up
with something that seems to give better results on the (perhaps
demented) test case I was playing with.  Here's mine:

  's/\([^= ]\+\|\([^= ]*=\("[^"]*"\|'"'[^']*'"'\|[^"'"'"' ][^ ]*\)\)\)\( \|$\)/\1\n/g'

The sed is not as nice to look at though.  I attach my test script.

BTW Should we actually be outputting the bits that contain no '=' for this?
If not, we could just pipe into:

  grep =

Cheers, Phil.

Attachment: signature.asc
Description: PGP signature

#!/bin/busybox sh

TEST='wibble x=y a/b="c '"'d'"' e" f=g h/j='"'k \"l\" m' foo bar aaa=bbb"

split_cmdline() {
  # for testing, add this echo -- instead it should just have /proc/cmdline as sed's parameter
  echo $TEST | busybox sed -e 's/\([^= ]\+\|\([^= ]*=\("[^"]*"\|'"'[^']*'"'\|[^"'"'"' ][^ ]*\)\)\)\( \|$\)/\1\n/g'
}

echo "=-=-=-=- Splitting: $TEST"
split_cmdline
echo "=-=-=-=-"

# to use merge this into the env, this should do the trick
#  { split_cmdline ; set ; } | sort -u
-- 
|)|  Philip Hands  [+44 (0)20 8530 9560]  HANDS.COM Ltd.
|-|  http://www.hands.com/    http://ftp.uk.debian.org/
|(|  Hugo-Klemm-Strasse 34,   21075 Hamburg,    GERMANY

Reply to: