]> git.ipfire.org Git - people/ms/pakfire.git/blobdiff - src/libpakfire/archive.c
jail: Remove callbacks from command calls
[people/ms/pakfire.git] / src / libpakfire / archive.c
index 984d4d7deb94fa1c3acc2ab82fb81a46567c279a..a263cd84884cd7ca396133d90ec613b23188d870 100644 (file)
@@ -1398,7 +1398,8 @@ static int __pakfire_archive_filter_systemd_sysusers(struct pakfire_ctx* ctx,
        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;
@@ -1406,7 +1407,7 @@ static int pakfire_archive_stream_payload(struct pakfire* pakfire, void* data, i
        // 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;
        }
 
@@ -1417,7 +1418,7 @@ static int pakfire_archive_stream_payload(struct pakfire* pakfire, void* data, i
        // 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;
        }
 
@@ -1447,8 +1448,11 @@ static int __pakfire_archive_handle_systemd_sysusers(struct pakfire_ctx* ctx,
        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)