-
Notifications
You must be signed in to change notification settings - Fork 162
Migrate to callback-based authentication for libssh 0.12 #622
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
Open
HanzlikPetr
wants to merge
1
commit into
CESNET:devel
Choose a base branch
from
HanzlikPetr:pr_libssh_deprecated_functions
base: devel
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,6 +42,7 @@ | |
| #include "session_p.h" | ||
| #include "session_server.h" | ||
| #include "session_server_ch.h" | ||
| #include "session_server_ssh_wrapper.h" | ||
|
HanzlikPetr marked this conversation as resolved.
|
||
|
|
||
| #ifdef NC_ENABLED_SSH_TLS | ||
|
|
||
|
|
@@ -2294,6 +2295,34 @@ nc_server_send_reply_io(struct nc_session *session, int io_timeout, const struct | |
| return ret; | ||
| } | ||
|
|
||
| #ifdef NC_ENABLED_SSH_TLS | ||
| /** | ||
| * @brief Scan the session ring for a newly established NETCONF SSH channel. | ||
| * | ||
| * @param[in] session Session whose SSH channel ring to scan. | ||
| * @return Pointer to the new starting NETCONF session if found, NULL otherwise. | ||
| */ | ||
| static struct nc_session * | ||
| nc_ps_ssh_find_new_channel(struct nc_session *session) | ||
|
Comment on lines
+2305
to
+2306
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider returning |
||
| { | ||
| struct nc_session *new; | ||
|
|
||
| if (!session->ti.libssh.next) { | ||
| return NULL; | ||
| } | ||
|
|
||
| for (new = session->ti.libssh.next; new != session; new = new->ti.libssh.next) { | ||
| if ((new->status == NC_STATUS_STARTING) && new->ti.libssh.channel && | ||
| (new->flags & NC_SESSION_SSH_SUBSYS_NETCONF)) { | ||
| return new; | ||
| } | ||
| } | ||
|
|
||
| return NULL; | ||
| } | ||
|
|
||
| #endif /* NC_ENABLED_SSH_TLS */ | ||
|
|
||
| /** | ||
| * @brief Poll a session from pspoll acquiring IO lock as needed. | ||
| * Session must be running and session RPC lock held! | ||
|
|
@@ -2317,8 +2346,9 @@ nc_ps_poll_session_io(struct nc_session *session, int io_timeout, time_t now_mon | |
| uint16_t idle_timeout; | ||
|
|
||
| #ifdef NC_ENABLED_SSH_TLS | ||
| #if !LIBSSH_0_12 | ||
| ssh_message ssh_msg; | ||
| struct nc_session *new; | ||
| #endif | ||
| #endif /* NC_ENABLED_SSH_TLS */ | ||
|
|
||
| /* check timeout first */ | ||
|
|
@@ -2341,36 +2371,33 @@ nc_ps_poll_session_io(struct nc_session *session, int io_timeout, time_t now_mon | |
| switch (session->ti_type) { | ||
| #ifdef NC_ENABLED_SSH_TLS | ||
| case NC_TI_SSH: | ||
| #if LIBSSH_0_12 | ||
| if (nc_ps_ssh_find_new_channel(session)) { | ||
| ret = NC_PSPOLL_SSH_CHANNEL; | ||
| break; | ||
| } | ||
| #else | ||
| ssh_msg = ssh_message_get(session->ti.libssh.session); | ||
| if (ssh_msg) { | ||
| if (nc_session_ssh_msg(session, NULL, ssh_msg, NULL)) { | ||
| ssh_message_reply_default(ssh_msg); | ||
| } | ||
| if (session->ti.libssh.next) { | ||
| for (new = session->ti.libssh.next; new != session; new = new->ti.libssh.next) { | ||
| if ((new->status == NC_STATUS_STARTING) && new->ti.libssh.channel && | ||
| (new->flags & NC_SESSION_SSH_SUBSYS_NETCONF)) { | ||
| /* new NETCONF SSH channel */ | ||
| ret = NC_PSPOLL_SSH_CHANNEL; | ||
| break; | ||
| } | ||
| } | ||
| if (new != session) { | ||
| ssh_message_free(ssh_msg); | ||
| break; | ||
| } | ||
| if (nc_ps_ssh_find_new_channel(session)) { | ||
| ret = NC_PSPOLL_SSH_CHANNEL; | ||
| ssh_message_free(ssh_msg); | ||
| break; | ||
| } | ||
| if (!ret) { | ||
| /* just some SSH message */ | ||
| ret = NC_PSPOLL_SSH_MSG; | ||
| } | ||
| ssh_message_free(ssh_msg); | ||
|
|
||
| /* break because 1) we don't want to return anything here ORred with NC_PSPOLL_RPC | ||
| * and 2) we don't want to delay openning a new channel by waiting for a RPC to get processed | ||
| * and 2) we don't want to delay opening a new channel by waiting for a RPC to get processed | ||
| */ | ||
| break; | ||
| } | ||
| #endif | ||
|
|
||
| r = ssh_channel_poll_timeout(session->ti.libssh.channel, 0, 0); | ||
| if (r == SSH_EOF) { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.