mok/mok.c
BOOLEAN secure_mode (VOID)
{
   EFI_STATUS status;
   EFI_GUID global_var = EFI_GLOBAL_VARIABLE;
   UINTN charsize = sizeof(char);
   UINT8 *sb = NULL, *setupmode = NULL;

   status = EfivarGetRaw(&global_var, L"SecureBoot", (CHAR8 **) &sb, &charsize);
   /* FIXME - more paranoia here? */
   if (status != EFI_SUCCESS || charsize != sizeof(CHAR8) || *sb != 1) {
      return FALSE;
   }

   status = EfivarGetRaw(&global_var, L"SetupMode", (CHAR8 **) &setupmode, &charsize);
   if (status == EFI_SUCCESS && charsize == sizeof(CHAR8) && *setupmode == 1) {
      return FALSE;
   }

   return TRUE;
}
/*
 * Check whether we're in Secure Boot and user mode
 */
Check whether we're in Secure Boot and user mode
Check whether we ' re in Secure Boot and user mode
BOOLEAN secure_mode (VOID)
{
   EFI_STATUS status;
   EFI_GUID global_var = EFI_GLOBAL_VARIABLE;
   UINTN charsize = sizeof(char);
   UINT8 *sb = NULL, *setupmode = NULL;
   status = EfivarGetRaw(&global_var, L"SecureBoot", (CHAR8 **) &sb, &charsize);
   if (status != EFI_SUCCESS || charsize != sizeof(CHAR8) || *sb != 1) {
      return FALSE;
   }
   status = EfivarGetRaw(&global_var, L"SetupMode", (CHAR8 **) &setupmode, &charsize);
   if (status == EFI_SUCCESS && charsize == sizeof(CHAR8) && *setupmode == 1) {
      return FALSE;
   }
   return TRUE;
}
BOOLEAN secure_mode ( VOID ) { EFI_STATUS status ; EFI_GUID global_var = EFI_GLOBAL_VARIABLE ; UINTN charsize = sizeof ( char ) ; UINT8 * sb = NULL , * setupmode = NULL ; status = EfivarGetRaw ( & global_var , L" " , ( CHAR8 * * ) & sb , & charsize ) ; if ( status != EFI_SUCCESS || charsize != sizeof ( CHAR8 ) || * sb != 1 ) { return FALSE ; } status = EfivarGetRaw ( & global_var , L" " , ( CHAR8 * * ) & setupmode , & charsize ) ; if ( status == EFI_SUCCESS && charsize == sizeof ( CHAR8 ) && * setupmode == 1 ) { return FALSE ; } return TRUE ; }
Check whether we're in Secure Boot and user mode
Check whether we ' re in Secure Boot and user mode
/* FIXME - more paranoia here? */