Received: from list by lists.gnu.org with archive (Exim 4.71) id 1chUto-0004nM-Mk for mharc-grub-devel@gnu.org; Sat, 25 Feb 2017 00:28:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33322) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1chUtm-0004nA-FG for grub-devel@gnu.org; Sat, 25 Feb 2017 00:28:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1chUtj-00063G-DI for grub-devel@gnu.org; Sat, 25 Feb 2017 00:28:02 -0500 Received: from mail-lf0-x244.google.com ([2a00:1450:4010:c07::244]:34155) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1chUtj-000635-5t for grub-devel@gnu.org; Sat, 25 Feb 2017 00:27:59 -0500 Received: by mail-lf0-x244.google.com with SMTP id a198so60249lfb.1 for ; Fri, 24 Feb 2017 21:27:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=4sWi0JU6lOMrCSqQmgSJj5aBXAROXfNERokp3nc/gik=; b=sQ20UcFf/AKQnuvsOuqSut0wHziNW8zIF0gk66DG2kNDG1gdZH2+EqXklYRT1vgq7B JYyv5+T0BXgR4do6huy3Ym5xwSgzXZ/e/ilgGynY0VGHEKB7DIruFQcafycbABEJ2gD/ a/tT7TncjELtmwypAPriyYqzoKh0U3dXl4zn/4wIbiGxdh5PYDGmI7BIDDtK2ChVIRvy tQupzsHUPr+Glk/H6SHpPDBSl0JOFb6+nX7YiWlr2zaUGkLEIiYCWbv9BNU8XqrsPXMl R0OTSsJVb+bC3baLzHgLZ0NYsTYQl2GEZqon7aiTe85+xmxgcUHJO53PDe9YL1O5XKJj TNzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=4sWi0JU6lOMrCSqQmgSJj5aBXAROXfNERokp3nc/gik=; b=KsDkPYe1XDZBOWrADM57f8h/V8PRR+O2g24pMJ663UJE2Obh7uFTeNeZmG9dUiVyrH NnDmRblQZcXi/v2W9LJjFw9uzTePfPGNxh9V/XF0MkwgOWhUNxpOasGwss07CxWHXeiY 6zIbxVSWQOekvd1ym9X/T+brNTlLZ7SMTK3A3hg96Vqvr/kh9PGiCrH1ao0KMBF5Y9Cn OC1/nw5sS7yYLl4GWkPnVbWFQvSRWOf8JIOY7+Ft2zrNTjZz5BXI6232mP2QoeGGZImw PBcQVt+cYmRPrTOswjosYY/Qyu499GyXj8+LX6cV994Sc1VHQivejAh7o9Ongg5RjUWC n9bw== X-Gm-Message-State: AMke39mLLyqN9fcS7ybHreymNQMwQZCI2bEC3ijEJKYH7/ci9dQ24pwMIDefgL+2E5Je0w== X-Received: by 10.46.13.9 with SMTP id 9mr1546122ljn.40.1488000477879; Fri, 24 Feb 2017 21:27:57 -0800 (PST) Received: from [192.168.1.6] (ppp109-252-90-129.pppoe.spdop.ru. [109.252.90.129]) by smtp.gmail.com with ESMTPSA id v2sm9106317lja.31.2017.02.24.21.27.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Feb 2017 21:27:56 -0800 (PST) Subject: Re: pvgrub2 legacy_configfile issues: /sbin/init exec error -8 To: The development of GNU GRUB , Andy Smith References: <20170211135314.GY21587@bitfolk.com> <20170211152643.GH1804@bitfolk.com> <20170211171934.GJ1804@bitfolk.com> From: Andrei Borzenkov Message-ID: <847c5cb3-e850-fa3b-a483-fb8b625d7816@gmail.com> Date: Sat, 25 Feb 2017 08:27:55 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::244 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Feb 2017 05:28:03 -0000 25.02.2017 02:22, Vladimir 'phcoder' Serbinenko пишет: > On Sun, Feb 12, 2017, 11:52 Vladimir 'phcoder' Serbinenko > wrote: > >> >> >> On Sun, 12 Feb 2017, 08:06 Andrei Borzenkov wrote: >> >> 12.02.2017 00:07, Vladimir 'phcoder' Serbinenko пишет: >> ... >>>> >>> For multiboot module old grub was passing module file name on module >>> command line, so legacy_configfile should replicate this behaviour. But >> in >>> Linux case it shouldn't have ended up loading twice. We need additional >>> code in legacy_initrd. Please try the attached patch >>> >> ... >>> >>> >>> diff --git a/grub-core/commands/legacycfg.c >> b/grub-core/commands/legacycfg.c >>> index dd9d9f1..24546bf 100644 >>> --- a/grub-core/commands/legacycfg.c >>> +++ b/grub-core/commands/legacycfg.c >>> @@ -517,7 +517,7 @@ grub_cmd_legacy_initrd (struct grub_command *mycmd >> __attribute__ ((unused)), >>> #endif >>> ); >>> >>> - return cmd->func (cmd, argc, args); >>> + return cmd->func (cmd, argc ? argc - 1 : 0, args + 1); >> >> If the goal is to be compatible with legacy grub, it is not compatible >> (nor was) - legacy grub "initrd" ignored all extra arguments to "initrd" >> command while we attempt to load them as additional initrd components. >> >> Nor did legacy grub attempt to quote command line for multiboot kernel >> or modules. >> >> Agreed on both. That's why I said that previous patch is wrong and I'm >> working on new one >> > For first point, see attached patch. > Second point isn't a problem as legacycfg will already split along spaces > and hence quoting code will not be triggered. > It will. while (*c) { if (*c == '\\' || *c == '\'' || *c == '"') *buf++ = '\\'; *buf++ = *c; c++; } In particular, this is a problem with Linux which does not interpret these quotes at all (it only supports " .... " without any way to escape nested `"'). That's something for post 2.02 now, but I still would like to know what was the reason for this code in the first place. > > diff --git a/grub-core/commands/legacycfg.c b/grub-core/commands/legacycfg.c > index dd9d9f1..b32f3c7 100644 > --- a/grub-core/commands/legacycfg.c > +++ b/grub-core/commands/legacycfg.c > @@ -517,7 +517,7 @@ grub_cmd_legacy_initrd (struct grub_command *mycmd > __attribute__ ((unused)), > #endif > ); > > - return cmd->func (cmd, argc, args); > + return cmd->func (cmd, argc ? 1 : 0, args); > } > if (kernel_type == MULTIBOOT) > { > Looks OK as stop gap. @Andy, could you test it? I still do not understand why initrd is parsed as TYPE_FILE_NO_CONSUME, nor why we handle multiboot kernel in legacy_initrd in the first place. Legacy grub only supported Linux kernel with initrd command. switch (kernel_type) { case KERNEL_TYPE_LINUX: case KERNEL_TYPE_BIG_LINUX: if (! load_initrd (arg)) return 1; break; default: errnum = ERR_NEED_LX_KERNEL; return 1; } Although this probably does not really matter now.