From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Vl4eL-0006cj-9T for mharc-grub-devel@gnu.org; Mon, 25 Nov 2013 17:29:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53790) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vl4eE-0006IZ-7X for grub-devel@gnu.org; Mon, 25 Nov 2013 17:28:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vl4e9-0001Im-F4 for grub-devel@gnu.org; Mon, 25 Nov 2013 17:28:54 -0500 Received: from mail-yh0-x22c.google.com ([2607:f8b0:4002:c01::22c]:37200) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vl4e9-0001Ig-7h for grub-devel@gnu.org; Mon, 25 Nov 2013 17:28:49 -0500 Received: by mail-yh0-f44.google.com with SMTP id f64so3450110yha.31 for ; Mon, 25 Nov 2013 14:28:48 -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=63HMzGwvD5Aw8vHPl+v6m+IMASuWExRpLJff6v1B9FI=; b=FeGRRn0hoVuMhrv4oaa25z1URfWMEySA4JqkZJR//hTFKeF433lQcl9QAxgocoUvDF 5JQfkG/E+Kcsp8hekAJYs/19Jd/caFVvAkSRaoHWivTbCNPEqSFVm2hCnW5eNZWGQF9h 9muZCpEufZ7pN5zKOo/h46PyHXnqF2sTavzwcXlEhPN/gv4OuLCdjDg0BiNEpNuWVpwu sLedOGy4TC5U7s2XkSSYtY+ZyezZXs6kKIwEJFoko+bPf/xzAFJO/7kRcRVdcYZIMhQY AFCtm0U3vqcJV9nlKUmUC2+GDqsSmvhl0PL1koxGwyVy//ya1JB7Hw5hjWWdhBtiFG4e SFrQ== X-Received: by 10.236.150.45 with SMTP id y33mr193976yhj.124.1385418528815; Mon, 25 Nov 2013 14:28:48 -0800 (PST) Received: from [10.0.0.14] (c-50-169-245-128.hsd1.nh.comcast.net. [50.169.245.128]) by mx.google.com with ESMTPSA id e10sm78541754yhj.1.2013.11.25.14.28.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Nov 2013 14:28:48 -0800 (PST) Message-ID: <5293CF1F.9070009@gmail.com> Date: Mon, 25 Nov 2013 17:28:47 -0500 From: SevenBits User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.1 MIME-Version: 1.0 To: The development of GNU GRUB 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> In-Reply-To: <5293CA3A.7090702@gmail.com> X-Enigmail-Version: 1.6 Content-Type: multipart/alternative; boundary="------------040909000403020407010603" X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4002:c01::22c 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: Mon, 25 Nov 2013 22:28:59 -0000 This is a multi-part message in MIME format. --------------040909000403020407010603 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 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 secondly, >> by saying it needs "readable aliases for known types" do you mean that >> there should be a function to set an integer, one to set a boolean, etc? >> > 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. > > 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. > >> 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 vendor >> uuid. >>> it would be needed and slso it needs readable aliases for known types >>> On Nov 25, 2013 10:35 PM, "SevenBits" wrote: >> >>>> 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 for >>>> 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 takes >>>> 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. This >>>> can then be checked using GRUB's built in 'if' statement and scripting >>>> capability to allow unique booting capabilities based on whether, for >>>> 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 = { >>>> }; >>>> >>>> module = { >>>> - name = setvariable; >>>> - common = commands/efi/setvariable.c; >>>> - enable = i386_efi; >>>> - enable = x86_64_efi; >>>> -}; >>>> - >>>> -module = { >>>> name = pcidump; >>>> common = commands/pcidump.c; >>>> enable = 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 License >>>> - * 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 = GRUB_EFI_GLOBAL_VARIABLE_GUID; >>>> - if (argc == 0) >>>> - return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("efi variable name >>>> expected")); >>>> - else if (argc == 1) >>>> - return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("efi variable name >>>> value expected")); >>>> - >>>> - grub_err_t status; >>>> - grub_size_t arg_size = (grub_strlen(argv[1]) + 1) * sizeof(char); >>>> - >>>> - status = grub_efi_set_variable (argv[0], &global, argv[1], >> arg_size); >>>> - if (status != 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 = GRUB_EFI_GLOBAL_VARIABLE_GUID; >>>> - if (argc == 0) >>>> - return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("efi variable name >>>> expected")); >>>> - else if (argc == 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 = (char*)grub_efi_get_variable (argv[0], &global, >>>> &var_size); >>>> - status = grub_env_set (argv[1], value); >>>> - if (status != 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 = 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 = 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 >> > > > > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > https://lists.gnu.org/mailman/listinfo/grub-devel -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBAgAGBQJSk88fAAoJEFbRvtGxmFPEo6sH+QH8Ui0uRIkjAPrpiYtq6WNS T4tsxK8n4wv5dtROlWZTJpuLhtynKP1m4LjSguO8XTMtRhgqFiyfcA1cJOQ/5XbP qEK1MoRivAme/Ia88l+AlGqSXqBTu5zmG+TfuMrVl/DFXKIwes6S5/mxeXftV+B7 gMq1LAZJ2oGiy1lSRdS37Tzg0VChVJJvFHIEu5AUAisLvOLKB054M82T3vmxQD6s N3z2RTxho98JxqjF+4tGMtbAI0mebD+v9ik2H3vs4Tsd+86Ie1/nSWPGJ0mdfN96 812p4xCBPx3vFkcfo1cReqNIl2aDVY+F55vWoh1Nc2fKHh1PW7/RB9Bo+FWbb48= =fQuY -----END PGP SIGNATURE----- --------------040909000403020407010603 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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 secondly,
>> by saying it needs "readable aliases for known types" do you mean that
>> there should be a function to set an integer, one to set a boolean, etc?
>>
> 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.
>
> 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.
>
>> 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 vendor
>> uuid.
>>> it would be needed and slso it needs readable aliases for known types
>>> On Nov 25, 2013 10:35 PM, "SevenBits" <sevenbitstech@gmail.com> wrote:
>>
>>>> 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 for
>>>> 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 takes
>>>> 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. This
>>>> can then be checked using GRUB's built in 'if' statement and scripting
>>>> capability to allow unique booting capabilities based on whether, for
>>>> 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 = {
>>>>  };
>>>>
>>>>  module = {
>>>> -  name = setvariable;
>>>> -  common = commands/efi/setvariable.c;
>>>> -  enable = i386_efi;
>>>> -  enable = x86_64_efi;
>>>> -};
>>>> -
>>>> -module = {
>>>>    name = pcidump;
>>>>    common = commands/pcidump.c;
>>>>    enable = 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 License
>>>> - *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
>>>> - */
>>>> -
>>>> -#include <grub/env.h>
>>>> -#include <grub/dl.h>
>>>> -#include <grub/misc.h>
>>>> -#include <grub/file.h>
>>>> -#include <grub/efi/efi.h>
>>>> -#include <grub/pci.h>
>>>> -#include <grub/command.h>
>>>> -#include <grub/i18n.h>
>>>> -
>>>> -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 = GRUB_EFI_GLOBAL_VARIABLE_GUID;
>>>> -    if (argc == 0)
>>>> -        return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("efi variable name
>>>> expected"));
>>>> -    else if (argc == 1)
>>>> -        return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("efi variable name
>>>> value expected"));
>>>> -
>>>> -    grub_err_t status;
>>>> -    grub_size_t arg_size = (grub_strlen(argv[1]) + 1) * sizeof(char);
>>>> -
>>>> -    status = grub_efi_set_variable (argv[0], &global, argv[1],
>> arg_size);
>>>> -    if (status != 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 = GRUB_EFI_GLOBAL_VARIABLE_GUID;
>>>> -    if (argc == 0)
>>>> -        return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("efi variable name
>>>> expected"));
>>>> -    else if (argc == 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 = (char*)grub_efi_get_variable (argv[0], &global,
>>>> &var_size);
>>>> -    status = grub_env_set (argv[1], value);
>>>> -    if (status != 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 = 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 = 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
>>
>
>
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJSk88fAAoJEFbRvtGxmFPEo6sH+QH8Ui0uRIkjAPrpiYtq6WNS
T4tsxK8n4wv5dtROlWZTJpuLhtynKP1m4LjSguO8XTMtRhgqFiyfcA1cJOQ/5XbP
qEK1MoRivAme/Ia88l+AlGqSXqBTu5zmG+TfuMrVl/DFXKIwes6S5/mxeXftV+B7
gMq1LAZJ2oGiy1lSRdS37Tzg0VChVJJvFHIEu5AUAisLvOLKB054M82T3vmxQD6s
N3z2RTxho98JxqjF+4tGMtbAI0mebD+v9ik2H3vs4Tsd+86Ie1/nSWPGJ0mdfN96
812p4xCBPx3vFkcfo1cReqNIl2aDVY+F55vWoh1Nc2fKHh1PW7/RB9Bo+FWbb48=
=fQuY
-----END PGP SIGNATURE-----

--------------040909000403020407010603--