mirror of https://github.com/wolfSSL/wolfssh.git
tests: Stop TestKnownHostsLastEntry depending on WMKDIR
A local run with ./configure --enable-smallstack (no --enable-sftp) showed WMKDIR as an implicit, undeclared function under MinGW. wolfssh/port.h only defines WMKDIR when WOLFSSH_SFTP, WOLFSSH_SCP, or WOLFSSH_SSHD is enabled, but TestKnownHostsLastEntry itself is gated on WOLFSSL_BASE64_ENCODE alone, so it compiles in configurations where none of those three are on and WMKDIR does not exist. Add a small TEST_MKDIR macro next to the existing TEST_SETENV and TEST_UNSETENV ones, backed directly by _mkdir() under USE_WINDOWS_API and mkdir() otherwise, and use it in place of WMKDIR. The Windows branch needs direct.h for _mkdir's declaration; include it next to the existing _WIN32 guard around arpa/inet.h at the top of the file. Verified with the MinGW cross compiler both with WOLFSSH_SFTP defined and without, and confirmed a plain Linux build configured with --enable-smallstack (no --enable-sftp) still passes tests/regress.test and tests/unit.test.pull/1247/head
parent
53683a758c
commit
82032bddfe
|
|
@ -34,6 +34,8 @@
|
|||
#include <stdlib.h>
|
||||
#ifndef _WIN32
|
||||
#include <arpa/inet.h>
|
||||
#else
|
||||
#include <direct.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
|
@ -13366,13 +13368,18 @@ static int KnownHostsCheckCapture(const byte* pubKey, word32 pubKeySz,
|
|||
|
||||
/* setenv()/unsetenv() are POSIX and have no MSVCRT equivalent; _putenv_s()
|
||||
* matches their (name, value) shape and success/failure return closely
|
||||
* enough for this test's own HOME juggling. */
|
||||
* enough for this test's own HOME juggling. WMKDIR is not an option here:
|
||||
* it is only defined when wolfssh/port.h is built with SFTP, SCP, or sshd
|
||||
* support, and this test compiles whenever WOLFSSL_BASE64_ENCODE is set,
|
||||
* independent of those. */
|
||||
#ifdef USE_WINDOWS_API
|
||||
#define TEST_SETENV(n,v) _putenv_s((n), (v))
|
||||
#define TEST_UNSETENV(n) _putenv_s((n), "")
|
||||
#define TEST_MKDIR(p,m) _mkdir((p))
|
||||
#else
|
||||
#define TEST_SETENV(n,v) setenv((n), (v), 1)
|
||||
#define TEST_UNSETENV(n) unsetenv((n))
|
||||
#define TEST_MKDIR(p,m) mkdir((p), (m))
|
||||
#endif
|
||||
|
||||
/* known_hosts is a text file and POSIX lets its last line end without a
|
||||
|
|
@ -13439,8 +13446,8 @@ static void TestKnownHostsLastEntry(void)
|
|||
(void)rmdir(homeDir);
|
||||
|
||||
/* Use a single flag to avoid duplicate errors below. */
|
||||
ready = (WMKDIR(NULL, homeDir, 0700) == 0)
|
||||
&& (WMKDIR(NULL, sshDir, 0700) == 0)
|
||||
ready = (TEST_MKDIR(homeDir, 0700) == 0)
|
||||
&& (TEST_MKDIR(sshDir, 0700) == 0)
|
||||
&& (TEST_SETENV("HOME", homeDir) == 0);
|
||||
AssertTrue(ready);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue