tests: Make test suite work out of the box on Debian

* tests/torture.c (torture_setup_create_sshd_config): Rework how the
location of the sftp server is discovered, and add the Debian-specific
location.

Signed-off-by: Justus Winter <justus@g10code.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Justus Winter
2016-03-16 12:32:29 +01:00
committed by Andreas Schneider
parent 926b9e937b
commit e37fd83254

View File

@@ -866,7 +866,15 @@ static void torture_setup_create_sshd_config(void **state)
char sshd_config[2048]; char sshd_config[2048];
char sshd_path[1024]; char sshd_path[1024];
struct stat sb; struct stat sb;
const char *sftp_server_locations[] = {
"/usr/lib/ssh/sftp-server",
"/usr/libexec/sftp-server",
"/usr/libexec/openssh/sftp-server",
"/usr/lib/openssh/sftp-server", /* Debian */
};
size_t sftp_sl_size = ARRAY_SIZE(sftp_server_locations);
const char *sftp_server; const char *sftp_server;
size_t i;
int rc; int rc;
snprintf(sshd_path, snprintf(sshd_path,
@@ -904,16 +912,13 @@ static void torture_setup_create_sshd_config(void **state)
assert_non_null(s->socket_dir); assert_non_null(s->socket_dir);
sftp_server = "/usr/lib/ssh/sftp-server"; sftp_server = getenv("TORTURE_SFTP_SERVER");
rc = lstat(sftp_server, &sb); if (sftp_server == NULL) {
if (rc < 0) { for (i = 0; i < sftp_sl_size; i++) {
sftp_server = "/usr/libexec/sftp-server"; sftp_server = sftp_server_locations[i];
rc = lstat(sftp_server, &sb);
if (rc < 0) {
sftp_server = "/usr/libexec/openssh/sftp-server";
rc = lstat(sftp_server, &sb); rc = lstat(sftp_server, &sb);
if (rc < 0) { if (rc == 0) {
sftp_server = getenv("TORTURE_SFTP_SERVER"); break;
} }
} }
} }