Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wolfSSHd Connection Closure #718

Merged
merged 1 commit into from
Jul 16, 2024
Merged

Conversation

ejohnstown
Copy link
Contributor

DESCRIPTION

Improvements to wolfSSHd to shutdown the connection cleaner, without disconnection errors. The server will keep processing the channel data and close its side of the connection. On socket shutdown, it will shutdown its side of the socket and read data from the socket until 0 return, then it closes the socket. Will also interrupt the child process if there are any socket errors.
(ZD 17722)

Copy link
Contributor

@douzzer douzzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good. a stray XSTRLEN() and a couple XSNPRINTF()s to fix.

WMEMSET(cmd, 0, sizeof(cmd));
if (XSTRLEN(pPasswd->pw_shell) == 0) {
XSNPRINTF(cmd, sizeof(cmd), "%s", "/bin/sh");
if (pPasswd->pw_shell && XSTRLEN(pPasswd->pw_shell)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be WSTRLEN().

if (XSTRLEN(pPasswd->pw_shell) == 0) {
XSNPRINTF(cmd, sizeof(cmd), "%s", "/bin/sh");
if (pPasswd->pw_shell && XSTRLEN(pPasswd->pw_shell)) {
XSNPRINTF(cmd, sizeof(cmd), "%s", pPasswd->pw_shell);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be WSNPRINTF().

apps/wolfsshd/wolfsshd.c Outdated Show resolved Hide resolved
@ejohnstown ejohnstown requested a review from douzzer July 16, 2024 01:23
apps/wolfsshd/wolfsshd.c Show resolved Hide resolved
1. Initialize all the fds to -1.
2. Add flags for peerConnected and stdoutEmpty.
3. Remove the idle counter.
4. When the socket would block on write, set a flag to check the socket for
   writing later to call the worker which will send pending data.
5. When reading the pipes, a 0 returns means the pipe is closed. Deal
   with that.
6. If the ssh write fails, interrupt the subordinate process.
7. When waiting for the peer to close its channel and shutdown, sleep
   for 100ms, rather than 1us. It takes a little while to tear down.
8. Shutdown the peer socket. Spin on receiving the peer socket until it
   closes or has an error.
9. Fixed a few function wrappers; was using Xname instead of Wname.
@ejohnstown ejohnstown requested a review from douzzer July 16, 2024 17:51
@douzzer douzzer merged commit e3bed88 into wolfSSL:master Jul 16, 2024
36 checks passed
@ejohnstown ejohnstown deleted the wolfsshd-closure branch July 16, 2024 20:43
jefferyq2 pushed a commit to jefferyq2/wolfssh that referenced this pull request Sep 24, 2024
jefferyq2 pushed a commit to jefferyq2/wolfssh that referenced this pull request Oct 18, 2024
jefferyq2 pushed a commit to jefferyq2/wolfssh that referenced this pull request Oct 29, 2024
jefferyq2 pushed a commit to jefferyq2/wolfssh that referenced this pull request Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants