diff --git a/Changelog.md b/Changelog.md index 3fc1dda6..c8292cde 100644 --- a/Changelog.md +++ b/Changelog.md @@ -7,6 +7,7 @@ OpenCore Changelog - Added `PowerTimeoutKernelPanic` kernel quirk - Fixed erratic cursor appearing in release builds - Moved `ReconnectOnResChange` to a user-configurable quirk to avoid freezes +- Added OpenCore version to picker ui, configured by `ExposeSensitiveData` #### v0.5.1 - Added support of kernel resource kext injection diff --git a/Docs/Configuration.pdf b/Docs/Configuration.pdf index 8a218bed..da205c78 100644 Binary files a/Docs/Configuration.pdf and b/Docs/Configuration.pdf differ diff --git a/Docs/Configuration.tex b/Docs/Configuration.tex index 3556067b..6c41e662 100755 --- a/Docs/Configuration.tex +++ b/Docs/Configuration.tex @@ -2149,13 +2149,14 @@ nvram 4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102:boot-log | \item \texttt{ExposeSensitiveData}\\ \textbf{Type}: \texttt{plist\ integer}\\ - \textbf{Failsafe}: \texttt{2}\\ + \textbf{Failsafe}: \texttt{0x6}\\ \textbf{Description}: Sensitive data exposure bitmask (sum) to operating system. \begin{itemize} \tightlist \item \texttt{0x01} --- Expose printable booter path as an UEFI variable. \item \texttt{0x02} --- Expose OpenCore version as an UEFI variable. + \item \texttt{0x02} --- Expose OpenCore version in boot picker menu title. \end{itemize} Exposed booter path points to OpenCore.efi or its booter depending on the load order. diff --git a/Docs/Differences/Differences.pdf b/Docs/Differences/Differences.pdf index 4f17837e..aa35ef19 100644 Binary files a/Docs/Differences/Differences.pdf and b/Docs/Differences/Differences.pdf differ diff --git a/Docs/Differences/Differences.tex b/Docs/Differences/Differences.tex index af8ad791..4c72ea48 100644 --- a/Docs/Differences/Differences.tex +++ b/Docs/Differences/Differences.tex @@ -1,7 +1,7 @@ \documentclass[]{article} %DIF LATEXDIFF DIFFERENCE FILE -%DIF DEL PreviousConfiguration.tex Mon Oct 7 11:21:04 2019 -%DIF ADD ../Configuration.tex Thu Oct 24 00:48:16 2019 +%DIF DEL PreviousConfiguration.tex Mon Oct 14 18:48:10 2019 +%DIF ADD ../Configuration.tex Thu Oct 24 18:27:13 2019 \usepackage{lmodern} \usepackage{amssymb,amsmath} @@ -2221,14 +2221,15 @@ nvram 4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102:boot-log | \item \texttt{ExposeSensitiveData}\\ \textbf{Type}: \texttt{plist\ integer}\\ - \textbf{Failsafe}: \texttt{2}\\ + \textbf{Failsafe}: \texttt{\DIFdelbegin \DIFdel{2}\DIFdelend \DIFaddbegin \DIFadd{0x6}\DIFaddend }\\ \textbf{Description}: Sensitive data exposure bitmask (sum) to operating system. \begin{itemize} \tightlist \item \texttt{0x01} --- Expose printable booter path as an UEFI variable. \item \texttt{0x02} --- Expose OpenCore version as an UEFI variable. - \end{itemize} + \DIFaddbegin \item \texttt{\DIFadd{0x02}} \DIFadd{--- Expose OpenCore version in boot picker menu title. + }\DIFaddend \end{itemize} Exposed booter path points to OpenCore.efi or its booter depending on the load order. To obtain booter path use the following command in macOS: diff --git a/Docs/Sample.plist b/Docs/Sample.plist index 486b1528..0043be84 100644 --- a/Docs/Sample.plist +++ b/Docs/Sample.plist @@ -576,7 +576,7 @@ AllowNvramReset ExposeSensitiveData - 2 + 6 HaltLevel 2147483648 RequireSignature diff --git a/Docs/SampleFull.plist b/Docs/SampleFull.plist index 0a1d0381..ea115557 100644 --- a/Docs/SampleFull.plist +++ b/Docs/SampleFull.plist @@ -576,7 +576,7 @@ AllowNvramReset ExposeSensitiveData - 2 + 6 HaltLevel 2147483648 RequireSignature diff --git a/Include/OpenCore.h b/Include/OpenCore.h index 74700cd2..3bd73777 100644 --- a/Include/OpenCore.h +++ b/Include/OpenCore.h @@ -181,6 +181,16 @@ OcShouldReconnectConsoleOnResolutionChange ( IN OC_GLOBAL_CONFIG *Config ); +/** + Get human readable version string. + + @retval null-terminated 7-bit ASCII version string. +**/ +CONST CHAR8 * +OcMiscGetVersionString ( + VOID + ); + /** Load early miscellaneous support like configuration. diff --git a/Platform/OpenCore/OpenCoreMisc.c b/Platform/OpenCore/OpenCoreMisc.c index 99f14fbd..b15a8464 100644 --- a/Platform/OpenCore/OpenCoreMisc.c +++ b/Platform/OpenCore/OpenCoreMisc.c @@ -115,6 +115,74 @@ OcToolLoadEntry ( return EFI_SUCCESS; } +CONST CHAR8 * +OcMiscGetVersionString ( + VOID + ) +{ + UINT32 Month; + + /** + Force the assertions in case we forget about them. + **/ + OC_STATIC_ASSERT ( + L_STR_LEN (OPEN_CORE_VERSION) == 5, + "OPEN_CORE_VERSION must follow X.Y.Z format, where X.Y.Z are single digits." + ); + + OC_STATIC_ASSERT ( + L_STR_LEN (OPEN_CORE_TARGET) == 3, + "OPEN_CORE_TARGET must XYZ format, where XYZ is build target." + ); + + STATIC CHAR8 mOpenCoreVersion[] = { + /* [2]:[0] = */ OPEN_CORE_TARGET + /* [3] = */ "-" + /* [6]:[4] = */ "XXX" + /* [7] = */ "-" + /* [12]:[8] = */ "YYYY-" + /* [15]:[13] = */ "MM-" + /* [17]:[16] = */ "DD" + }; + + STATIC BOOLEAN mOpenCoreVersionReady; + + if (!mOpenCoreVersionReady) { + + mOpenCoreVersion[4] = OPEN_CORE_VERSION[0]; + mOpenCoreVersion[5] = OPEN_CORE_VERSION[2]; + mOpenCoreVersion[6] = OPEN_CORE_VERSION[4]; + + mOpenCoreVersion[8] = __DATE__[7]; + mOpenCoreVersion[9] = __DATE__[8]; + mOpenCoreVersion[10] = __DATE__[9]; + mOpenCoreVersion[11] = __DATE__[10]; + + Month = + (__DATE__[0] == 'J' && __DATE__[1] == 'a' && __DATE__[2] == 'n') ? 1 : + (__DATE__[0] == 'F' && __DATE__[1] == 'e' && __DATE__[2] == 'b') ? 2 : + (__DATE__[0] == 'M' && __DATE__[1] == 'a' && __DATE__[2] == 'r') ? 3 : + (__DATE__[0] == 'A' && __DATE__[1] == 'p' && __DATE__[2] == 'r') ? 4 : + (__DATE__[0] == 'M' && __DATE__[1] == 'a' && __DATE__[2] == 'y') ? 5 : + (__DATE__[0] == 'J' && __DATE__[1] == 'u' && __DATE__[2] == 'n') ? 6 : + (__DATE__[0] == 'J' && __DATE__[1] == 'u' && __DATE__[2] == 'l') ? 7 : + (__DATE__[0] == 'A' && __DATE__[1] == 'u' && __DATE__[2] == 'g') ? 8 : + (__DATE__[0] == 'S' && __DATE__[1] == 'e' && __DATE__[2] == 'p') ? 9 : + (__DATE__[0] == 'O' && __DATE__[1] == 'c' && __DATE__[2] == 't') ? 10 : + (__DATE__[0] == 'N' && __DATE__[1] == 'o' && __DATE__[2] == 'v') ? 11 : + (__DATE__[0] == 'D' && __DATE__[1] == 'e' && __DATE__[2] == 'c') ? 12 : 0; + + mOpenCoreVersion[13] = Month < 10 ? '0' : '1'; + mOpenCoreVersion[14] = '0' + (Month % 10); + mOpenCoreVersion[16] = __DATE__[4] >= '0' ? __DATE__[4] : '0'; + mOpenCoreVersion[17] = __DATE__[5]; + + mOpenCoreVersionReady = TRUE; + } + + return mOpenCoreVersion; +} + EFI_STATUS OcMiscEarlyInit ( IN OC_STORAGE_CONTEXT *Storage, @@ -458,6 +526,10 @@ OcMiscBoot ( Context->PrivilegeContext = Privilege; Context->RequestPrivilege = OcShowSimplePasswordRequest; + if ((Config->Misc.Security.ExposeSensitiveData & OCS_EXPOSE_VERSION_UI) != 0) { + Context->TitleSuffix = OcMiscGetVersionString (); + } + if (Config->Misc.Boot.ShowPicker) { PickerCommand = Context->PickerCommand = OcPickerShowPicker; } else { diff --git a/Platform/OpenCore/OpenCoreNvram.c b/Platform/OpenCore/OpenCoreNvram.c index 61526027..95a2c9f8 100644 --- a/Platform/OpenCore/OpenCoreNvram.c +++ b/Platform/OpenCore/OpenCoreNvram.c @@ -72,74 +72,25 @@ mNvramStorageRootSchema = { .Dict = {mNvramStorageNodesSchema, ARRAY_SIZE (mNvramStorageNodesSchema)} }; -/** - Force the assertions in case we forget about them. -**/ -OC_STATIC_ASSERT ( - L_STR_LEN (OPEN_CORE_VERSION) == 5, - "OPEN_CORE_VERSION must follow X.Y.Z format, where X.Y.Z are single digits." - ); - -OC_STATIC_ASSERT ( - L_STR_LEN (OPEN_CORE_TARGET) == 3, - "OPEN_CORE_TARGET must XYZ format, where XYZ is build target." - ); - -STATIC CHAR8 mOpenCoreVersion[] = { - /* [2]:[0] = */ OPEN_CORE_TARGET - /* [3] = */ "-" - /* [6]:[4] = */ "XXX" - /* [7] = */ "-" - /* [12]:[8] = */ "YYYY-" - /* [15]:[13] = */ "MM-" - /* [17]:[16] = */ "DD" -}; - STATIC VOID OcReportVersion ( IN OC_GLOBAL_CONFIG *Config ) { - UINT32 Month; + CONST CHAR8 *Version; - mOpenCoreVersion[4] = OPEN_CORE_VERSION[0]; - mOpenCoreVersion[5] = OPEN_CORE_VERSION[2]; - mOpenCoreVersion[6] = OPEN_CORE_VERSION[4]; + Version = OcMiscGetVersionString (); - mOpenCoreVersion[8] = __DATE__[7]; - mOpenCoreVersion[9] = __DATE__[8]; - mOpenCoreVersion[10] = __DATE__[9]; - mOpenCoreVersion[11] = __DATE__[10]; + DEBUG ((DEBUG_INFO, "OC: Current version is %a\n", Version)); - Month = - (__DATE__[0] == 'J' && __DATE__[1] == 'a' && __DATE__[2] == 'n') ? 1 : - (__DATE__[0] == 'F' && __DATE__[1] == 'e' && __DATE__[2] == 'b') ? 2 : - (__DATE__[0] == 'M' && __DATE__[1] == 'a' && __DATE__[2] == 'r') ? 3 : - (__DATE__[0] == 'A' && __DATE__[1] == 'p' && __DATE__[2] == 'r') ? 4 : - (__DATE__[0] == 'M' && __DATE__[1] == 'a' && __DATE__[2] == 'y') ? 5 : - (__DATE__[0] == 'J' && __DATE__[1] == 'u' && __DATE__[2] == 'n') ? 6 : - (__DATE__[0] == 'J' && __DATE__[1] == 'u' && __DATE__[2] == 'l') ? 7 : - (__DATE__[0] == 'A' && __DATE__[1] == 'u' && __DATE__[2] == 'g') ? 8 : - (__DATE__[0] == 'S' && __DATE__[1] == 'e' && __DATE__[2] == 'p') ? 9 : - (__DATE__[0] == 'O' && __DATE__[1] == 'c' && __DATE__[2] == 't') ? 10 : - (__DATE__[0] == 'N' && __DATE__[1] == 'o' && __DATE__[2] == 'v') ? 11 : - (__DATE__[0] == 'D' && __DATE__[1] == 'e' && __DATE__[2] == 'c') ? 12 : 0; - - mOpenCoreVersion[13] = Month < 10 ? '0' : '1'; - mOpenCoreVersion[14] = '0' + (Month % 10); - mOpenCoreVersion[16] = __DATE__[4] >= '0' ? __DATE__[4] : '0'; - mOpenCoreVersion[17] = __DATE__[5]; - - DEBUG ((DEBUG_INFO, "OC: Current version is %a\n", mOpenCoreVersion)); - - if ((Config->Misc.Security.ExposeSensitiveData & OCS_EXPOSE_VERSION) != 0) { + if ((Config->Misc.Security.ExposeSensitiveData & OCS_EXPOSE_VERSION_VAR) != 0) { gRT->SetVariable ( OC_VERSION_VARIABLE_NAME, &gOcVendorVariableGuid, OPEN_CORE_NVRAM_ATTR, - L_STR_SIZE_NT (mOpenCoreVersion), - &mOpenCoreVersion[0] + AsciiStrLen (Version), + (VOID *) Version ); } }