]> git.ipfire.org Git - pakfire.git/commitdiff
jail: Create a new systemd event loop
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 5 Oct 2024 15:34:05 +0000 (15:34 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 5 Oct 2024 15:34:05 +0000 (15:34 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/jail.c

index 5662ee202345c1c93e785715c2acaa8c1d0c1817..f95c361f2dc739d415fbf2270c8d7e3423089ca2 100644 (file)
@@ -50,6 +50,9 @@
 // libuuid
 #include <uuid.h>
 
+// systemd
+#include <systemd/sd-event.h>
+
 #include <pakfire/arch.h>
 #include <pakfire/cgroup.h>
 #include <pakfire/jail.h>
@@ -157,6 +160,7 @@ struct pakfire_jail {
 };
 
 struct pakfire_jail_exec {
+       sd_event* loop;
        int flags;
 
        // PID (of the child)
@@ -2349,6 +2353,13 @@ PAKFIRE_EXPORT int pakfire_jail_exec(struct pakfire_jail* jail, const char* argv
 
        CTX_DEBUG(jail->ctx, "Executing jail...\n");
 
+       // Create a new event loop
+       r = sd_event_new(&ctx.loop);
+       if (r < 0) {
+               CTX_ERROR(jail->ctx, "Could not create a new event loop: %s\n", strerror(-r));
+               goto ERROR;
+       }
+
        // Enable networking in interactive mode
        if (ctx.flags & PAKFIRE_JAIL_PTY_FORWARDING)
                ctx.flags |= PAKFIRE_JAIL_HAS_NETWORKING;
@@ -2502,6 +2513,9 @@ ERROR:
 #endif /* ENABLE_DEBUG */
        pakfire_jail_close_pipe(jail, ctx.socket);
 
+       if (ctx.loop)
+               sd_event_unref(ctx.loop);
+
        return exit;
 }