Keyboard-interactive was unusable in builds with
WOLFSSH_KEYBOARD_INTERACTIVE but no WOLFSSH_TERM, in two ways.
- ClientFreeBuffers declared 'entry' under TERM && KBI but used it
under KBI alone, so KBI-without-TERM failed to compile; widen the
declaration guard to match the use
- ClientUserAuth's keyboard-interactive branch is guarded on
TERM && KBI, so without TERM a keyboard-interactive request fell
past every branch and returned the initial WOLFSSH_USERAUTH_SUCCESS
with no responses populated. There is no terminal to prompt on, so
answer WOLFSSH_USERAUTH_FAILURE instead of claiming success.
- Reply to a port-0 (dynamic) tcpip-forward with the bound port.
- Add WS_FWD_PORT_CHECK (1024) as the status/port boundary in WS_FwdCbError.
- Callback returns a WS_FwdCbError status below it, the port at or above it.
- DoGlobalRequestFwd reports the port and rejects a port-0 setup with none.
- Map a callback rejection to WS_RESOURCE_E so a no-reply request keeps the link.
- Update the echoserver reference callbacks (examples and Espressif) to
recover the OS-chosen port with getsockname() and return it under the new
convention.
- Add regress coverage for the allocated-port and rejection paths.
Issue: F-5573
Co-authored-by: John Safranek <john@wolfssl.com>
1. Remove the check on authType, it is covered already.
2. Add Keyboard Setup to the existing check on authType.
3. Add a branch for User Auth None so it reaches its handler
in the map loop rather than the new error case.
4. Add else case for an error.
Fixes CID: 637345
Cleanup clang-tidy bugprone-signal-handler findings.
- wolfsshd: drop fprintf from interruptCatch; the main accept
loop logs "Closing down wolfSSHD" after seeing quit set.
- sftpclient: annotate wolfSSH_SFTP_Interrupt call in
sig_handler with NOLINT, since the function is only a single
byte store and is safe to call from a signal handler.
- Zero private key and password buffers in both apps/wolfssh
and examples client.
- Also zero keyboard-interactive response buffers in the
example client.
Issue: F-249
Refactor of the echoserver example only; library is unchanged.
1. Collapse FwdStates and AGENT_STATE_* into a single WS_AppState
(INIT/LISTEN/CONNECT/CONNECTED). FWD_STATE_DIRECT becomes an
isDirect flag, cleared after connect.
2. Hoist the fields shared by the forwarding, agent, and shell paths
into a common WS_AppCtx (privateData, listenFd, appFd, channelId,
state, buffer). Shell only uses buffer.
3. Feature-specific remainder stays in WS_AgentCbActionCtx (name) and
WS_FwdCbActionCtx (host/origin name+port, isDirect). Drop the unused
pid field; inline getpid() at the call site.
4. wolfSSH_AGENT_DefaultActions and wolfSSH_FwdDefaultActions now take
a WS_AppCtx* and reach feature-specific state via
appCtx->privateData. echoserver_test() is updated to register the
WS_AppCtx (not the old CbCtx) with wolfSSH_set_agent_cb_ctx and
wolfSSH_SetFwdCbCtx.
5. Reindent ssh_worker()'s #ifdef blocks and add /* WOLFSSH_xxx */
markers.
6. fwd.test.expect: redirect echoserver and portfwd output to log files
and sync on portfwd's -R ready file instead of matching "sampled" in
the pty. Under --enable-debug the WLOG volume fills the pty and
stalls portfwd in select() before channel-open.
macOS uses GCD for threading and semaphores, but they aren't quite like
POSIX semaphores. macOS allows the use of named POSIX semaphores.
1. Convert the semaphores to named POSIX semaphores.
2. Simplify all calls for semaphores into single function calls of the
wrapper API.
3. Update both examples/client/client.c and apps/wolfssh/wolfssh.c.
4. Update both to deregister the WINCH signal.
1. Separate the key type and signature type when handling user
authentication. ssh-rsa is a key type used with rsa-sha2-256 and
rsa-sha2-512 signatures, along with ssh-rsa signatures.
2. Allow rsa-sha2-512 to be used.
3. Fix bug where setting the key algorithm on the client command line
was setting the list to NULL.
4. Fix bug where adding rsa-sha2-512 to the list of canned algorithms
was terminating the list, rather that adding it.
Issue: ZD-21247
1. Add a test script and expect script for testing forwarding.
2. Update portfwd to have a ready file option.
3. Fix echoserver error string, needed NL.
1. Fix a couple unused variable warnings.
2. In wolfSSH_AGENT_DefaultActions(), fix comparison to the result of
snprintf() treating normal result as an error. Reset the return code
for the error state of the socket() command. Better cleanup of agent
startup failures.
When running the build tests, the terminal size gets set to 0x0. When
then tests finish, things like vim start to misbehave until you change
your term window size.
1. Echoserver will not change the terminal size when in echo mode.
2. Do not update the modes when the echo server is not in echo mode.
3. Do not set the terminal update callback context when the echo server
is not in echo mode.
4. Update the guards around the above three items to match the guards for
the modes update function.
Historically, some systems have used <sys/errno.h> in place of <errno.h>, but the C standard,
all the way back to C89/Ansi C, specifies that the correct name is `errno.h` -
and most modern compilers create a sys/errno.h compatibility shim sys/errno.h -
but musl-gcc does not have this compatibility shim,
reasoning that sys/errno.h is non-standard, and fails to compile:
```
$ CC=musl-gcc ./configure --enable-static --disable-shared --enable-scp --enable-sftp --enable-shell --with-wolfssl=wolfssl/install-musl
(...)
$ make
make -j17 all-am
make[1]: Entering directory '/home/hans/projects/wolfssh'
CC examples/client/common.o
CC examples/client/client.o
CC src/libwolfssh_la-ssh.lo
CC src/libwolfssh_la-internal.lo
CC src/libwolfssh_la-log.lo
CC src/libwolfssh_la-port.lo
CC src/libwolfssh_la-io.lo
CC src/libwolfssh_la-wolfscp.lo
CC src/libwolfssh_la-wolfsftp.lo
CC examples/echoserver/echoserver.o
CC src/libwolfssh_la-wolfterm.lo
CC examples/sftpclient/sftpclient.o
CC examples/scpclient/scpclient.o
In file included from examples/echoserver/echoserver.c:91:
/usr/include/x86_64-linux-musl/sys/errno.h:1:2: error: #warning redirecting incorrect #include <sys/errno.h> to <errno.h> [-Werror=cpp]
1 | #warning redirecting incorrect #include <sys/errno.h> to <errno.h>
| ^~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:1452: examples/echoserver/echoserver.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/home/hans/projects/wolfssh'
make: *** [Makefile:1020: all] Error 2
```
so, unless we need to support pre-C89 (35+ year old C) compilers,
we can just replace sys/errno.h with errno.h.
1. Due to not checking the result of fseek(), it is possible to try to
malloc() -1 bytes of storage. Checking the return from fseek() and
erring if negative.
2. Changing the check between the result of fseek() and fread() to match
signedness. Adding some casting, as at that point the fseek() result
is always positive.
Fixes CIDs:
573009 572928 572868
1. When cleaning the path, check that the path pointer is not null
before using it.
2. Move the strlen of path.
3. Remove the second check of path, and just loop over it.
Fixed CID: 572847
1. Modify all the test executable `CPPFLAGS` to only have
`-DNO_MAIN_LOOP` and `AM_CPPFLAGS`. This removes a lot of duplicate
setup of flags for each of the tests.
2. Delete the echoserver's `CFLAGS`. It is just setting the `CFLAGS` for
its compile to `AM_CFLAGS` and `AM_CPPFLAGS` which are included by
default.
3. Add the macro WS_MAYBE_UNUSED that may be the unused attribute.
4. If INLINE isn't set to some form of inline, set it to
WS_MAYBE_UNUSED.
5. Remove redundant ThreadStartNoJoin() macros from the testing header.