return sd_event_exit(sd_event_source_get_event(source), 0);
}
+struct pakfire_jail_command {
+ const char** argv;
+ const char** envp;
+};
+
static int pakfire_jail_launch_command(struct pakfire_jail* jail, void* data) {
- char** argv = data;
+ struct pakfire_jail_command* command = data;
int r;
// Check if argv is valid
- if (!argv || !argv[0])
+ if (!command->argv || !command->argv[0])
return -EINVAL;
DEBUG(jail->ctx, "Launching command:\n");
// Log argv
- for (unsigned int i = 0; argv[i]; i++)
- DEBUG(jail->ctx, " argv[%u] = %s\n", i, argv[i]);
+ for (unsigned int i = 0; command->argv[i]; i++)
+ DEBUG(jail->ctx, " argv[%u] = %s\n", i, command->argv[i]);
// exec() command
- r = execvpe(argv[0], argv, jail->env);
+ r = execvpe(command->argv[0], (char**)command->argv, (char**)command->envp);
if (r < 0) {
// Translate errno into regular exit code
switch (errno) {
r = 1;
}
- ERROR(jail->ctx, "Could not execve(%s): %m\n", argv[0]);
+ ERROR(jail->ctx, "Could not execve(%s): %m\n", command->argv[0]);
}
// We should not get here
}
int pakfire_jail_exec(struct pakfire_jail* jail, const char* argv[], int flags) {
- return __pakfire_jail_exec(jail, pakfire_jail_launch_command, argv, flags,
+ struct pakfire_jail_command command = {
+ .argv = argv,
+ };
+
+ return __pakfire_jail_exec(jail, pakfire_jail_launch_command, &command, flags,
NULL, NULL, NULL, NULL, NULL, NULL);
}
int pakfire_jail_exec_capture_output(struct pakfire_jail* jail,
const char* argv[], int flags, char** output, size_t* length) {
- return __pakfire_jail_exec(jail, pakfire_jail_launch_command, argv, flags,
+ struct pakfire_jail_command command = {
+ .argv = argv,
+ };
+
+ return __pakfire_jail_exec(jail, pakfire_jail_launch_command, &command, flags,
NULL, NULL, NULL, NULL, output, length);
}
struct pakfire_jail* jail, const char* argv[], int flags,
pakfire_pty_stdin_callback stdin_callback, void* stdin_data,
pakfire_pty_stdout_callback stdout_callback, void* stdout_data) {
- return __pakfire_jail_exec(jail, pakfire_jail_launch_command, argv, flags,
+ struct pakfire_jail_command command = {
+ .argv = argv,
+ };
+
+ return __pakfire_jail_exec(jail, pakfire_jail_launch_command, &command, flags,
stdin_callback, stdin_data, stdout_callback, stdout_data, NULL, NULL);
}