From 418c2a2a674f8099a67977ab7e21fa5efdd26f2b Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sun, 13 Sep 2026 18:37:28 +0200 Subject: [PATCH] openssh_fixture: merge Apple container commands with others Use the full `image pull`, `image tag` commands for docker and podman, to make them all use the same commands. Ref: https://docs.docker.com/reference/cli/docker/image/pull/ https://docs.docker.com/reference/cli/docker/image/tag/ Follow-up to 9bd1f16dc225733105949387d77a477447b6f858 #2605 Closes #2622 --- tests/openssh_fixture.c | 55 ++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 34 deletions(-) diff --git a/tests/openssh_fixture.c b/tests/openssh_fixture.c index 15077e27..3b44a459 100644 --- a/tests/openssh_fixture.c +++ b/tests/openssh_fixture.c @@ -172,28 +172,17 @@ static int build_openssh_server_container_image(void) if(container_cmd) { const char *container_image_name = openssh_server_image(); if(container_image_name) { - int ret; - if(strstr(container_cmd, "container")) { - /* Requires Apple container 0.7.0+ for '--progress none' */ - ret = run_command(NULL, "%s image pull --progress none %s", - container_cmd, container_image_name); - if(ret == 0) { - ret = run_command(NULL, "%s image tag %s " - "libssh2/openssh_server", - container_cmd, container_image_name); - if(ret == 0) - return ret; - } - } - else { - ret = run_command(NULL, "%s pull %s", - container_cmd, container_image_name); - if(ret == 0) { - ret = run_command(NULL, "%s tag %s libssh2/openssh_server", - container_cmd, container_image_name); - if(ret == 0) - return ret; - } + int ret = run_command(NULL, "%s image pull %s%s", container_cmd, + /* Requires Apple container 0.7.0+ */ + strstr(container_cmd, "container") ? + "--progress none " : "", + container_image_name); + if(!ret) { + ret = run_command(NULL, "%s image tag %s " + "libssh2/openssh_server", container_cmd, + container_image_name); + if(!ret) + return ret; } } return run_command(NULL, @@ -213,20 +202,18 @@ static int start_openssh_server(char **container_id_out) { if(container_cmd) { const char *container_host_port = openssh_server_port(); - if(strstr(container_cmd, "container")) { - if(!container_host_port) { - fprintf(stderr, "OPENSSH_SERVER_PORT must be set\n"); - return 1; - } - /* Requires Apple container 0.7.0+ for '--progress none' */ - return run_command(container_id_out, "%s run --progress none " - "--rm -d -p %s:22 libssh2/openssh_server", - container_cmd, container_host_port); + if(strstr(container_cmd, "container") && !container_host_port) { + fprintf(stderr, "OPENSSH_SERVER_PORT must be set\n"); + return 1; } - else if(container_host_port) - return run_command(container_id_out, "%s run " + if(container_host_port) + return run_command(container_id_out, "%s run %s" "--rm -d -p %s:22 libssh2/openssh_server", - container_cmd, container_host_port); + container_cmd, + /* Requires Apple container 0.7.0+ */ + strstr(container_cmd, "container") ? + "--progress none " : "", + container_host_port); return run_command(container_id_out, "%s run --rm -d -p 22 " "libssh2/openssh_server", container_cmd); }