[ostree] admin: Error out if we see malformed or mismatched checksums for /boot
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] admin: Error out if we see malformed or mismatched checksums for /boot
- Date: Fri, 30 Aug 2013 22:11:09 +0000 (UTC)
commit 72a8f41ad4d82a52d02976b4211d11a8bbf1bc3a
Author: Colin Walters <walters verbum org>
Date: Fri Aug 30 18:10:35 2013 -0400
admin: Error out if we see malformed or mismatched checksums for /boot
The kernel/initramfs both need to end in -SHA256 and match.
src/ostree/ot-admin-deploy.c | 38 ++++++++++++++++++++++++++++++++++----
1 files changed, 34 insertions(+), 4 deletions(-)
---
diff --git a/src/ostree/ot-admin-deploy.c b/src/ostree/ot-admin-deploy.c
index 44eee3a..9379b50 100644
--- a/src/ostree/ot-admin-deploy.c
+++ b/src/ostree/ot-admin-deploy.c
@@ -376,6 +376,8 @@ get_kernel_from_tree (GFile *deployroot,
gs_unref_object GFileEnumerator *dir_enum = NULL;
gs_unref_object GFile *ret_kernel = NULL;
gs_unref_object GFile *ret_initramfs = NULL;
+ gs_free char *kernel_checksum = NULL;
+ gs_free char *initramfs_checksum = NULL;
dir_enum = g_file_enumerate_children (bootdir, OSTREE_GIO_FAST_QUERYINFO,
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
@@ -395,11 +397,27 @@ get_kernel_from_tree (GFile *deployroot,
break;
name = g_file_info_get_name (file_info);
-
+
if (ret_kernel == NULL && g_str_has_prefix (name, "vmlinuz-"))
- ret_kernel = g_file_get_child (bootdir, name);
+ {
+ const char *dash = strrchr (name, '-');
+ g_assert (dash);
+ if (ostree_validate_structureof_checksum_string (dash + 1, NULL))
+ {
+ kernel_checksum = g_strdup (dash + 1);
+ ret_kernel = g_file_get_child (bootdir, name);
+ }
+ }
else if (ret_initramfs == NULL && g_str_has_prefix (name, "initramfs-"))
- ret_initramfs = g_file_get_child (bootdir, name);
+ {
+ const char *dash = strrchr (name, '-');
+ g_assert (dash);
+ if (ostree_validate_structureof_checksum_string (dash + 1, NULL))
+ {
+ initramfs_checksum = g_strdup (dash + 1);
+ ret_initramfs = g_file_get_child (bootdir, name);
+ }
+ }
if (ret_kernel && ret_initramfs)
break;
@@ -408,11 +426,23 @@ get_kernel_from_tree (GFile *deployroot,
if (ret_kernel == NULL)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
- "Failed to find boot/vmlinuz-CHECKSUM in %s",
+ "Failed to find boot/vmlinuz-<CHECKSUM> in %s",
gs_file_get_path_cached (deployroot));
goto out;
}
+ if (ret_initramfs != NULL)
+ {
+ if (strcmp (kernel_checksum, initramfs_checksum) != 0)
+ {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
+ "Mismatched kernel %s checksum vs initrd %s",
+ gs_file_get_basename_cached (ret_initramfs),
+ gs_file_get_basename_cached (ret_initramfs));
+ goto out;
+ }
+ }
+
ot_transfer_out_value (out_kernel, &ret_kernel);
ot_transfer_out_value (out_initramfs, &ret_initramfs);
ret = TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]