Skip to content

Commit

Permalink
[iso] fix GRUB version detection for Fedora Rawhide
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
pbatard committed Jul 28, 2022
1 parent a2e9b6f commit eda1f59
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
5 changes: 3 additions & 2 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
o Version 3.20 (2022.08.??)
Enable applicable Windows User Experience options for Windows 10
Make Windows User Experience options persist between sessions
Remember last Windows User Experience selection between sessions
Add automatic local account creation and regional options duplication
(NB: This is limited to creating an account with the same name as the current user and
with an empty password that the user will be prompted to change after first reboot)
Add a workaround for ISOs that have a 'syslinux' symbolic link to '/isolinux/' (Knoppix)
Revert to inserting registry keys for the TPM/SB/RAM bypass where possible
Revert to offline insertion of registry keys for the TPM/SB/RAM bypass where possible
Remove storage bypass, since this is a bogus bypass that doesn't do anything
Improve BIOS compatibility when displaying the "UEFI boot only" alert message
Fix Windows User Experience dialog appearing twice for Windows To Go
Fix Windows User Experience options not being applied for ARM64
Fix Microsoft Account bypass not being applied unless TPM/SB/RAM bypass is selected
Fix overeager detection of GRUB2 bootloaders with nonstandard prefixes

o Version 3.19 (2022.07.01)
Add a new selection dialog for Windows 11 setup customization:
Expand Down
25 changes: 17 additions & 8 deletions src/iso.c
Original file line number Diff line number Diff line change
Expand Up @@ -847,19 +847,28 @@ static int iso_extract_files(iso9660_t* p_iso, const char *psz_path)

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 = '_';
}
Expand Down Expand Up @@ -1139,7 +1148,7 @@ BOOL ExtractISO(const char* src_iso, const char* dest_dir, BOOL scan)
// 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;
Expand Down
10 changes: 5 additions & 5 deletions src/rufus.rc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 232, 326
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_ACCEPTFILES
CAPTION "Rufus 3.20.1926"
CAPTION "Rufus 3.20.1927"
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
Expand Down Expand Up @@ -395,8 +395,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,20,1926,0
PRODUCTVERSION 3,20,1926,0
FILEVERSION 3,20,1927,0
PRODUCTVERSION 3,20,1927,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -414,13 +414,13 @@ BEGIN
VALUE "Comments", "https://rufus.ie"
VALUE "CompanyName", "Akeo Consulting"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "3.20.1926"
VALUE "FileVersion", "3.20.1927"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2022 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
VALUE "OriginalFilename", "rufus-3.20.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "3.20.1926"
VALUE "ProductVersion", "3.20.1927"
END
END
BLOCK "VarFileInfo"
Expand Down

0 comments on commit eda1f59

Please sign in to comment.