Source: libssh2
Version: 1.9.0-2
Severity: serious
Tags: ftbfs patch
Hi!
Building libssh2 using debuild in a clean local chroot, I get test
failures and even a core dump!
...
PASS: mansyntax.sh
PASS: test_simple
FAIL: test_sshd.test 1 - sshd-test_ssh2
FAIL: test_sshd.test 2 - sshd-test_auth_pubkey_ok_ed25519
=====================================
libssh2 -: tests/test-suite.log
=====================================
# TOTAL: 4
# PASS: 2
# SKIP: 0
# XFAIL: 0
# FAIL: 2
# XPASS: 0
# ERROR: 0
.. contents:: :depth: 2
FAIL: test_sshd
===============
Fingerprint: 12 FD AD 1E 3B 31 B1 0B AB B0 0F 2A 8D 1B 9A 62 C3 26 BD 2F
Authentication methods: publickey,password,keyboard-interactive
Authentication by public key failed!
all done
./test_sshd.test: line 131: 2476672 Segmentation fault (core dumped)
"${test}"
# sshd executable: '/usr/sbin/sshd' (OpenSSH_9.4, OpenSSL 3.0.12 24 Oct 2023)
# ssh executable: '/usr/bin/ssh' (OpenSSH_9.4p1 Debian-1, OpenSSL 3.0.12 24 Oct
2023)
1..2
not ok 1 - sshd-test_ssh2
FAIL: test_sshd.test 1 - sshd-test_ssh2
not ok 2 - sshd-test_auth_pubkey_ok_ed25519
FAIL: test_sshd.test 2 - sshd-test_auth_pubkey_ok_ed25519
============================================================================
Testsuite summary for libssh2 -
============================================================================
# TOTAL: 4
# PASS: 2
# SKIP: 0
# XFAIL: 0
# FAIL: 2
# XPASS: 0
# ERROR: 0
============================================================================
These are both down to environment: the test code assumes that "USER"
is a valid environment varliable, which is not necessarily
true. Here's a patch which fixes this for these two tests, and fails
cleanly with diagnostics if there's a problem.
-- System Information:
Debian Release: 11.8
APT prefers oldstable-updates
APT policy: (500, 'oldstable-updates'), (500, 'oldstable-security'), (500,
'oldoldstable'), (500, 'oldstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 5.10.0-26-amd64 (SMP w/8 CPU threads)
Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8),
LANGUAGE=en_GB:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
diff --git a/tests/session_fixture.c b/tests/session_fixture.c
index 3bb9da2..4671117 100644
--- a/tests/session_fixture.c
+++ b/tests/session_fixture.c
@@ -430,11 +430,18 @@ int test_auth_pubkey(LIBSSH2_SESSION *session, int flags,
/* Ignore our hard-wired Dockerfile user when not running under Docker */
if(!openssh_fixture_have_docker() && strcmp(username, "libssh2") == 0) {
- username = getenv("USER");
+ if(getenv("USER"))
+ username = getenv("USER");
+ else if(getenv("LOGNAME"))
+ username = getenv("LOGNAME");
#ifdef WIN32
- if(!username)
+ else if(getenv("USERNAME"))
username = getenv("USERNAME");
#endif
+ else {
+ fprintf(stderr, "Failed to find a username from env\n");
+ return 1;
+ }
}
userauth_list = libssh2_userauth_list(session, username,
diff --git a/tests/test_ssh2.c b/tests/test_ssh2.c
index a637cdc..6e28598 100644
--- a/tests/test_ssh2.c
+++ b/tests/test_ssh2.c
@@ -63,10 +63,16 @@ int main(int argc, char *argv[])
if(getenv("USER"))
username = getenv("USER");
+ else if(getenv("LOGNAME"))
+ username = getenv("LOGNAME");
#ifdef WIN32
else if(getenv("USERNAME"))
username = getenv("USERNAME");
#endif
+ else {
+ fprintf(stderr, "Failed to find a username from env\n");
+ return 1;
+ }
if(getenv("PRIVKEY"))
privkey = getenv("PRIVKEY");