Merge pull request #2615 from nikita-dubrovskii/handle_errors

This commit is contained in:
Jonathan Lebon 2022-05-25 13:38:23 -04:00 committed by GitHub
commit 9aca8816c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -110,12 +110,21 @@ _ostree_bootloader_zipl_write_config (OstreeBootloader *bootloader,
return TRUE;
}
static gboolean _ostree_secure_execution_is_enabled (GCancellable *cancellable) {
gsize len = 0;
g_autofree char *data = glnx_file_get_contents_utf8_at (-1, SECURE_EXECUTION_SYSFS_FLAG, &len, cancellable, NULL);
static gboolean _ostree_secure_execution_is_enabled (gboolean *out_enabled,
GCancellable *cancellable,
GError **error)
{
*out_enabled = FALSE;
glnx_autofd int fd = -1;
if (!ot_openat_ignore_enoent (AT_FDCWD, SECURE_EXECUTION_SYSFS_FLAG, &fd, error))
return FALSE;
if (fd == -1)
return TRUE; //ENOENT --> SecureExecution is disabled
g_autofree char *data = glnx_fd_readall_utf8 (fd, NULL, cancellable, error);
if (!data)
return FALSE;
return strstr (data, "1") != NULL;
*out_enabled = strstr (data, "1") != NULL;
return TRUE;
}
static gboolean
@ -338,7 +347,10 @@ _ostree_bootloader_zipl_post_bls_sync (OstreeBootloader *bootloader,
return TRUE;
/* Try with Secure Execution */
if ( _ostree_secure_execution_is_enabled (cancellable) )
gboolean se_enabled = FALSE;
if ( !_ostree_secure_execution_is_enabled (&se_enabled, cancellable, error))
return FALSE;
if (se_enabled)
{
g_autoptr(GPtrArray) keys = NULL;
if (!_ostree_secure_execution_get_keys (&keys, cancellable, error))