Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/wolfSSL/wolfssh into comp…
Browse files Browse the repository at this point in the history
…onent-manager
  • Loading branch information
gojimmypi committed Jan 4, 2024
2 parents 47d793d + f481ed5 commit a376c04
Show file tree
Hide file tree
Showing 17 changed files with 343 additions and 973 deletions.
12 changes: 3 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,6 @@ The sftpclient tool accepts the following command line options:
-G get remote filename as local filename


server
------

This tool is a place holder.


SCP
===

Expand Down Expand Up @@ -357,12 +351,12 @@ define `WOLFSSH_SFTP`:
For full API usage and implementation details, please see the wolfSSH User
Manual.

The SFTP client created is located in the directory examples/sftpclient/ and the
server is ran using the same echoserver as with wolfSSH.
The SFTP client created is located in the directory examples/sftpclient/ and
the example echoserver acts as a SFTP server.

src/wolfssh$ ./examples/sftpclient/wolfsftp

A full list of supported commands can be seen with typeing "help" after a
A full list of supported commands can be seen with typing "help" after a
connection.


Expand Down
18 changes: 8 additions & 10 deletions apps/wolfsshd/test/sshd_term_size_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ COL=`tmux display -p -t test '#{pane_width}'`
ROW=`tmux display -p -t test '#{pane_height}'`

# get the terminals columns and lines
tmux send-keys -t test 'echo col=$COLUMNS row=$LINES'
tmux send-keys -t test 'echo;echo $COLUMNS $LINES;echo'
tmux send-keys -t test 'ENTER'
tmux capture-pane -t test
RESULT=`tmux show-buffer | grep -v echo | grep -v rejecting | grep "col="`
RESULT=$(tmux show-buffer | grep '^[0-9]* [0-9]*$')

echo "$RESULT"
echo ""
echo ""
ROW_FOUND=`echo "$RESULT" | sed -e 's/.*[^0-9]\([0-9]\+\)[^0-9]*$/\1/'`
COL_FOUND=`echo "$RESULT" | sed -r 's/^[^0-9]*([0-9]+).*$/\1/'`
ROW_FOUND=$(echo "$RESULT" | sed -e 's/[0-9]* \([0-9]*\)/\1/')
COL_FOUND=$(echo "$RESULT" | sed -e 's/\([0-9]*\) [0-9]*/\1/')

if [ "$COL" != "$COL_FOUND" ]; then
echo "Col found was $COL_FOUND which does not match expected $COL"
Expand Down Expand Up @@ -67,15 +67,13 @@ tmux new-session -d -x 50 -y 10 -s test "$TEST_CLIENT -t -u $USER -i $PRIVATE_KE
# give the command a second to establish SSH connection
sleep 0.5

echo "New COL=$COL ROW=$ROW"

tmux send-keys -t test 'echo col=$COLUMNS row=$LINES'
tmux send-keys -t test 'echo;echo $COLUMNS $LINES;echo'
tmux send-keys -t test 'ENTER'
tmux capture-pane -t test
RESULT=`tmux show-buffer | grep -v echo | grep -v rejecting | grep "col="`
RESULT=$(tmux show-buffer | grep '^[0-9]* [0-9]*$')

ROW_FOUND=`echo "$RESULT" | sed -e 's/.*[^0-9]\([0-9]\+\)[^0-9]*$/\1/'`
COL_FOUND=`echo "$RESULT" | sed -r 's/^[^0-9]*([0-9]+).*$/\1/'`
ROW_FOUND=$(echo "$RESULT" | sed -e 's/[0-9]* \([0-9]*\)/\1/')
COL_FOUND=$(echo "$RESULT" | sed -e 's/\([0-9]*\) [0-9]*/\1/')

if [ "50" != "$COL_FOUND" ]; then
echo "Col found was $COL_FOUND which does not match expected 50"
Expand Down
34 changes: 28 additions & 6 deletions apps/wolfsshd/wolfsshd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,7 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh,
/* Child process */
const char *args[] = {"-sh", NULL, NULL, NULL};
char cmd[MAX_COMMAND_SZ];
char shell[MAX_COMMAND_SZ];
int ret;

