From c48a889da09af0c2cc9d540fa5f3868d6f239e3e Mon Sep 17 00:00:00 2001
From: Colin Walters <walters@verbum.org>
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 edadde0..cdb90d4 100644
--- a/src/daemon/rpmostree-sysroot-upgrader.c
+++ b/src/daemon/rpmostree-sysroot-upgrader.c
@@ -1321,7 +1321,8 @@ clean_pkgcache_orphans (RpmOstreeSysrootUpgrader *self,
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 9b2fb9a..43c814f 100644
--- a/src/daemon/rpmostreed-deployment-utils.c
+++ b/src/daemon/rpmostreed-deployment-utils.c
@@ -185,7 +185,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;
@@ -254,7 +255,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 ded637d..3fde7da 100644
--- a/src/daemon/rpmostreed-os.c
+++ b/src/daemon/rpmostreed-os.c
@@ -1166,7 +1166,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 8b7baa6..670a668 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..14"
+echo "1..15"
setup_os_repository "archive-z2" "syslinux"
@@ -145,6 +145,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
--
2.9.3