return PAKFIRE_WALK_OK;
}
-static int pakfire_archive_stream_payload(struct pakfire* pakfire, void* data, int fd) {
+static int pakfire_archive_stream_payload(struct pakfire_ctx* ctx,
+ struct pakfire_jail* jail, void* data, int fd) {
char buffer[1024];
struct archive* a = (struct archive*)data;
// Read a block from the input archive
ssize_t bytes_read = archive_read_data(a, buffer, sizeof(buffer));
if (bytes_read < 0) {
- ERROR(pakfire, "Could not read from archive: %s\n", archive_error_string(a));
+ CTX_ERROR(ctx, "Could not read from archive: %s\n", archive_error_string(a));
return 1;
}
// Write the data to the output file descriptor
ssize_t bytes_written = write(fd, buffer, bytes_read);
if (bytes_written < 0) {
- ERROR(pakfire, "Could not stream output: %m\n");
+ CTX_ERROR(ctx, "Could not stream output: %m\n");
return 1;
}
if (r)
goto ERROR;
- r = pakfire_jail_exec(jail, argv, pakfire_archive_stream_payload, NULL, a,
- PAKFIRE_JAIL_NOENT_OK);
+ // Set callback
+ pakfire_jail_set_stdin_callback(jail, pakfire_archive_stream_payload, a);
+
+ // Run!
+ r = pakfire_jail_exec(jail, argv, PAKFIRE_JAIL_NOENT_OK);
ERROR:
if (jail)