Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

container: Do rpmdb cleanup in outer scope #5247

Merged
merged 1 commit into from
Jan 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions src/libpriv/rpmostree-container.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,15 @@

#include <libglnx.h>

gboolean
rpmostree_container_rebuild (rpmostreecxx::Treefile &treefile, GCancellable *cancellable,
GError **error)
static gboolean
container_rebuild_inner (int rootfs_fd, rpmostreecxx::Treefile &treefile, GCancellable *cancellable,
GError **error)
{
CXX_TRY (treefile.validate_for_container (), error);

g_autoptr (RpmOstreeContext) ctx = rpmostree_context_new_container ();
rpmostree_context_set_treefile (ctx, treefile);

glnx_autofd int rootfs_fd = -1;
if (!glnx_opendirat (AT_FDCWD, "/", TRUE, &rootfs_fd, error))
return FALSE;

// Forcibly turn this on for the container flow because it's the only sane
// way for installing RPM packages that invoke useradd/groupadd to work.
g_setenv ("RPMOSTREE_EXP_BRIDGE_SYSUSERS", "1", TRUE);
Expand Down Expand Up @@ -78,6 +74,22 @@ rpmostree_container_rebuild (rpmostreecxx::Treefile &treefile, GCancellable *can

CXX_TRY (fs_prep->undo (), error);

return TRUE;
}

gboolean
rpmostree_container_rebuild (rpmostreecxx::Treefile &treefile, GCancellable *cancellable,
GError **error)
{

glnx_autofd int rootfs_fd = -1;
if (!glnx_opendirat (AT_FDCWD, "/", TRUE, &rootfs_fd, error))
return FALSE;

// Do this in a new scope to ensure we teardown our connection to the rpmdb
if (!container_rebuild_inner (rootfs_fd, treefile, cancellable, error))
return FALSE;

CXX_TRY (rpmostreecxx::postprocess_cleanup_rpmdb (rootfs_fd), error);

return TRUE;
Expand Down
Loading