mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-08-05 20:55:46 +03:00
tests/pkd: Fix OpenSSH version check
When running in FIPS mode, the OpenSSH version is not the first string printed by "ssh -V". This makes the parser to find the first occurrence of the version ignoring anything printed before it. Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
committed by
Andreas Schneider
parent
905b027f0f
commit
5568e5e520
@@ -43,7 +43,8 @@ static int bin_exists(const char *binary) {
|
|||||||
static int is_openssh_client_new_enough(void) {
|
static int is_openssh_client_new_enough(void) {
|
||||||
int rc = -1;
|
int rc = -1;
|
||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
char version[1024] = { 0 };
|
char version_buff[1024] = { 0 };
|
||||||
|
char *version;
|
||||||
|
|
||||||
static int version_ok = 0;
|
static int version_ok = 0;
|
||||||
unsigned long int major = 0;
|
unsigned long int major = 0;
|
||||||
@@ -59,10 +60,13 @@ static int is_openssh_client_new_enough(void) {
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fgets(&version[0], sizeof(version), fp) == NULL) {
|
do {
|
||||||
fprintf(stderr, "failed to get OpenSSH client version string\n");
|
if (fgets(&version_buff[0], sizeof(version_buff), fp) == NULL) {
|
||||||
goto errfgets;
|
fprintf(stderr, "failed to get OpenSSH client version string\n");
|
||||||
}
|
goto errfgets;
|
||||||
|
}
|
||||||
|
version = strstr(version_buff, "OpenSSH");
|
||||||
|
} while(version == NULL);
|
||||||
|
|
||||||
/* "OpenSSH_<major>.<minor><SP>..." */
|
/* "OpenSSH_<major>.<minor><SP>..." */
|
||||||
if (strlen(version) < 11) {
|
if (strlen(version) < 11) {
|
||||||
|
Reference in New Issue
Block a user