]> git.ipfire.org Git - pakfire.git/commitdiff
jail: Send log stuff to the context logger
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 16 Oct 2023 10:07:58 +0000 (10:07 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 16 Oct 2023 10:07:58 +0000 (10:07 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/jail.c

index 52291408dc2c7fb8663698f4c100aefb94d847b8..86b85229a33160a3441f7b7e779a80382f50defd 100644 (file)
@@ -89,6 +89,7 @@ struct pakfire_jail_mountpoint {
 };
 
 struct pakfire_jail {
+       struct pakfire_ctx* ctx;
        struct pakfire* pakfire;
        int nrefs;
 
@@ -198,8 +199,10 @@ static void pakfire_jail_free(struct pakfire_jail* jail) {
 
        if (jail->cgroup)
                pakfire_cgroup_unref(jail->cgroup);
-
-       pakfire_unref(jail->pakfire);
+       if (jail->pakfire)
+               pakfire_unref(jail->pakfire);
+       if (jail->ctx)
+               pakfire_ctx_unref(jail->ctx);
        free(jail);
 }
 
@@ -269,6 +272,9 @@ PAKFIRE_EXPORT int pakfire_jail_create(struct pakfire_jail** jail, struct pakfir
        if (!j)
                return 1;
 
+       // Reference context
+       j->ctx = pakfire_ctx(pakfire);
+
        // Reference Pakfire
        j->pakfire = pakfire_ref(pakfire);
 
@@ -1639,7 +1645,7 @@ static int pakfire_jail_child(struct pakfire_jail* jail, struct pakfire_jail_exe
        int r;
 
        // Redirect any logging to our log pipe
-       pakfire_set_log_callback(jail->pakfire, pakfire_jail_log_redirect, &ctx->pipes);
+       pakfire_ctx_set_log_callback(jail->ctx, pakfire_jail_log_redirect, &ctx->pipes);
 
        // Fetch my own PID
        pid_t pid = getpid();