2017-04-23 6:36 GMT+02:00 Andrei Borzenkov <arvidj...@gmail.com>:

> 23.04.2017 03:54, adrian15 пишет:
> > grub-install seems to be deleting long UEFI entries
> >
> > (*) What the bug is
> >
> > * Add an UEFI entry with this label (Remove the single quotes):
> >  '(Rescapp added) \EFI\ubuntu\MokManager.efi'
> >
> > Example:
> >
> > efibootmgr -c \
> >  -d /dev/sda \
> >  -p 2 \
> >  -L '(Rescapp added) \EFI\ubuntu\MokManager.efi' \
> >  -l '\EFI\ubuntu\MokManager.efi'
> >
> > * Run grub-install /dev/sda or maybe just grub-install
> >
> > I expect the newly added uefi entry to be there.
> > What I find is that the entry has been lost or deleted!
> >
>
> What is value of GRUB_DISTRIBUTOR in /etc/default/grub?
>

After evaluating the bash expression the GRUB_DISTRIBUTOR value is Ubuntu.

> ...
> >
> > Maybe grub-install uses efibootmgr as an auxiliar tool and the problem
> > is in Ubuntu's efibootmgr?
> >
>
> Yes.
>

Yeah, I see it right in the source code. More to come.

>
> > It would be nice if someone could point us on where does grub-install
> > handles the uefi boot entries so that we can take a deeper look into it.
> >
>
> grub-core/osdep/unix/platform.c
>
Thank you.

I've taken a look at: grub-core/osdep/unix/platform.c file (on 2.02-rc2
tag) and I have some comments about it.

There's the function: grub_install_remove_efi_entries_by_distributor which
has some interesting snippets:

1) First of all this matches all the line:

if (!strcasestr (line, efi_distributor))
continue;

That means that if you add a custom label which matches the efi distributor
then it gets removed. I think that's what happened to me. I would prefer
something more precise that would check the complete efi file path agains
e.g. EFI/vendor/ .

2) Then there's:

      if (grub_memcmp (line, "Boot", sizeof ("Boot") - 1) != 0
 || line[sizeof ("Boot") - 1] < '0'
 || line[sizeof ("Boot") - 1] > '9')
continue;

which might be wrong because of 0 and 9 and maybe not because of the array
indexes.

Let's go into details about that.

2.1) Boot0000 First entry
BootA000 Second entry

Shouldn't the look for A to F hexadecimal letters too?

And...

2.2) line[sizeof ("Boot") - 1] < '0'

Am I doing it right?

sizeof ("Boot") = 4

So it's line [4 - 1] and therefore: line [3] .
And as a consequence... line[3] = 't'.

line[3] is always going to be 't' when the first OR condition is not
true...so no need of the third or the fourth condition then.

Or is there  something about indexes or character size (unicode being
16bit?) that I am missing?



Thank you.

adrian15
-- 
Support free software. Donate to Super Grub Disk. Apoya el software libre.
Dona a Super Grub Disk. http://www.supergrubdisk.org/donate/ .
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to