]> git.ipfire.org Git - people/stevee/pakfire.git/commitdiff
jail: communicate: Mark the stdin fd as closed to avoid later writes
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 16 Dec 2022 10:25:26 +0000 (10:25 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 16 Dec 2022 10:25:26 +0000 (10:25 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/jail.c

index 20785045e601479b0c565d6a609648d6b7c0086f..391437fa1fe50bb65f75e4fbcb828b7fc45a0f84 100644 (file)
@@ -543,6 +543,10 @@ static int pakfire_jail_stream_stdin(struct pakfire_jail* jail,
                return 0;
        }
 
+       // Skip if the writing pipe has already been closed
+       if (!ctx->pipes.stdin[1])
+               return 0;
+
        DEBUG(jail->pakfire, "Streaming standard input...\n");
 
        // Calling the callback
@@ -554,7 +558,13 @@ static int pakfire_jail_stream_stdin(struct pakfire_jail* jail,
        if (r == EOF) {
                DEBUG(jail->pakfire, "Closing standard input pipe\n");
 
+               // Close the file-descriptor
                close(fd);
+
+               // Reset the file-descriptor so it won't be closed again later
+               ctx->pipes.stdin[1] = 0;
+
+               // Report success
                r = 0;
        }