OpenCoreMisc: Added OpenCore version to picker ui, configured by ExposeSensitiveData

This commit is contained in:
vit9696 2019-10-24 18:31:58 +03:00
parent eae214b4f8
commit cd8a046ce9
10 changed files with 98 additions and 62 deletions

View File

@ -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

Binary file not shown.

View File

@ -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.

Binary file not shown.

View File

@ -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:

View File

@ -576,7 +576,7 @@
<key>AllowNvramReset</key>
<false/>
<key>ExposeSensitiveData</key>
<integer>2</integer>
<integer>6</integer>
<key>HaltLevel</key>
<integer>2147483648</integer>
<key>RequireSignature</key>

View File

@ -576,7 +576,7 @@
<key>AllowNvramReset</key>
<false/>
<key>ExposeSensitiveData</key>
<integer>2</integer>
<integer>6</integer>
<key>HaltLevel</key>
<integer>2147483648</integer>
<key>RequireSignature</key>

View File

@ -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.

View File

@ -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 {

View File

@ -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
);
}
}