diff --git a/src/libpriv/rpmostree-bwrap.c b/src/libpriv/rpmostree-bwrap.c index 0de04ade..3d681d3e 100644 --- a/src/libpriv/rpmostree-bwrap.c +++ b/src/libpriv/rpmostree-bwrap.c @@ -340,6 +340,14 @@ rpmostree_bwrap_set_child_setup (RpmOstreeBwrap *bwrap, bwrap->child_setup_data = data; } + +/* Set an environment variable in the child process */ +void +rpmostree_bwrap_setenv (RpmOstreeBwrap *bwrap, const char *name, const char *value) +{ + g_subprocess_launcher_setenv (bwrap->launcher, name, value, TRUE); +} + /* Execute @bwrap - must have been configured. After executing this method, the * @bwrap instance cannot be run again. */ diff --git a/src/libpriv/rpmostree-bwrap.h b/src/libpriv/rpmostree-bwrap.h index 6e09a267..37b0331d 100644 --- a/src/libpriv/rpmostree-bwrap.h +++ b/src/libpriv/rpmostree-bwrap.h @@ -46,6 +46,8 @@ RpmOstreeBwrap *rpmostree_bwrap_new (int rootfs, void rpmostree_bwrap_append_bwrap_argv (RpmOstreeBwrap *bwrap, ...) G_GNUC_NULL_TERMINATED; void rpmostree_bwrap_append_child_argv (RpmOstreeBwrap *bwrap, ...) G_GNUC_NULL_TERMINATED; +void rpmostree_bwrap_setenv (RpmOstreeBwrap *bwrap, const char *name, const char *value); + void rpmostree_bwrap_set_child_setup (RpmOstreeBwrap *bwrap, GSpawnChildSetupFunc func, gpointer data); diff --git a/src/libpriv/rpmostree-core.c b/src/libpriv/rpmostree-core.c index d734ced3..a5bdb78a 100644 --- a/src/libpriv/rpmostree-core.c +++ b/src/libpriv/rpmostree-core.c @@ -3427,6 +3427,10 @@ rpmostree_context_assemble (RpmOstreeContext *self, * start` in its %post which both violates Fedora policy and also will not * work with the rpm-ostree model. * See also https://github.com/projectatomic/rpm-ostree/issues/550 + * + * See also the SYSTEMD_OFFLINE bits in rpmostree-scripts.c; at some + * point in the far future when we don't support CentOS7 we can drop + * our wrapper script. If we remember. */ if (renameat (tmprootfs_dfd, "usr/bin/systemctl", tmprootfs_dfd, "usr/bin/systemctl.rpmostreesave") < 0) diff --git a/src/libpriv/rpmostree-scripts.c b/src/libpriv/rpmostree-scripts.c index 3db375f1..9b1debeb 100644 --- a/src/libpriv/rpmostree-scripts.c +++ b/src/libpriv/rpmostree-scripts.c @@ -278,6 +278,11 @@ run_script_in_bwrap_container (int rootfs_fd, if (!bwrap) goto out; + /* https://github.com/systemd/systemd/pull/7631 AKA + * "systemctl,verbs: Introduce SYSTEMD_OFFLINE environment variable" + * https://github.com/systemd/systemd/commit/f38951a62837a00a0b1ff42d007e9396b347742d + */ + rpmostree_bwrap_setenv (bwrap, "SYSTEMD_OFFLINE", "1"); struct ChildSetupData data = { .stdin_fd = stdin_fd, .stdout_fd = -1, diff --git a/tests/vmcheck/test-layering-scripts.sh b/tests/vmcheck/test-layering-scripts.sh index 7f97f1b2..f017374c 100755 --- a/tests/vmcheck/test-layering-scripts.sh +++ b/tests/vmcheck/test-layering-scripts.sh @@ -217,6 +217,11 @@ if vm_rpmostree install etc-mutate; then assert_not_reached "successfully installed etc-mutate?" fi +# SYSTEMD_OFFLINE +vm_build_rpm test-systemd-offline post 'test "${SYSTEMD_OFFLINE}" = 1' +vm_rpmostree install test-systemd-offline +vm_rpmostree uninstall test-systemd-offline + # Ensure this is reset; at least in the Vagrant box with # fedora-atomic:fedora/26/x86_64/atomic-host # Version: 26.131 (2017-09-19 22:29:04)