From 0d31527bf6e11a944fb34780e4788ff2c129ffe6 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Feb 15 2019 16:03:47 +0000 Subject: sss_cache: Do nothing if SYSTEMD_OFFLINE=1 Today running `rpm-ostree compose tree` results in a big spam of warnings like: ``` ⠙ Running pre scripts... openssh openssh.prein: (Fri Feb 15 15:50:41:748148 2019) [sss_cache] [confdb_init] (0x0010): Unable to open config database [/var/lib/sss/db/config.ldb] openssh.prein: Could not open available domains openssh.prein: groupadd.rpmostreesave: sss_cache exited with status 5 openssh.prein: groupadd.rpmostreesave: Failed to flush the sssd cache. openssh.prein: (Fri Feb 15 15:50:41:774909 2019) [sss_cache] [confdb_init] (0x0010): Unable to open config database [/var/lib/sss/db/config.ldb] openssh.prein: Could not open available domains openssh.prein: groupadd.rpmostreesave: sss_cache exited with status 5 ``` This is because rpm-ostree doesn't want scripts writing into `/var`; it's system-administrator managed state. Really, SSSD should probably be silently ignoring system users. But let's just silently do nothing if we're running offline, as there won't be a sssd running. --- diff --git a/src/tools/sss_cache.c b/src/tools/sss_cache.c index 6bdcf61..964daa9 100644 --- a/src/tools/sss_cache.c +++ b/src/tools/sss_cache.c @@ -147,6 +147,21 @@ int main(int argc, const char *argv[]) bool skipped = true; struct sss_domain_info *dinfo; + /* In offline mode, there's not going to be a sssd instance + * running. This occurs for both e.g. yum --installroot + * as well as rpm-ostree offline updates. + * + * So let's just quickly do nothing. (Though note today + * yum --installroot doesn't set this variable, rpm-ostree + * does) + * + * For more information on the variable, see: + * https://github.com/systemd/systemd/pull/7631 + */ + const char *systemd_offline = getenv ("SYSTEMD_OFFLINE"); + if (systemd_offline && strcmp (systemd_offline, "1") == 0) + return 0; + ret = init_context(argc, argv, &tctx); if (ret == ENOENT) { /* nothing to invalidate; no reason to fail */