signal(SIGINT, SIG_DFL);
Expand Down Expand Up @@ -1258,6 +1259,25 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh,

setenv("HOME", pPasswd->pw_dir, 1);
setenv("LOGNAME", pPasswd->pw_name, 1);
setenv("SHELL", pPasswd->pw_shell, 1);

if (pPasswd->pw_shell) {
word32 shellSz = (word32)WSTRLEN(pPasswd->pw_shell);

if (shellSz < sizeof(shell)) {
char* cursor;
char* start;

WSTRNCPY(shell, pPasswd->pw_shell, sizeof(shell));
cursor = shell;
do {
start = cursor;
*cursor = '-';
cursor = WSTRCHR(start, '/');
} while (cursor && *cursor != '\0');
args[0] = start;
}
}

rc = chdir(pPasswd->pw_dir);
if (rc != 0) {
Expand Down Expand Up @@ -1323,19 +1343,21 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh,

/* set initial size of terminal based on saved size */
#if defined(HAVE_SYS_IOCTL_H)
wolfSSH_DoModes(ssh->modes, ssh->modesSz, childFd);
{
struct winsize s;
struct winsize s = {0};

s.ws_col = ssh->widthChar;
s.ws_row = ssh->heightRows;
s.ws_xpixel = ssh->widthPixels;
s.ws_ypixel = ssh->heightPixels;

WMEMSET(&s, 0, sizeof s);
s.ws_col = ssh->curX;
s.ws_row = ssh->curY;
s.ws_xpixel = ssh->curXP;
s.ws_ypixel = ssh->curYP;
ioctl(childFd, TIOCSWINSZ, &s);
}
#endif

wolfSSH_SetTerminalResizeCtx(ssh, (void*)&childFd);

while (ChildRunning) {
byte tmp[2];
fd_set readFds;
Expand Down
23 changes: 10 additions & 13 deletions examples/echoserver/echoserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -2159,21 +2159,18 @@ static void ShowUsage(void)
}


static INLINE void SignalTcpReady(func_args* serverArgs, word16 port)
static INLINE void SignalTcpReady(tcp_ready* ready, word16 port)
{
#if defined(_POSIX_THREADS) && defined(NO_MAIN_DRIVER) && \
!defined(__MINGW32__) && !defined(SINGLE_THREADED)
tcp_ready* ready = serverArgs->signal;
if (ready != NULL) {
pthread_mutex_lock(&ready->mutex);
ready->ready = 1;
ready->port = port;
pthread_cond_signal(&ready->cond);
pthread_mutex_unlock(&ready->mutex);
}
pthread_mutex_lock(&ready->mutex);
ready->ready = 1;
ready->port = port;
pthread_cond_signal(&ready->cond);
pthread_mutex_unlock(&ready->mutex);
#else
(void)serverArgs;
(void)port;
WOLFSSH_UNUSED(ready);
WOLFSSH_UNUSED(port);
#endif
}

Expand Down Expand Up @@ -2543,6 +2540,8 @@ THREAD_RETURN WOLFSSH_THREAD echoserver_test(void* args)
#endif
}

SignalTcpReady(serverArgs->signal, port);

do {
WS_SOCKET_T clientFd = WOLFSSH_SOCKET_INVALID;
#ifdef WOLFSSL_NUCLEUS
Expand Down Expand Up @@ -2600,8 +2599,6 @@ THREAD_RETURN WOLFSSH_THREAD echoserver_test(void* args)
}
#endif

SignalTcpReady(serverArgs, port);

#ifdef WOLFSSL_NUCLEUS
clientFd = NU_Accept(listenFd, &clientAddr, 0);
#else
Expand Down
1 change: 0 additions & 1 deletion examples/include.am
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# All paths should be given relative to the root

include examples/client/include.am
include examples/server/include.am
include examples/echoserver/include.am
include examples/portfwd/include.am
include examples/sftpclient/include.am
Expand Down
10 changes: 0 additions & 10 deletions examples/server/include.am

This file was deleted.

Loading

0 comments on commit a376c04

Please sign in to comment.