]> git.ipfire.org Git - pakfire.git/commitdiff
jail: Remove functions that capture the command output
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 10 Oct 2024 10:10:01 +0000 (10:10 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 10 Oct 2024 10:10:01 +0000 (10:10 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/include/pakfire/jail.h
src/libpakfire/jail.c

index 55006fa9a7a1b303923170eee8951bc42cf9ce9d..9aee36230a76edab9b91d5ea65b6dea40dacd481 100644 (file)
@@ -70,10 +70,6 @@ int pakfire_jail_exec(struct pakfire_jail* jail, const char* argv[], int flags,
 
 #include <pakfire/cgroup.h>
 
-// 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);
 
index 1eae57e34388945b16a4458d4f6dcedac08acade..d48f08b6656e4d8a678d7e7c7c2b57cbf770ea94 100644 (file)
@@ -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