|
|
073af0 |
From 1675058768263b804148c7a737b00a480d6b32f8 Mon Sep 17 00:00:00 2001
|
|
|
073af0 |
From: Jonathan Lebon <jonathan@jlebon.com>
|
|
|
073af0 |
Date: Wed, 26 Feb 2020 11:14:51 -0500
|
|
|
073af0 |
Subject: [PATCH] initramfs: Fix using local /etc when also replacing kernel
|
|
|
073af0 |
|
|
|
073af0 |
Instead of basing our decision to use the local `/etc` on whether we're
|
|
|
073af0 |
using `dracut --rebuild`, base it directly on a boolean parameter.
|
|
|
073af0 |
|
|
|
073af0 |
This is relevant in the client-side when initramfs regeneration is
|
|
|
073af0 |
requested as well as a kernel override. In such cases, we do want to use
|
|
|
073af0 |
the local `/etc`, but we'd skip that path because we didn't also use
|
|
|
073af0 |
`dracut --rebuild`.
|
|
|
073af0 |
|
|
|
073af0 |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1806588
|
|
|
073af0 |
---
|
|
|
073af0 |
src/daemon/rpmostree-sysroot-upgrader.c | 9 ++++++---
|
|
|
073af0 |
src/libpriv/rpmostree-kernel.c | 6 ++----
|
|
|
073af0 |
src/libpriv/rpmostree-kernel.h | 1 +
|
|
|
073af0 |
src/libpriv/rpmostree-postprocess.c | 2 +-
|
|
|
073af0 |
tests/vmcheck/test-override-kernel.sh | 9 +++++++++
|
|
|
073af0 |
5 files changed, 19 insertions(+), 8 deletions(-)
|
|
|
073af0 |
|
|
|
073af0 |
diff --git a/src/daemon/rpmostree-sysroot-upgrader.c b/src/daemon/rpmostree-sysroot-upgrader.c
|
|
|
073af0 |
index e3f5acef..f84e20c6 100644
|
|
|
073af0 |
--- a/src/daemon/rpmostree-sysroot-upgrader.c
|
|
|
073af0 |
+++ b/src/daemon/rpmostree-sysroot-upgrader.c
|
|
|
073af0 |
@@ -1097,9 +1097,12 @@ perform_local_assembly (RpmOstreeSysrootUpgrader *self,
|
|
|
073af0 |
g_assert (kernel_state && kernel_path);
|
|
|
073af0 |
|
|
|
073af0 |
g_auto(GLnxTmpfile) initramfs_tmpf = { 0, };
|
|
|
073af0 |
- if (!rpmostree_run_dracut (self->tmprootfs_dfd, add_dracut_argv, kver,
|
|
|
073af0 |
- initramfs_path, NULL, &initramfs_tmpf,
|
|
|
073af0 |
- cancellable, error))
|
|
|
073af0 |
+ /* NB: We only use the real root's /etc if initramfs regeneration is explicitly
|
|
|
073af0 |
+ * requested. IOW, just replacing the kernel still gets use stock settings, like the
|
|
|
073af0 |
+ * server side. */
|
|
|
073af0 |
+ if (!rpmostree_run_dracut (self->tmprootfs_dfd, add_dracut_argv, kver, initramfs_path,
|
|
|
073af0 |
+ rpmostree_origin_get_regenerate_initramfs (self->origin),
|
|
|
073af0 |
+ NULL, &initramfs_tmpf, cancellable, error))
|
|
|
073af0 |
return FALSE;
|
|
|
073af0 |
|
|
|
073af0 |
if (!rpmostree_finalize_kernel (self->tmprootfs_dfd, bootdir, kver, kernel_path,
|
|
|
073af0 |
diff --git a/src/libpriv/rpmostree-kernel.c b/src/libpriv/rpmostree-kernel.c
|
|
|
073af0 |
index d1f0c90c..a1e4546c 100644
|
|
|
073af0 |
--- a/src/libpriv/rpmostree-kernel.c
|
|
|
073af0 |
+++ b/src/libpriv/rpmostree-kernel.c
|
|
|
073af0 |
@@ -475,6 +475,7 @@ rpmostree_run_dracut (int rootfs_dfd,
|
|
|
073af0 |
const char *const* argv,
|
|
|
073af0 |
const char *kver,
|
|
|
073af0 |
const char *rebuild_from_initramfs,
|
|
|
073af0 |
+ gboolean use_root_etc,
|
|
|
073af0 |
GLnxTmpDir *dracut_host_tmpdir,
|
|
|
073af0 |
GLnxTmpfile *out_initramfs_tmpf,
|
|
|
073af0 |
GCancellable *cancellable,
|
|
|
073af0 |
@@ -562,10 +563,7 @@ rpmostree_run_dracut (int rootfs_dfd,
|
|
|
073af0 |
&tmpf, error))
|
|
|
073af0 |
goto out;
|
|
|
073af0 |
|
|
|
073af0 |
- /* If we're rebuilding, we use the *current* /etc so we pick up any modified
|
|
|
073af0 |
- * config files. Otherwise, we use the usr/etc defaults.
|
|
|
073af0 |
- */
|
|
|
073af0 |
- if (rebuild_from_initramfs)
|
|
|
073af0 |
+ if (use_root_etc)
|
|
|
073af0 |
{
|
|
|
073af0 |
bwrap = rpmostree_bwrap_new_base (rootfs_dfd, error);
|
|
|
073af0 |
if (!bwrap)
|
|
|
073af0 |
diff --git a/src/libpriv/rpmostree-kernel.h b/src/libpriv/rpmostree-kernel.h
|
|
|
073af0 |
index fb9d8a1b..32a36511 100644
|
|
|
073af0 |
--- a/src/libpriv/rpmostree-kernel.h
|
|
|
073af0 |
+++ b/src/libpriv/rpmostree-kernel.h
|
|
|
073af0 |
@@ -54,6 +54,7 @@ rpmostree_run_dracut (int rootfs_dfd,
|
|
|
073af0 |
const char *const* argv,
|
|
|
073af0 |
const char *kver,
|
|
|
073af0 |
const char *rebuild_from_initramfs,
|
|
|
073af0 |
+ gboolean use_root_etc,
|
|
|
073af0 |
GLnxTmpDir *dracut_host_tmpdir,
|
|
|
073af0 |
GLnxTmpfile *out_initramfs_tmpf,
|
|
|
073af0 |
GCancellable *cancellable,
|
|
|
073af0 |
diff --git a/src/libpriv/rpmostree-postprocess.c b/src/libpriv/rpmostree-postprocess.c
|
|
|
073af0 |
index ce7424a1..186817be 100644
|
|
|
073af0 |
--- a/src/libpriv/rpmostree-postprocess.c
|
|
|
073af0 |
+++ b/src/libpriv/rpmostree-postprocess.c
|
|
|
073af0 |
@@ -447,7 +447,7 @@ process_kernel_and_initramfs (int rootfs_dfd,
|
|
|
073af0 |
return FALSE;
|
|
|
073af0 |
if (!rpmostree_run_dracut (rootfs_dfd,
|
|
|
073af0 |
(const char *const*)dracut_argv->pdata, kver,
|
|
|
073af0 |
- NULL, &dracut_host_tmpd,
|
|
|
073af0 |
+ NULL, FALSE, &dracut_host_tmpd,
|
|
|
073af0 |
&initramfs_tmpf, cancellable, error))
|
|
|
073af0 |
return FALSE;
|
|
|
073af0 |
/* No reason to have the initramfs not be world-readable since
|
|
|
073af0 |
diff --git a/tests/vmcheck/test-override-kernel.sh b/tests/vmcheck/test-override-kernel.sh
|
|
|
073af0 |
index 0e8c91b7..4bde242a 100755
|
|
|
073af0 |
--- a/tests/vmcheck/test-override-kernel.sh
|
|
|
073af0 |
+++ b/tests/vmcheck/test-override-kernel.sh
|
|
|
073af0 |
@@ -60,3 +60,12 @@ assert_streq "$(wc -l < modules-dirs.txt)" "2"
|
|
|
073af0 |
assert_file_has_content_literal modules-dirs.txt $kernel_release
|
|
|
073af0 |
|
|
|
073af0 |
echo "ok override kernel"
|
|
|
073af0 |
+
|
|
|
073af0 |
+# And check that we can regenerate the initramfs and include files from our /etc
|
|
|
073af0 |
+vm_cmd touch /etc/foobar.conf
|
|
|
073af0 |
+vm_rpmostree initramfs --enable --arg=-I --arg=/etc/foobar.conf
|
|
|
073af0 |
+newroot=$(vm_get_deployment_root 0)
|
|
|
073af0 |
+vm_cmd lsinitrd ${newroot}/usr/lib/modules/${kernel_release}/initramfs.img > lsinitrd.txt
|
|
|
073af0 |
+assert_file_has_content_literal lsinitrd.txt etc/foobar.conf
|
|
|
073af0 |
+
|
|
|
073af0 |
+echo "ok override kernel with custom initramfs args"
|
|
|
073af0 |
--
|
|
|
073af0 |
2.24.1
|
|
|
073af0 |
|