From 9f671efc60e8cb84ad2c73718c686692c92585fa Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 15 Jun 2017 13:29:06 -0400 Subject: [PATCH 1/4] treecompose: Add various g_prefix_error() To help debug a problem which turned out to be in SELinux postprocessing for RHELAH. Closes: #830 Approved by: jlebon --- src/app/rpmostree-compose-builtin-tree.c | 20 ++++++++++++++++---- src/libpriv/rpmostree-postprocess.c | 28 +++++++++++++--------------- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/src/app/rpmostree-compose-builtin-tree.c b/src/app/rpmostree-compose-builtin-tree.c index 15b2862..4cbe503 100644 --- a/src/app/rpmostree-compose-builtin-tree.c +++ b/src/app/rpmostree-compose-builtin-tree.c @@ -1008,12 +1008,18 @@ rpmostree_compose_builtin_tree (int argc, if (!rpmostree_treefile_postprocessing (rootfs_fd, self->treefile_context_dirs->pdata[0], self->serialized_treefile, treefile, next_version, cancellable, error)) - goto out; + { + g_prefix_error (error, "Postprocessing: "); + goto out; + } if (!rpmostree_prepare_rootfs_for_commit (self->workdir_dfd, &rootfs_fd, rootfs_name, treefile, cancellable, error)) - goto out; + { + g_prefix_error (error, "Preparing rootfs for commit: "); + goto out; + } if (!rpmostree_copy_additional_files (yumroot, self->treefile_context_dirs->pdata[0], treefile, cancellable, error)) goto out; @@ -1021,12 +1027,18 @@ rpmostree_compose_builtin_tree (int argc, if (!rpmostree_check_passwd (repo, yumroot, treefile_dirpath, treefile, previous_checksum, cancellable, error)) - goto out; + { + g_prefix_error (error, "Handling passwd db: "); + goto out; + } if (!rpmostree_check_groups (repo, yumroot, treefile_dirpath, treefile, previous_checksum, cancellable, error)) - goto out; + { + g_prefix_error (error, "Handling group db: "); + goto out; + } /* Insert our input hash */ g_hash_table_replace (metadata_hash, g_strdup ("rpmostree.inputhash"), diff --git a/src/libpriv/rpmostree-postprocess.c b/src/libpriv/rpmostree-postprocess.c index 46fb636..db24c70 100644 --- a/src/libpriv/rpmostree-postprocess.c +++ b/src/libpriv/rpmostree-postprocess.c @@ -654,10 +654,7 @@ postprocess_selinux_policy_store_location (int rootfs_dfd, name = dent->d_name; if (renameat (dfd_iter.fd, name, etc_selinux_dfd, name) != 0) - { - glnx_set_error_from_errno (error); - return FALSE; - } + return glnx_throw_errno_prefix (error, "rename(%s)", name); } return TRUE; @@ -794,12 +791,18 @@ create_rootfs_from_yumroot_content (int target_root_dfd, /* NSS configuration to look at the new files */ if (!replace_nsswitch (src_rootfs_fd, cancellable, error)) - goto out; + { + g_prefix_error (error, "nsswitch replacement: "); + goto out; + } if (selinux) { if (!postprocess_selinux_policy_store_location (src_rootfs_fd, cancellable, error)) - goto out; + { + g_prefix_error (error, "SELinux postprocess: "); + goto out; + } } /* We take /usr from the yum content */ @@ -1615,17 +1618,15 @@ rpmostree_prepare_rootfs_for_commit (int workdir_dfd, glnx_fd_close int target_root_dfd = -1; if (mkdirat (workdir_dfd, temp_new_root, 0755) < 0) - { - glnx_set_error_from_errno (error); - return FALSE; - } + return glnx_throw_errno_prefix (error, "creating %s", temp_new_root); + if (!glnx_opendirat (workdir_dfd, temp_new_root, TRUE, &target_root_dfd, error)) return FALSE; if (!create_rootfs_from_yumroot_content (target_root_dfd, *inout_rootfs_fd, treefile, cancellable, error)) - return FALSE; + return glnx_prefix_error (error, "Finalizing rootfs"); (void) close (*inout_rootfs_fd); @@ -1634,10 +1635,7 @@ rpmostree_prepare_rootfs_for_commit (int workdir_dfd, if (TEMP_FAILURE_RETRY (renameat (workdir_dfd, temp_new_root, workdir_dfd, rootfs_name)) != 0) - { - glnx_set_error_from_errno (error); - return FALSE; - } + return glnx_throw_errno_prefix (error, "rename(%s, %s)", temp_new_root, rootfs_name); *inout_rootfs_fd = target_root_dfd; target_root_dfd = -1; /* Transfer ownership */ -- 2.13.0