[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] examples: Fix disconnect after auth in ssh_server_fork


It is very likely that auth packets and channel request packets get handled by separate poll calls, causing to disconnect the client if he has authenticated
on the 3rd attempt, but has not yet had a channel allocated.

Signed-off-by: Audrius Butkevicius <audrius.butkevicius@xxxxxxxxx>
---
 examples/ssh_server_fork.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/examples/ssh_server_fork.c b/examples/ssh_server_fork.c
index 837db6f..70adaf8 100644
--- a/examples/ssh_server_fork.c
+++ b/examples/ssh_server_fork.c
@@ -534,7 +534,7 @@ static void handle_session(ssh_event event, ssh_session session) {
     while (sdata.authenticated == 0 || sdata.channel == NULL) {
/* If the user has used up all attempts, or if he hasn't been able to
          * authenticate in 10 seconds (n * 100ms), disconnect. */
-        if (sdata.auth_attempts >= 3 || n >= 100) {
+ if ((sdata.authenticated == 0 && sdata.auth_attempts >= 3) || n > 100) {
             return;
         }

--
1.7.2.5







Follow-Ups:
Re: [PATCH] examples: Fix disconnect after auth in ssh_server_forkAris Adamantiadis <aris@xxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org