Migrate distroless rTorrent runtime to openSUSE Tumbleweed
Build and Push Docker Image / build (push) Successful in 1m23s

This commit is contained in:
Ketan Patel committed 2026-11-01 21:45:11 -05:00
1 parent 18c861f52c
commit 5295c67f77
4 files changed
+84 -25

No files matched your search

+24 -3
View File
@@ -1,6 +1,7 @@
#define _POSIX_C_SOURCE 200809L
#include <arpa/inet.h>
#include <errno.h>
#include <netdb.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
@@ -16,15 +17,34 @@ static void pause_tick(void) {
nanosleep(&delay, NULL);
}
int main(void) {
int main(int argc, char **argv) {
if (argc == 3 && strcmp(argv[1], "--resolve") == 0) {
struct addrinfo *addresses = NULL;
int error = getaddrinfo(argv[2], NULL, NULL, &addresses);
if (error) {
fprintf(stderr, "Name lookup failed for %s: %s\n", argv[2], gai_strerror(error));
return 1;
}
freeaddrinfo(addresses);
puts("Distroless name lookup passed");
return 0;
}
alarm(60); /* Fail the build if a scheduled execute hook stalls rTorrent. */
const char *forbidden[] = {"/bin/sh", "/bin/bash", "/bin/busybox", "/sbin/apk", NULL};
const char *forbidden[] = {"/bin/sh", "/bin/bash", "/bin/busybox", "/sbin/apk",
"/usr/bin/zypper", "/usr/bin/rpm", "/usr/bin/gcc", "/usr/bin/python3", NULL};
for (int i = 0; forbidden[i]; ++i) {
if (access(forbidden[i], F_OK) == 0) {
fprintf(stderr, "Unexpected runtime tool: %s\n", forbidden[i]);
return 1;
}
}
struct addrinfo *addresses = NULL;
if (getaddrinfo("localhost", NULL, NULL, &addresses) != 0) return 1;
freeaddrinfo(addresses);
if (access("/etc/ssl/ca-bundle.pem", R_OK) != 0) {
fprintf(stderr, "CA certificate bundle is missing\n");
return 1;
}
/* Exercise the production execute.capture hook without external networking. */
FILE *fixture = fopen("/tmp/rtorrent-public-ip.txt", "w");
if (!fixture) return 1;
@@ -37,7 +57,7 @@ int main(void) {
fputs("system.daemon.set = true\nnetwork.bind_address.set = 0.0.0.0\n"
"network.scgi.open_port = 127.0.0.1:5001\n"
"method.insert = get_public_ip_address, simple|private, \"execute.capture=/usr/local/bin/rtorrent-public-ip,file:///tmp/rtorrent-public-ip.txt\"\n"
"schedule2 = ip_tick, 0, 1800, \"network.local_address.set=(get_public_ip_address)\"\n", f);
"schedule = ip_tick, 0, 1800, \"network.local_address.set=(get_public_ip_address)\"\n", f);
fclose(f);
f = fopen(lock, "w");
if (!f) return 1;
@@ -83,6 +103,7 @@ int main(void) {
memcpy(request + length, body, strlen(body));
length += strlen(body);
if (send(fd, request, length, 0) != (ssize_t)length) goto cleanup;
if (shutdown(fd, SHUT_WR) != 0) goto cleanup; /* Match Flood's stream.end(request). */
size_t used = 0;
ssize_t n;
while (used < sizeof(response) - 1 && (n = recv(fd, response + used, sizeof(response) - 1 - used, 0)) > 0)