Skip to content

ssh: Add support for userauth banner. - #610

Closed
snimmagadda wants to merge 10 commits into
libssh2:masterfrom
snimmagadda:userauth-banner2
Closed

snimmagadda wants to merge 10 commits into
libssh2:masterfrom
snimmagadda:userauth-banner2

Conversation

@snimmagadda

Copy link
Copy Markdown
Contributor

This PR tries to revive #444 by @palmin which was based on #274 by @dmiller-nmap and @bonsaiviking from late 2018.

Instead of a do..while(1) loop, this PR calls _libssh2_packet_requirev() again after handling SSH_MSG_USERAUTH_BANNER similar to what's being done in _libssh2_userauth_publickey(). Additionally, userauth_banner is freed in session_free().

The new libssh2_userauth_banner API allows to get an optional
userauth banner sent with SSH_MSG_USERAUTH_BANNER packet by the
server.
@snimmagadda

Copy link
Copy Markdown
Contributor Author

Close and reopen PR to trigger a ci/appveyor rebuild. Last run hit a maximum limit and logs show "Waiting for SSH connection from GitHub Actions...".

@snimmagadda snimmagadda closed this Jun 8, 2021
@snimmagadda snimmagadda reopened this Jun 8, 2021

@willco007 willco007 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

userauth_banner can be junk memory when calling libssh2_userauth_banner() if it hasn't been allocated or banner_len is an unexpected value. It should probably be set to NULL on initialization.

@snimmagadda

Copy link
Copy Markdown
Contributor Author

@willco007 I believe this memset during session initialization sets userauth_banner to NULL. I have added a guard to check against a NULL session when calling libssh2_userauth_banner() though.

Comment thread src/userauth.c Resolved
@DevAGCO

DevAGCO commented Oct 15, 2021

Copy link
Copy Markdown

Looking forward for this functionality to be back in the next release !

@willco007

Copy link
Copy Markdown
Member

Anyone using this PR that can comment on it before we land it?

@snimmagadda

Copy link
Copy Markdown
Contributor Author

I had a small diff in my tree that I forgot to push until I received this comment. Sorry for the delay, it's safer to explicitly NUL terminate before using the banner as a string.

Comment thread src/userauth.c Resolved
Comment thread docs/libssh2_userauth_banner.3 Resolved
Suggested by Daniel Stenberg (bagder).
@bagder bagder closed this in d5ed0e6 Jan 13, 2022
@bagder

bagder commented Jan 13, 2022

Copy link
Copy Markdown
Member

Thanks!

willco007 pushed a commit to willco007/libssh2 that referenced this pull request Jan 13, 2022
The new libssh2_userauth_banner API allows to get an optional
userauth banner sent with SSH_MSG_USERAUTH_BANNER packet by the
server.

Closes libssh2#610
@snimmagadda
snimmagadda deleted the userauth-banner2 branch January 18, 2022 10:11
@DevAGCO

DevAGCO commented Jun 7, 2023

Copy link
Copy Markdown

Any plan on when this will be merged to master?

@willco007

Copy link
Copy Markdown
Member

It's in. d5ed0e6

@DevAGCO

DevAGCO commented Jun 8, 2023 via email

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants