From: Michael Tremer Date: Thu, 10 Oct 2024 10:10:01 +0000 (+0000) Subject: jail: Remove functions that capture the command output X-Git-Tag: 0.9.30~1094 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dd0f2e3273c815acc7cc610873c05a5d8ded2a43;p=pakfire.git jail: Remove functions that capture the command output Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/include/pakfire/jail.h b/src/libpakfire/include/pakfire/jail.h index 55006fa9a..9aee36230 100644 --- a/src/libpakfire/include/pakfire/jail.h +++ b/src/libpakfire/include/pakfire/jail.h @@ -70,10 +70,6 @@ int pakfire_jail_exec(struct pakfire_jail* jail, const char* argv[], int flags, #include -// Capture -int pakfire_jail_capture_stdout(struct pakfire_ctx* ctx, struct pakfire_jail* jail, - void* data, const char* line, size_t length); - // Resource limits int pakfire_jail_set_cgroup(struct pakfire_jail* jail, struct pakfire_cgroup* cgroup); diff --git a/src/libpakfire/jail.c b/src/libpakfire/jail.c index 1eae57e34..d48f08b66 100644 --- a/src/libpakfire/jail.c +++ b/src/libpakfire/jail.c @@ -498,47 +498,6 @@ static void pakfire_jail_log_redirect(void* data, int priority, const char* file } } -static int pakfire_jail_drain_buffer_with_callback(struct pakfire_jail* jail, - struct pakfire_log_buffer* buffer, pakfire_jail_stdout_callback callback, void* data) { - const char* eol = NULL; - int r; - - while (buffer->used) { - // Search for the end of the first line - eol = memchr(buffer->data, '\n', buffer->used); - - // No newline found - if (!eol) { - // If the buffer is full, we send the entire content to make space. - if (buffer->used >= sizeof(buffer->data)) { - CTX_DEBUG(jail->ctx, "Buffer is full. Sending all content\n"); - - eol = buffer->data + buffer->used - 1; - - // Otherwise we might have only read parts of the output... - } else { - break; - } - } - - // Find the length of the string - const size_t length = eol - buffer->data + 1; - - // Call the callback - r = callback(jail->ctx, jail, data, buffer->data, length); - if (r) { - CTX_ERROR(jail->ctx, "The standard output callback returned an error: %d\n", r); - return r; - } - - // Remove line from buffer - memmove(buffer->data, buffer->data + length, buffer->used - length); - buffer->used -= length; - } - - return 0; -} - /* Passes any log messages on to the context logger */ @@ -603,26 +562,6 @@ static int pakfire_jail_stream_stdin(struct pakfire_jail* jail, } } -static int pakfire_jail_command_output(struct pakfire_ctx* ctx, struct pakfire_jail* jail, - void* data, const char* line, const size_t length) { - CTX_INFO(ctx, "Command Output: %.*s", (int)length, line); - - return 0; -} - -int pakfire_jail_capture_stdout(struct pakfire_ctx* ctx, struct pakfire_jail* jail, - void* data, const char* line, size_t length) { - char** output = (char**)data; - int r; - - // Append everything from stdout to a buffer - r = asprintf(output, "%s%.*s", (output && *output) ? *output : "", (int)length, line); - if (r < 0) - return -errno; - - return 0; -} - // Capabilities // Logs all capabilities of the current process