From 775c7819b7e29b501c90df6d99a71457e9308c20 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Mon, 13 Feb 2017 21:01:31 -0500 Subject: [PATCH] daemon: Avoid erroring out on startup/status with origin unconfigured-state As part of an earlier cleanup of origin parsing, we started checking the origin `unconfigured-state` even just starting the daemon, which is kind of bad. It's tempting to flip the default for the parser so that we *only* check unconfigured state if we go to upgrade, but let's not do that in this patch. Closes: #626 Approved by: jlebon --- src/daemon/rpmostree-sysroot-upgrader.c | 3 ++- src/daemon/rpmostreed-deployment-utils.c | 6 ++++-- src/daemon/rpmostreed-os.c | 3 ++- tests/check/test-basic.sh | 14 +++++++++++++- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/daemon/rpmostree-sysroot-upgrader.c b/src/daemon/rpmostree-sysroot-upgrader.c index 7c676528..0bfb6617 100644 --- a/src/daemon/rpmostree-sysroot-upgrader.c +++ b/src/daemon/rpmostree-sysroot-upgrader.c @@ -1335,7 +1335,8 @@ clean_pkgcache_orphans (OstreeSysroot *sysroot, OstreeDeployment *deployment = deployments->pdata[i]; g_autoptr(RpmOstreeOrigin) origin = NULL; - origin = rpmostree_origin_parse_deployment (deployment, error); + origin = rpmostree_origin_parse_deployment_ex (deployment, RPMOSTREE_ORIGIN_PARSE_FLAGS_IGNORE_UNCONFIGURED, + error); if (!origin) return FALSE; diff --git a/src/daemon/rpmostreed-deployment-utils.c b/src/daemon/rpmostreed-deployment-utils.c index b6c3f046..7f93f2e0 100644 --- a/src/daemon/rpmostreed-deployment-utils.c +++ b/src/daemon/rpmostreed-deployment-utils.c @@ -191,7 +191,8 @@ rpmostreed_deployment_generate_variant (OstreeDeployment *deployment, id = rpmostreed_deployment_generate_id (deployment); - origin = rpmostree_origin_parse_deployment (deployment, error); + origin = rpmostree_origin_parse_deployment_ex (deployment, RPMOSTREE_ORIGIN_PARSE_FLAGS_IGNORE_UNCONFIGURED, + error); if (!origin) return NULL; @@ -281,7 +282,8 @@ rpmostreed_commit_generate_cached_details_variant (OstreeDeployment *deployment, { g_autoptr(RpmOstreeOrigin) origin = NULL; - origin = rpmostree_origin_parse_deployment (deployment, error); + origin = rpmostree_origin_parse_deployment_ex (deployment, RPMOSTREE_ORIGIN_PARSE_FLAGS_IGNORE_UNCONFIGURED, + error); if (!origin) return NULL; origin_refspec = g_strdup (rpmostree_origin_get_refspec (origin)); diff --git a/src/daemon/rpmostreed-os.c b/src/daemon/rpmostreed-os.c index ccc8869e..3d15353e 100644 --- a/src/daemon/rpmostreed-os.c +++ b/src/daemon/rpmostreed-os.c @@ -1214,7 +1214,8 @@ rpmostreed_os_load_internals (RpmostreedOS *self, GError **error) g_autoptr(RpmOstreeOrigin) origin = NULL; /* Don't fail here for unknown origin types */ - origin = rpmostree_origin_parse_deployment (merge_deployment, NULL); + origin = rpmostree_origin_parse_deployment_ex (merge_deployment, RPMOSTREE_ORIGIN_PARSE_FLAGS_IGNORE_UNCONFIGURED, + NULL); if (origin) { cached_update = rpmostreed_commit_generate_cached_details_variant (merge_deployment, diff --git a/tests/check/test-basic.sh b/tests/check/test-basic.sh index b871ff3b..b754867c 100755 --- a/tests/check/test-basic.sh +++ b/tests/check/test-basic.sh @@ -24,7 +24,7 @@ export RPMOSTREE_SUPPRESS_REQUIRES_ROOT_CHECK=yes ensure_dbus -echo "1..15" +echo "1..16" setup_os_repository "archive-z2" "syslinux" @@ -133,6 +133,18 @@ $OSTREE remote add secureos file://$(pwd)/testos-repo rpm-ostree rebase --os=testos secureos:$branch gpg-signed echo "ok deploy from remote with unsigned and signed commits" +originpath=$(ostree admin --sysroot=sysroot --print-current-dir).origin +echo "unconfigured-state=Access to TestOS requires ONE BILLION DOLLARS" >> ${originpath} +pid=$(pgrep -u $(id -u) -f 'rpm-ostree.*daemon') +test -n "${pid}" || assert_not_reached "failed to find rpm-ostree pid" +kill -9 ${pid} +rpm-ostree status +if rpm-ostree upgrade --os=testos 2>err.txt; then + assert_not_reached "Upgraded from unconfigured-state" +fi +assert_file_has_content err.txt 'ONE BILLION DOLLARS' +echo "ok unconfigured status" + # Ensure it returns an error when passing a wrong option. rpm-ostree --help | awk '/^$/ {in_commands=0} {if(in_commands==1){print $0}} /^Builtin Commands:/ {in_commands=1}' > commands while read command; do