diff --git a/Makefile-libpriv.am b/Makefile-libpriv.am index ddcb64eb..49d5e2c9 100644 --- a/Makefile-libpriv.am +++ b/Makefile-libpriv.am @@ -75,11 +75,6 @@ CLEANFILES += $(gperf_gperf_sources:-gperf.gperf=-gperf.c) nodist_librpmostreepriv_sources = src/libpriv/rpmostree-script-gperf.c -rpmostree-libpriv-gresources.c: src/libpriv/gresources.xml Makefile $(shell glib-compile-resources --sourcedir=$(srcdir)/src/libpriv --generate-dependencies $(srcdir)/src/libpriv/gresources.xml) - $(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir)/src/libpriv --generate-source --c-name _rpmostree_ $< -BUILT_SOURCES += rpmostree-libpriv-gresources.c -librpmostreepriv_sources += rpmostree-libpriv-gresources.c - AM_V_GPERF = $(AM_V_GPERF_$(V)) AM_V_GPERF_ = $(AM_V_GPERF_$(AM_DEFAULT_VERBOSITY)) AM_V_GPERF_0 = @echo " GPERF " $@; diff --git a/rust/src/core.rs b/rust/src/core.rs index 2e79e4fa..318d5885 100644 --- a/rust/src/core.rs +++ b/rust/src/core.rs @@ -44,6 +44,10 @@ impl TempEtcGuard { } } +pub(crate) fn get_systemctl_wrapper() -> &'static [u8] { + include_bytes!("../../src/libpriv/systemctl-wrapper.sh") +} + #[cfg(test)] mod test { use super::*; diff --git a/rust/src/initramfs.rs b/rust/src/initramfs.rs index dd433ac2..13fb6750 100644 --- a/rust/src/initramfs.rs +++ b/rust/src/initramfs.rs @@ -118,6 +118,11 @@ fn generate_initramfs_overlay_etc>( generate_initramfs_overlay(&root, files, cancellable) } +pub(crate) fn get_dracut_random_cpio() -> &'static [u8] { + // Generated with: fakeroot /bin/sh -c 'cd dracut-urandom && find . -print0 | sort -z | (mknod dev/random c 1 8 && mknod dev/urandom c 1 9 && cpio -o --null -H newc -R 0:0 --reproducible --quiet -D . -O /tmp/dracut-urandom.cpio)' + include_bytes!("../../src/libpriv/dracut-random.cpio.gz") +} + #[cfg(test)] mod test { use super::*; @@ -143,7 +148,7 @@ mod test { } } -pub mod ffi { +mod ffi { use super::*; use crate::ffiutil::error_to_glib; use glib::translate::*; @@ -177,3 +182,4 @@ pub mod ffi { } } } +pub use self::ffi::*; diff --git a/rust/src/lib.rs b/rust/src/lib.rs index a560beb7..7732d6f6 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -18,6 +18,13 @@ mod ffi { fn prepare_tempetc_guard(rootfs: i32) -> Result>; fn undo(self: &TempEtcGuard) -> Result<()>; + + fn get_systemctl_wrapper() -> &'static [u8]; + } + + // initramfs.rs + extern "Rust" { + fn get_dracut_random_cpio() -> &'static [u8]; } // utils.rs @@ -37,7 +44,7 @@ pub use self::history::*; mod journal; pub use self::journal::*; mod initramfs; -pub use self::initramfs::ffi::*; +pub use self::initramfs::*; mod lockfile; pub use self::lockfile::*; mod livefs; diff --git a/src/libpriv/gresources.xml b/src/libpriv/gresources.xml deleted file mode 100644 index 53d57b9c..00000000 --- a/src/libpriv/gresources.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - systemctl-wrapper.sh - - dracut-random.cpio.gz - - diff --git a/src/libpriv/rpmostree-core.cxx b/src/libpriv/rpmostree-core.cxx index 73a48a5c..a66dd005 100644 --- a/src/libpriv/rpmostree-core.cxx +++ b/src/libpriv/rpmostree-core.cxx @@ -4369,15 +4369,9 @@ rpmostree_context_assemble (RpmOstreeContext *self, else { have_systemctl = TRUE; - g_autoptr(GBytes) systemctl_wrapper = g_resources_lookup_data ("/rpmostree/systemctl-wrapper.sh", - G_RESOURCE_LOOKUP_FLAGS_NONE, - error); - if (!systemctl_wrapper) - return FALSE; - size_t len; - auto buf = static_cast(g_bytes_get_data (systemctl_wrapper, &len)); + auto systemctl_wrapper = rpmostreecxx::get_systemctl_wrapper (); if (!glnx_file_replace_contents_with_perms_at (tmprootfs_dfd, "usr/bin/systemctl", - buf, len, 0755, (uid_t) -1, (gid_t) -1, + systemctl_wrapper.data(), systemctl_wrapper.length(), 0755, (uid_t) -1, (gid_t) -1, GLNX_FILE_REPLACE_NODATASYNC, cancellable, error)) return FALSE; diff --git a/src/libpriv/rpmostree-kernel.cxx b/src/libpriv/rpmostree-kernel.cxx index a076a4a8..953f598e 100644 --- a/src/libpriv/rpmostree-kernel.cxx +++ b/src/libpriv/rpmostree-kernel.cxx @@ -525,7 +525,6 @@ rpmostree_run_dracut (int rootfs_dfd, g_autoptr(RpmOstreeBwrap) bwrap = NULL; g_autoptr(GPtrArray) rebuild_argv = NULL; g_auto(GLnxTmpfile) tmpf = { 0, }; - g_autoptr(GBytes) random_cpio_data = NULL; /* We need to have /etc/passwd since dracut doesn't have altfiles * today. Though maybe in the future we should add it, but @@ -627,16 +626,10 @@ rpmostree_run_dracut (int rootfs_dfd, * https://bugzilla.redhat.com/show_bug.cgi?id=1401444 * https://bugzilla.redhat.com/show_bug.cgi?id=1380866 * */ - random_cpio_data = g_resources_lookup_data ("/rpmostree/dracut-random.cpio.gz", - G_RESOURCE_LOOKUP_FLAGS_NONE, - error); - if (!random_cpio_data) - return FALSE; - gsize random_cpio_data_len = 0; - auto random_cpio_data_p = static_cast(g_bytes_get_data (random_cpio_data, &random_cpio_data_len)); + auto random_cpio_data = rpmostreecxx::get_dracut_random_cpio (); if (lseek (tmpf.fd, 0, SEEK_END) < 0) return glnx_throw_errno_prefix (error, "lseek"); - if (glnx_loop_write (tmpf.fd, random_cpio_data_p, random_cpio_data_len) < 0) + if (glnx_loop_write (tmpf.fd, random_cpio_data.data(), random_cpio_data.length()) < 0) return glnx_throw_errno_prefix (error, "write"); if (rebuild_from_initramfs)