// Process status (from waitpid)
int status;
+ // FD to notify the client that the parent has finished initialization
+ int completed_fd;
+
// Log pipes
union {
int stdout[2];
/*
Performs the initialisation that needs to happen in the parent part
*/
-static int pakfire_jail_parent(struct pakfire_jail* jail, struct pakfire_jail_exec* ctx,
- int completed_fd) {
+static int pakfire_jail_parent(struct pakfire_jail* jail, struct pakfire_jail_exec* ctx) {
int r;
// Setup UID mapping
DEBUG(jail->pakfire, "Parent has finished initialization\n");
// Send signal to client
- r = pakfire_jail_send_signal(jail, completed_fd);
+ r = pakfire_jail_send_signal(jail, ctx->completed_fd);
if (r)
return r;
}
static int pakfire_jail_child(struct pakfire_jail* jail, struct pakfire_jail_exec* ctx,
- const char* argv[], int completed_fd) {
+ const char* argv[]) {
int r;
// XXX do we have to reconfigure logging here?
DEBUG(jail->pakfire, "Launched child process in jail with PID %d\n", getpid());
// Wait for the parent to finish initialization
- r = pakfire_jail_wait_for_signal(jail, completed_fd);
+ r = pakfire_jail_wait_for_signal(jail, ctx->completed_fd);
if (r)
return r;
Setup a file descriptor which can be used to notify the client that the parent
has completed configuration.
*/
- int completed_fd = eventfd(0, EFD_CLOEXEC);
- if (completed_fd < 0) {
+ ctx.completed_fd = eventfd(0, EFD_CLOEXEC);
+ if (ctx.completed_fd < 0) {
ERROR(jail->pakfire, "eventfd() failed: %m\n");
return -1;
}
// Child process
} else if (ctx.pid == 0) {
- r = pakfire_jail_child(jail, &ctx, argv, completed_fd);
+ r = pakfire_jail_child(jail, &ctx, argv);
_exit(r);
}
// Parent process
- r = pakfire_jail_parent(jail, &ctx, completed_fd);
+ r = pakfire_jail_parent(jail, &ctx);
if (r)
goto ERROR;