tests: Skip agent forwarding test if we are too deep in filesystem

The maximal lenght of unix domain socket path is 108 characters. When
the build directory (and UID wrapper home directories) are too deep
in the filesystem, OpenSSH will fail to create the socket file,
which is failing this test.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Pavol Žáčik <pzacik@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Jakub Jelen
2026-01-09 16:31:29 +01:00
parent 18ec01c980
commit c90b239230

View File

@@ -18,6 +18,10 @@
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> /* usleep */ #include <unistd.h> /* usleep */
#ifndef UNIX_PATH_MAX
#define UNIX_PATH_MAX 108
#endif
/* struct to store the state of the test */ /* struct to store the state of the test */
struct agent_callback_state { struct agent_callback_state {
int called; int called;
@@ -137,6 +141,19 @@ static void torture_auth_agent_forwarding(void **state)
int read_count = 0; int read_count = 0;
bool agent_available = false; bool agent_available = false;
bool agent_not_available_found = false; bool agent_not_available_found = false;
size_t exp_socket_len;
/* The forwarded agent socket is created under the home directory, which
* might easily extend the maximum unix domain socket path length.
* If we see this, just skip the test as it will not work */
exp_socket_len = strlen(BINARYDIR) +
strlen("/home/bob/.ssh/agent.1234567890.sshd.XXXXXXXXXX");
if (exp_socket_len > UNIX_PATH_MAX) {
SSH_LOG(SSH_LOG_WARNING,
"The working directory is too long for agent forwarding to work"
": Skipping the test");
skip();
}
assert_non_null(s); assert_non_null(s);
session = s->ssh.ssh.session; session = s->ssh.ssh.session;