// Timeout
int pakfire_jail_set_timeout(struct pakfire_jail* jail, unsigned int timeout);
-typedef int (*pakfire_jail_callback)(struct pakfire_jail* jail, void* data);
+typedef int (*pakfire_jail_callback)(struct pakfire_ctx* ctx, void* data);
// Standard Input
typedef int (*pakfire_jail_stdin_callback)
PAKFIRE_JAIL_HAS_LOOP_DEVICES = (1 << 3),
};
+int pakfire_jail_exec(struct pakfire_jail* jail,
+ pakfire_jail_callback callback, void* data, int flags);
+
int pakfire_jail_exec_command(struct pakfire_jail* jail,
const char* argv[], struct pakfire_env* env, int flags);
struct pakfire_cgroup_stats cgroup_stats;
// The function to be called once the jail has been set up
- int (*callback)(struct pakfire_jail* jail, void* data);
+ pakfire_jail_callback callback;
void* data;
};
}
struct pakfire_jail_command {
+ struct pakfire_jail* jail;
const char** argv;
struct pakfire_env* env;
};
-static int pakfire_jail_launch_command(struct pakfire_jail* jail, void* data) {
+static int pakfire_jail_launch_command(struct pakfire_ctx* ctx, void* data) {
struct pakfire_jail_command* command = data;
struct pakfire_env* env = NULL;
char** envp = NULL;
return -EINVAL;
// Create a new environment
- r = pakfire_env_create(&env, jail->ctx);
+ r = pakfire_env_create(&env, ctx);
if (r < 0)
goto ERROR;
// Merge the basic environment
- r = pakfire_env_merge(env, jail->env);
+ r = pakfire_env_merge(env, command->jail->env);
if (r < 0)
goto ERROR;
goto ERROR;
}
- DEBUG(jail->ctx, "Launching command:\n");
+ DEBUG(ctx, "Launching command:\n");
// Log argv
for (unsigned int i = 0; command->argv[i]; i++)
- DEBUG(jail->ctx, " argv[%u] = %s\n", i, command->argv[i]);
+ DEBUG(ctx, " argv[%u] = %s\n", i, command->argv[i]);
// Fetch the environment
envp = pakfire_env_get_envp(env);
r = 1;
}
- ERROR(jail->ctx, "Could not execve(%s): %m\n", command->argv[0]);
+ ERROR(ctx, "Could not execve(%s): %m\n", command->argv[0]);
}
ERROR:
}
// Call the callback
- return ctx->callback(jail, ctx->data);
+ return ctx->callback(jail->ctx, ctx->data);
}
// Run a command in the jail
int pakfire_jail_exec_command(struct pakfire_jail* jail,
const char* argv[], struct pakfire_env* env, int flags) {
struct pakfire_jail_command command = {
+ .jail = jail,
.argv = argv,
.env = env,
};
int pakfire_jail_exec_capture_output(struct pakfire_jail* jail,
const char* argv[], struct pakfire_env* env, int flags, char** output, size_t* length) {
struct pakfire_jail_command command = {
+ .jail = jail,
.argv = argv,
.env = env,
};
pakfire_pty_stdin_callback stdin_callback, void* stdin_data,
pakfire_pty_stdout_callback stdout_callback, void* stdout_data) {
struct pakfire_jail_command command = {
+ .jail = jail,
.argv = argv,
.env = env,
};