From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Vl6Q4-0007FA-Er for mharc-grub-devel@gnu.org; Mon, 25 Nov 2013 19:22:24 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41849) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vl6Px-0007Do-Bl for grub-devel@gnu.org; Mon, 25 Nov 2013 19:22:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vl6Pr-0006VM-Vm for grub-devel@gnu.org; Mon, 25 Nov 2013 19:22:17 -0500 Received: from mail-ea0-x233.google.com ([2a00:1450:4013:c01::233]:50353) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vl6Pr-0006VB-KD for grub-devel@gnu.org; Mon, 25 Nov 2013 19:22:11 -0500 Received: by mail-ea0-f179.google.com with SMTP id r15so3033471ead.10 for ; Mon, 25 Nov 2013 16:22:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type; bh=VRUEnMic83sW3FllfnOI6UJb2fWvF3janf6GcCEmXAM=; b=aLqN6viS4OxQ342yCa38qMJTP5KfAlKg3DgpdxeBK+3iArXi/da5tTWXQqdpzS06/C YYaF4d2nMEAYhYiZVxWLgxD/48pbnnXe1mklDu+h+6bRg3qy++4W+HjIG9V/USzN1P3w pnfmASm+pRB7eRnDzvtmRGJY85bAjLxyhR3PdCSPdzeTc9bFNwFPfQhoW6PuQEIo/Xp/ Yud/KlPrx+smNa+L3dJ57HrR/NNY/YO+CMiEcSE+RfBNEhps6xXJ/o0x/wO12Ho874O3 b+Fa15H62n2m6L5ftd2N+PeGB4yr/SY5C1yWoHuUmeT18hQLh3maiu9W1FjTCieaUS+g Y0MQ== X-Received: by 10.15.63.134 with SMTP id m6mr508969eex.74.1385425330582; Mon, 25 Nov 2013 16:22:10 -0800 (PST) Received: from [192.168.1.121] (31-249.1-85.cust.bluewin.ch. [85.1.249.31]) by mx.google.com with ESMTPSA id a51sm3693828eeh.8.2013.11.25.16.22.09 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Nov 2013 16:22:09 -0800 (PST) Message-ID: <5293E9B0.3090804@gmail.com> Date: Tue, 26 Nov 2013 01:22:08 +0100 From: =?UTF-8?B?VmxhZGltaXIgJ8+GLWNvZGVyL3BoY29kZXInIFNlcmJpbmVua28=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131005 Icedove/17.0.9 MIME-Version: 1.0 To: grub-devel@gnu.org Subject: Re: PATCH: added GRUB command to get and set (U)EFI firmware variables References: <5293C281.4080601@gmail.com> <5293C927.8080208@gmail.com> <5293CA3A.7090702@gmail.com> <5293CF1F.9070009@gmail.com> In-Reply-To: <5293CF1F.9070009@gmail.com> X-Enigmail-Version: 1.5.1 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="----enig2DIAVFNXWRFUQWBWGREVW" X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4013:c01::233 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Nov 2013 00:22:22 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) ------enig2DIAVFNXWRFUQWBWGREVW Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 25.11.2013 23:28, SevenBits wrote: >=20 > On 11/25/2013 05:07 PM, Vladimir '?-coder/phcoder' Serbinenko wrote: >> On 25.11.2013 23:03, SevenBits wrote: >>> >>> Thanks for your quick reply. >>> >>> I just have a couple of questions. How do you prefer I allow the user= to >>> specify the vendor UUID? By typing it in via the keyboard? And second= ly, >>> by saying it needs "readable aliases for known types" do you mean tha= t >>> there should be a function to set an integer, one to set a boolean, e= tc? >>> >> I meant for UUIDs. E.g. one alias "efi" for shared space, "apple" for >> apple and so on. > So other than a generic variable UUID and Apple, are there others that > you think might be necessary? I can try and put in some common ones but= > manufacturers may not disclose what their specific UUIDs are. >=20 I'd include a command to list variables (interactively). We would pretty quickly collect most common UUIDs this way. >> But type of variable is also an issue and there should be at least >> following available: >> hex - transform all in hex >> utf16 - decode utf16 into utf8 >> Probably more, didn't really look into issue > I see, okay, I'll add some in. >=20 >>> Regarding the patch format, I'll tidy that up and send a proper one. >>> >>> -- SevenBits >>> >>> On 11/25/2013 04:41 PM, Vladimir 'phcoder' Serbinenko wrote: >>>> please resend as proper and not as reverse patch. Anotjer issie that= > can be >>>> seen from description alone is that you don't allow to specify vendo= r >>> uuid. >>>> it would be needed and slso it needs readable aliases for known type= s >>>> On Nov 25, 2013 10:35 PM, "SevenBits" wrot= e: >>> >>>>> Hello everyone, >>>>> >>>>> This patch adds two GRUB two commands to allow the user to get and = set >>>>> the values of (U)EFI firmware variables. When dealing with (U)EFI >>>>> firmware with GRUB I decided this would be a useful tool to have fo= r >>>>> both developers and end-users. >>>>> >>>>> The first command, setefivariable, takes two parameters: the name > of the >>>>> variable to set and its value. The second, getefivariable, also tak= es >>>>> two parameters: the name of the variable to retrieve and the name > of the >>>>> GRUB environment variable in which you want to store the result. Th= is >>>>> can then be checked using GRUB's built in 'if' statement and script= ing >>>>> capability to allow unique booting capabilities based on whether, f= or >>>>> example, secure boot is enabled or the (U)EFI firmware is in setup > mode. >>>>> >>>>> Have a look and let me know what you think! The patch follows. >>>>> >>>>> -- SevenBits >>>>> >>>>> diff --git a/grub/grub-core/Makefile.core.def >>>>> b/grub-orig/grub-core/Makefile.core.def >>>>> index 177d6d6..5cd84b1 100644 >>>>> --- a/grub/grub-core/Makefile.core.def >>>>> +++ b/grub-orig/grub-core/Makefile.core.def >>>>> @@ -1004,13 +1004,6 @@ module =3D { >>>>> }; >>>>> >>>>> module =3D { >>>>> - name =3D setvariable; >>>>> - common =3D commands/efi/setvariable.c; >>>>> - enable =3D i386_efi; >>>>> - enable =3D x86_64_efi; >>>>> -}; >>>>> - >>>>> -module =3D { >>>>> name =3D pcidump; >>>>> common =3D commands/pcidump.c; >>>>> enable =3D pci; >>>>> diff --git a/grub/grub-core/commands/efi/setvariable.c >>>>> b/grub/grub-core/commands/efi/setvariable.c >>>>> deleted file mode 100644 >>>>> index b0d0967..0000000 >>>>> --- a/grub/grub-core/commands/efi/setvariable.c >>>>> +++ /dev/null >>>>> @@ -1,96 +0,0 @@ >>>>> -/* setvariable.c - get and set efi firmware variables */ >>>>> -/* >>>>> - * GRUB -- GRand Unified Bootloader >>>>> - * Copyright (C) 2013 Free Software Foundation, Inc. >>>>> - * >>>>> - * GRUB is free software: you can redistribute it and/or modify >>>>> - * it under the terms of the GNU General Public License as > published by >>>>> - * the Free Software Foundation, either version 3 of the License,= or >>>>> - * (at your option) any later version. >>>>> - * >>>>> - * GRUB is distributed in the hope that it will be useful, >>>>> - * but WITHOUT ANY WARRANTY; without even the implied warranty of= >>>>> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >>>>> - * GNU General Public License for more details. >>>>> - * >>>>> - * You should have received a copy of the GNU General Public Lice= nse >>>>> - * along with GRUB. If not, see . >>>>> - */ >>>>> - >>>>> -#include >>>>> -#include >>>>> -#include >>>>> -#include >>>>> -#include >>>>> -#include >>>>> -#include >>>>> -#include >>>>> - >>>>> -GRUB_MOD_LICENSE ("GPLv3+"); >>>>> - >>>>> -static grub_err_t >>>>> -grub_cmd_setefivariable (grub_command_t cmd __attribute__ ((unused= )), >>>>> - int argc, char *argv[]) >>>>> -{ >>>>> - grub_efi_guid_t global =3D GRUB_EFI_GLOBAL_VARIABLE_GUID; >>>>> - if (argc =3D=3D 0) >>>>> - return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("efi variable= > name >>>>> expected")); >>>>> - else if (argc =3D=3D 1) >>>>> - return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("efi variable= > name >>>>> value expected")); >>>>> - >>>>> - grub_err_t status; >>>>> - grub_size_t arg_size =3D (grub_strlen(argv[1]) + 1) * sizeof(c= har); >>>>> - >>>>> - status =3D grub_efi_set_variable (argv[0], &global, argv[1], >>> arg_size); >>>>> - if (status !=3D GRUB_ERR_NONE) >>>>> - { >>>>> - grub_printf ("couldn't set efi variable"); >>>>> - return status; >>>>> - } >>>>> - return 0; >>>>> -} >>>>> - >>>>> -static grub_err_t >>>>> -grub_cmd_getefivariable (grub_command_t cmd __attribute__ ((unused= )), >>>>> - int argc, char *argv[]) >>>>> -{ >>>>> - grub_efi_guid_t global =3D GRUB_EFI_GLOBAL_VARIABLE_GUID; >>>>> - if (argc =3D=3D 0) >>>>> - return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("efi variable= > name >>>>> expected")); >>>>> - else if (argc =3D=3D 1) >>>>> - return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("efi variable= > name >>>>> value expected")); >>>>> - >>>>> - grub_size_t var_size; >>>>> - grub_err_t status; >>>>> - char *value =3D (char*)grub_efi_get_variable (argv[0], &global= , >>>>> &var_size); >>>>> - status =3D grub_env_set (argv[1], value); >>>>> - if (status !=3D GRUB_ERR_NONE) >>>>> - { >>>>> - grub_printf ("couldn't set environment variable"); >>>>> - return status; >>>>> - } >>>>> - return 0; >>>>> -} >>>>> - >>>>> -static grub_command_t cmd_setefivariable, cmd_getefivariable; >>>>> - >>>>> -GRUB_MOD_INIT(loadbios) >>>>> -{ >>>>> - cmd_setefivariable =3D grub_register_command ("setefivariable", >>>>> grub_cmd_setefivariable, >>>>> - N_("NAME VALUE"), >>>>> - N_("Set an EFI firmware variable " >>>>> - "which can be stored and retrieved " >>>>> - "from between sessions.")); >>>>> - >>>>> - cmd_getefivariable =3D grub_register_command ("getefivariable", >>>>> grub_cmd_getefivariable, >>>>> - N_("NAME ENV_VARIABLE"), >>>>> - N_("Gets an EFI firmware variable " >>>>> - "and stores it as a GRUB environment " >>>>> - "variable named ENV_VARIABLE.")); >>>>> -} >>>>> - >>>>> -GRUB_MOD_FINI(loadbios) >>>>> -{ >>>>> - grub_unregister_command (cmd_setefivariable); >>>>> - grub_unregister_command (cmd_getefivariable); >>>>> -} >>>>> >>>>> _______________________________________________ >>>>> Grub-devel mailing list >>>>> Grub-devel@gnu.org >>>>> https://lists.gnu.org/mailman/listinfo/grub-devel >>>>> >>> >>> >>> >>>> _______________________________________________ >>>> Grub-devel mailing list >>>> Grub-devel@gnu.org >>>> https://lists.gnu.org/mailman/listinfo/grub-devel >>> >>> >>> >>> >>> _______________________________________________ >>> Grub-devel mailing list >>> Grub-devel@gnu.org >>> https://lists.gnu.org/mailman/listinfo/grub-devel >>> >=20 >=20 >=20 >=20 >> _______________________________________________ >> Grub-devel mailing list >> Grub-devel@gnu.org >> https://lists.gnu.org/mailman/listinfo/grub-devel >=20 >=20 >=20 >=20 > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > https://lists.gnu.org/mailman/listinfo/grub-devel >=20 ------enig2DIAVFNXWRFUQWBWGREVW Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.15 (GNU/Linux) Comment: Using GnuPG with Icedove - http://www.enigmail.net/ iF4EAREKAAYFAlKT6bAACgkQmBXlbbo5nOuHLQD+K+BJgMmVXui+g0Mu2h8jurXD bofeKjExiVq4I80+iU0A/jzSMKpoT6NLZfAayZCaZu/BJulsfVV9VnsPW+mSOdIf =455V -----END PGP SIGNATURE----- ------enig2DIAVFNXWRFUQWBWGREVW--