]> git.ipfire.org Git - pakfire.git/commitdiff
jail: Wait a little bit later in the child process
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 12 Oct 2024 14:37:26 +0000 (14:37 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 12 Oct 2024 14:37:26 +0000 (14:37 +0000)
That way, we can set for the child process to die before we start
waiting.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/jail.c

index 68522ecaabaf8928e56c3ce7dc26deaf49623deb..71612ca9d728096d0793275bda8dacb9a75504de 100644 (file)
@@ -1124,11 +1124,6 @@ static int pakfire_jail_child(struct pakfire_jail* jail, struct pakfire_jail_exe
 
        CTX_DEBUG(jail->ctx, "Launched child process in jail with PID %d\n", pid);
 
-       // Wait for the parent to finish initialization
-       r = pakfire_jail_wait_for_signal(jail, ctx->completed_fd);
-       if (r)
-               return r;
-
        // Die with parent
        r = prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0);
        if (r) {
@@ -1150,6 +1145,11 @@ static int pakfire_jail_child(struct pakfire_jail* jail, struct pakfire_jail_exe
                return 126;
        }
 
+       // Wait for the parent to finish initialization
+       r = pakfire_jail_wait_for_signal(jail, ctx->completed_fd);
+       if (r)
+               return r;
+
        // Fetch UID/GID
        uid_t uid = getuid();
        gid_t gid = getgid();