return 0;
}
+static int pakfire_jail_setup_pipe(struct pakfire_jail* jail, int (*fds)[2], const int flags) {
+ int r = pipe2(*fds, flags);
+ if (r < 0) {
+ ERROR(jail->pakfire, "Could not setup pipe: %m\n");
+ return 1;
+ }
+
+ return 0;
+}
+
+static void pakfire_jail_close_pipe(struct pakfire_jail* jail, int fds[2]) {
+ for (unsigned int i = 0; i < 2; i++)
+ if (fds[i])
+ close(fds[i]);
+}
+
/*
This is a convenience function to fetch the reading end of a pipe and
closes the write end.
return 1;
}
- // Close the reading sides of the pipe
- close(ctx->pipes.stdout[0]);
- close(ctx->pipes.stderr[0]);
+ // Close the pipe (as we have moved the original file descriptors)
+ pakfire_jail_close_pipe(jail, ctx->pipes.stdout);
+ pakfire_jail_close_pipe(jail, ctx->pipes.stderr);
}
// Reset open file limit (http://0pointer.net/blog/file-descriptor-limits.html)
return r;
}
-static int pakfire_jail_setup_pipe(struct pakfire_jail* jail, int (*fds)[2], const int flags) {
- int r = pipe2(*fds, flags);
- if (r < 0) {
- ERROR(jail->pakfire, "Could not setup pipe: %m\n");
- return 1;
- }
-
- return 0;
-}
-
-static void pakfire_jail_close_pipe(struct pakfire_jail* jail, int fds[2]) {
- for (unsigned int i = 0; i < 2; i++)
- if (fds[i])
- close(fds[i]);
-}
-
// Run a command in the jail
static int __pakfire_jail_exec(struct pakfire_jail* jail, const char* argv[]) {
int exit = -1;