Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/external/source/libssh/ssh_server_fork.patch
Views: 11766
diff --git a/examples/ssh_server_fork.c b/examples/ssh_server_fork.c1index 217c5298..20008c76 1006442--- a/examples/ssh_server_fork.c3+++ b/examples/ssh_server_fork.c4@@ -235,8 +235,6 @@ struct channel_data_struct {5struct session_data_struct {6/* Pointer to the channel the session will allocate. */7ssh_channel channel;8- int auth_attempts;9- int authenticated;10};1112static int data_function(ssh_session session, ssh_channel channel, void *data,13@@ -406,8 +404,8 @@ static int shell_request(ssh_session session, ssh_channel channel,14if (cdata->pty_master != -1 && cdata->pty_slave != -1) {15return exec_pty("-l", NULL, cdata);16}17- /* Client requested a shell without a pty, let's pretend we allow that */18- return SSH_OK;19+20+ return exec_nopty("/bin/sh -l", cdata);21}2223static int subsystem_request(ssh_session session, ssh_channel channel,24@@ -421,16 +419,13 @@ static int subsystem_request(ssh_session session, ssh_channel channel,2526static int auth_password(ssh_session session, const char *user,27const char *pass, void *userdata) {28- struct session_data_struct *sdata = (struct session_data_struct *) userdata;29-30(void) session;31+ (void) userdata;3233if (strcmp(user, USER) == 0 && strcmp(pass, PASS) == 0) {34- sdata->authenticated = 1;35return SSH_AUTH_SUCCESS;36}3738- sdata->auth_attempts++;39return SSH_AUTH_DENIED;40}4142@@ -496,9 +491,7 @@ static void handle_session(ssh_event event, ssh_session session) {4344/* Our struct holding information about the session. */45struct session_data_struct sdata = {46- .channel = NULL,47- .auth_attempts = 0,48- .authenticated = 049+ .channel = NULL50};5152struct ssh_channel_callbacks_struct channel_cb = {53@@ -530,19 +523,11 @@ static void handle_session(ssh_event event, ssh_session session) {54ssh_set_auth_methods(session, SSH_AUTH_METHOD_PASSWORD);55ssh_event_add_session(event, session);5657- n = 0;58- while (sdata.authenticated == 0 || sdata.channel == NULL) {59- /* If the user has used up all attempts, or if he hasn't been able to60- * authenticate in 10 seconds (n * 100ms), disconnect. */61- if (sdata.auth_attempts >= 3 || n >= 100) {62- return;63- }64-65+ while (sdata.channel == NULL) {66if (ssh_event_dopoll(event, 100) == SSH_ERROR) {67fprintf(stderr, "%s\n", ssh_get_error(session));68return;69}70- n++;71}7273ssh_set_channel_callbacks(sdata.channel, &channel_cb);747576