Skip to content

Commit 49eb3b1

Browse files
committed
container: Do rpmdb cleanup in outer scope
Prep for the next change which ensures we cleanup rpmdb leftovers; we can't do that while possibly holding an open reference. Signed-off-by: Colin Walters <walters@verbum.org>
1 parent e64d9da commit 49eb3b1

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

src/libpriv/rpmostree-container.cxx

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,15 @@
3232

3333
#include <libglnx.h>
3434

35-
gboolean
36-
rpmostree_container_rebuild (rpmostreecxx::Treefile &treefile, GCancellable *cancellable,
37-
GError **error)
35+
static gboolean
36+
container_rebuild_inner (int rootfs_fd, rpmostreecxx::Treefile &treefile, GCancellable *cancellable,
37+
GError **error)
3838
{
3939
CXX_TRY (treefile.validate_for_container (), error);
4040

4141
g_autoptr (RpmOstreeContext) ctx = rpmostree_context_new_container ();
4242
rpmostree_context_set_treefile (ctx, treefile);
4343

44-
glnx_autofd int rootfs_fd = -1;
45-
if (!glnx_opendirat (AT_FDCWD, "/", TRUE, &rootfs_fd, error))
46-
return FALSE;
47-
4844
// Forcibly turn this on for the container flow because it's the only sane
4945
// way for installing RPM packages that invoke useradd/groupadd to work.
5046
g_setenv ("RPMOSTREE_EXP_BRIDGE_SYSUSERS", "1", TRUE);
@@ -78,6 +74,22 @@ rpmostree_container_rebuild (rpmostreecxx::Treefile &treefile, GCancellable *can
7874

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

77+
return TRUE;
78+
}
79+
80+
gboolean
81+
rpmostree_container_rebuild (rpmostreecxx::Treefile &treefile, GCancellable *cancellable,
82+
GError **error)
83+
{
84+
85+
glnx_autofd int rootfs_fd = -1;
86+
if (!glnx_opendirat (AT_FDCWD, "/", TRUE, &rootfs_fd, error))
87+
return FALSE;
88+
89+
// Do this in a new scope to ensure we teardown our connection to the rpmdb
90+
if (!container_rebuild_inner (rootfs_fd, treefile, cancellable, error))
91+
return FALSE;
92+
8193
CXX_TRY (rpmostreecxx::postprocess_cleanup_rpmdb (rootfs_fd), error);
8294

8395
return TRUE;

0 commit comments

Comments
 (0)