]> git.ipfire.org Git - pakfire.git/commitdiff
jail: Only try to restore file descriptors if they are still open
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 16 Dec 2023 13:07:00 +0000 (13:07 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 16 Dec 2023 13:07:00 +0000 (13:07 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/jail.c

index 7f67d080aefb62056a7457392b56093c5df51faf..c26b3d09bc3a7e073c7b488f9ab528225664e863 100644 (file)
@@ -1251,8 +1251,10 @@ ERROR:
                close(timerfd);
 
        // Restore any changed terminal attributes
-       pakfire_jail_restore_attrs(jail, &ctx->pty.stdin);
-       pakfire_jail_restore_attrs(jail, &ctx->pty.stdout);
+       if (ctx->pty.stdin.fd >= 0)
+               pakfire_jail_restore_attrs(jail, &ctx->pty.stdin);
+       if (ctx->pty.stdout.fd >= 0)
+               pakfire_jail_restore_attrs(jail, &ctx->pty.stdout);
 
        return r;
 }