mirror of
https://github.com/pbatard/rufus.git
synced 2025-06-03 16:19:01 -04:00
[iso] fix GRUB version detection for Fedora Rawhide
* How nice of "Open Source proponent" IBM/Red-Hat/Fedora to fix double space typos while making sure the provenance of the software they are using is hidden: https://src.fedoraproject.org/rpms/grub2/blob/rawhide/f/0024-Don-t-say-GNU-Linux-in-generated-menus.patch * Long story short: Fedora fixed the double space in "GRUB version", but of course they didn't upstream this change since it is part of a patch that removes every possible mention of GNU. This made our GRUB version detection break, since it relies on finding a "GRUB version" string. * Fix this by looking for both "GRUB version" and "GRUB version". * This, however, does not fix Fedora Rawhide BIOS boot, since they also added custom GRUB calls such as 'grub_debug_is_enabled', which we don't have in our vanilla produced GRUB binary. * Closes #2002.
This commit is contained in:
parent
a2e9b6fee0
commit
eda1f59a38
3 changed files with 25 additions and 15 deletions
25
src/iso.c
25
src/iso.c
|
@ -847,19 +847,28 @@ out:
|
|||
|
||||
void GetGrubVersion(char* buf, size_t buf_size)
|
||||
{
|
||||
// In typical "I'll make my own Open Source... with blackjack and hookers!" fashion,
|
||||
// IBM/Red-Hat/Fedora took it upon themselves to "fix" the double space typo from the
|
||||
// GRUB version string. But of course, just like their introduction of GRUB calls like
|
||||
// 'grub_debug_is_enabled', they didn't want to bother upstreaming their changes...
|
||||
// On the other hand, boy do they want to leech of FSF/GNU developed software, while
|
||||
// not having it mention GNU anywhere. See:
|
||||
// https://src.fedoraproject.org/rpms/grub2/blob/rawhide/f/0024-Don-t-say-GNU-Linux-in-generated-menus.patch
|
||||
const char* grub_version_str[] = { "GRUB version %s", "GRUB version %s" };
|
||||
char *p, unauthorized[] = {'<', '>', ':', '|', '*', '?', '\\', '/'};
|
||||
size_t i;
|
||||
const char grub_version_str[] = "GRUB version %s";
|
||||
size_t i, j;
|
||||
|
||||
for (i=0; i<buf_size; i++) {
|
||||
if (memcmp(&buf[i], grub_version_str, sizeof(grub_version_str)) == 0) {
|
||||
static_strcpy(img_report.grub2_version, &buf[i + sizeof(grub_version_str)]);
|
||||
break;
|
||||
for (i = 0; i < buf_size; i++) {
|
||||
for (j = 0; j < ARRAYSIZE(grub_version_str); j++) {
|
||||
if (memcmp(&buf[i], grub_version_str[j], strlen(grub_version_str[j]) + 1) == 0) {
|
||||
static_strcpy(img_report.grub2_version, &buf[i + strlen(grub_version_str[j]) + 1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Sanitize the string
|
||||
for (p = &img_report.grub2_version[0]; *p; p++) {
|
||||
for (i=0; i<sizeof(unauthorized); i++) {
|
||||
for (i = 0; i < sizeof(unauthorized); i++) {
|
||||
if (*p == unauthorized[i])
|
||||
*p = '_';
|
||||
}
|
||||
|
@ -1139,7 +1148,7 @@ out:
|
|||
// when using '/boot/grub2' as a prefix is very small and always located at the
|
||||
// very end the file to patch the damn thing and get on with our life!
|
||||
uprintf(" Detected Grub version: %s%s", img_report.grub2_version,
|
||||
img_report.has_grub2 >= 1 ? " with NONSTANDARD prefix" : "");
|
||||
img_report.has_grub2 > 1 ? " with NONSTANDARD prefix" : "");
|
||||
for (k = 0; k < ARRAYSIZE(grub_patch); k++) {
|
||||
if (strcmp(img_report.grub2_version, grub_patch[k].version) == 0)
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue