diff options
author | ilsimo <ilsimo> | 2007-03-17 16:41:21 +0000 |
---|---|---|
committer | ilsimo <ilsimo> | 2007-03-17 16:41:21 +0000 |
commit | ae9faad218563b46c0a4a00fc584454dbd566825 (patch) | |
tree | 20228960dc402577785c5949399eef336ae7fc14 /sesman/scp_v1.c | |
parent | 5260d224dc61868b72a47a5cf3138d22fca30eed (diff) | |
download | xrdp-proprietary-ae9faad218563b46c0a4a00fc584454dbd566825.tar.gz xrdp-proprietary-ae9faad218563b46c0a4a00fc584454dbd566825.zip |
more work on scp v1
Diffstat (limited to 'sesman/scp_v1.c')
-rw-r--r-- | sesman/scp_v1.c | 137 |
1 files changed, 77 insertions, 60 deletions
diff --git a/sesman/scp_v1.c b/sesman/scp_v1.c index d2018da5..ed6dcde4 100644 --- a/sesman/scp_v1.c +++ b/sesman/scp_v1.c @@ -22,7 +22,7 @@ * @file scp_v1.c * @brief scp version 1 implementation * @author Jay Sorg, Simone Fedele - * + * */ #include "sesman.h" @@ -32,6 +32,8 @@ extern struct config_sesman g_cfg; +static void parseCommonStates(enum SCP_SERVER_STATES_E e, char* f); + /******************************************************************************/ void DEFAULT_CC scp_v1_process(struct SCP_CONNECTION* c, struct SCP_SESSION* s) @@ -50,50 +52,31 @@ scp_v1_process(struct SCP_CONNECTION* c, struct SCP_SESSION* s) current_try = retries; data = auth_userpass(s->username, s->password); - LOG_DBG("user: %s\npass: %s", s->username, s->password); + /*LOG_DBG("user: %s\npass: %s", s->username, s->password);*/ while ((!data) && ((retries == 0) || (current_try > 0))) { - LOG_DBG("data %d - retry %d - currenttry %d - expr %d", data, retries, - current_try, ((!data) && ((retries == 0) || (current_try > 0)))); + LOG_DBG("data %d - retry %d - currenttry %d - expr %d", data, retries, current_try, ((!data) && ((retries==0) || (current_try>0)))); - e = scp_v1s_request_password(c, s, "Wrong username and/or password"); + e=scp_v1s_request_password(c,s,"Wrong username and/or password"); switch (e) { case SCP_SERVER_STATE_OK: /* all ok, we got new username and password */ data = auth_userpass(s->username, s->password); - /* one try less */ + /* one try less */ if (current_try > 0) { current_try--; } break; - case SCP_SERVER_STATE_VERSION_ERR: - LOG_DBG("version error", 0) - case SCP_SERVER_STATE_SIZE_ERR: - /* an unknown scp version was requested, so we shut down the */ - /* connection (and log the fact) */ - log_message(LOG_LEVEL_WARNING, - "protocol violation. connection closed."); - return; - case SCP_SERVER_STATE_NETWORK_ERR: - log_message(LOG_LEVEL_WARNING, "libscp network error."); - return; - case SCP_SERVER_STATE_SEQUENCE_ERR: - log_message(LOG_LEVEL_WARNING, "libscp sequence error."); - return; - case SCP_SERVER_STATE_INTERNAL_ERR: - /* internal error occurred (eg. malloc() error, ecc.) */ - log_message(LOG_LEVEL_ERROR, "libscp internal error occurred."); - return; default: - /* dummy: scp_v1s_request_password won't generate any other */ - /* error other than the ones before */ - log_message(LOG_LEVEL_ALWAYS, - "unknown return from scp_v1s_request_password()"); + /* we check the other errors */ + parseCommonStates(e, "scp_v1s_list_sessions()"); + free_session(s); return; + //break; } } @@ -106,7 +89,7 @@ scp_v1_process(struct SCP_CONNECTION* c, struct SCP_SESSION* s) return; } - /* testing if login is allowed*/ + /* testing if login is allowed*/ if (0 == access_login_allowed(s->username)) { scp_v1s_deny_connection(c, "Access to Terminal Server not allowed."); @@ -123,7 +106,6 @@ scp_v1_process(struct SCP_CONNECTION* c, struct SCP_SESSION* s) if (scount == 0) { -#warning FIXME we should check for MaxSessions /* no disconnected sessions - start a new one */ log_message(LOG_LEVEL_INFO, "granted TS access to user %s", s->username); if (SCP_SESSION_TYPE_XVNC == s->type) @@ -145,42 +127,48 @@ scp_v1_process(struct SCP_CONNECTION* c, struct SCP_SESSION* s) case SCP_SERVER_STATE_OK: /* all ok, we got new username and password */ break; - case SCP_SERVER_STATE_NETWORK_ERR: - log_message(LOG_LEVEL_WARNING, "libscp network error."); - return; default: - return; + /* we check the other errors */ + parseCommonStates(e, "scp_v1s_connect_new_session()"); + break; } } - else if (scount == 1) + else { - /* there's only one session - returning that */ - sitem = session_get_bypid(slist->SID); #warning FIXME session_get_by*() should return a malloc()ated struct #warning FIXME or at least lock the chain - if (0 == sitem) - { - e = scp_v1s_connection_error(c, "Internal error"); - log_message(LOG_LEVEL_INFO, "Cannot find session item on the chain"); - } - else - { - display = sitem->display; - e = scp_v1s_reconnect_session(c, slist, display); - log_message(LOG_LEVEL_INFO, - "User %s reconnected to session %d on port %d", - s->username, sitem->pid, display); - } - g_free(slist); - } - else - { - /* 2 or more disconnected sessions - listing */ - //max session x packet = 100 => pkt size = 1300 (13x100) + /* one or more disconnected sessions - listing */ e = scp_v1s_list_sessions(c, scount, slist, &sid); - //CHECK RETURN - + switch (e) + { + /*case SCP_SERVER_STATE_FORCE_NEW:*/ + /* we should check for MaxSessions */ + case SCP_SERVER_STATE_SELECTION_CANCEL: + log_message(LOG_LEVEL_INFO, "Connection cancelled after session listing"); + break; + case SCP_SERVER_STATE_OK: + /* ok, reconnecting... */ + sitem=session_get_bypid(sid); + if (0==sitem) + { + e=scp_v1s_connection_error(c, "Internal error"); + log_message(LOG_LEVEL_INFO, "Cannot find session item on the chain"); + } + else + { + display=sitem->display; + /*e=scp_v1s_reconnect_session(c, sitem, display);*/ + e=scp_v1s_reconnect_session(c, display); + log_message(LOG_LEVEL_INFO, "User %s reconnected to session %d on port %d", \ + s->username, sitem->pid, display); + } + break; + default: + /* we check the other errors */ + parseCommonStates(e, "scp_v1s_list_sessions()"); + break; + } g_free(slist); } @@ -190,8 +178,37 @@ scp_v1_process(struct SCP_CONNECTION* c, struct SCP_SESSION* s) /* here goes scp resource sharing code */ } - /* cleanup */ + /* cleanup */ free_session(s); - auth_end(data); + auth_end(data); } +static void parseCommonStates(enum SCP_SERVER_STATES_E e, char* f) +{ + switch (e) + { + case SCP_SERVER_STATE_VERSION_ERR: + LOG_DBG("version error", 0) + case SCP_SERVER_STATE_SIZE_ERR: + /* an unknown scp version was requested, so we shut down the */ + /* connection (and log the fact) */ + log_message(LOG_LEVEL_WARNING, + "protocol violation. connection closed."); + break; + case SCP_SERVER_STATE_NETWORK_ERR: + log_message(LOG_LEVEL_WARNING, "libscp network error."); + break; + case SCP_SERVER_STATE_SEQUENCE_ERR: + log_message(LOG_LEVEL_WARNING, "libscp sequence error."); + break; + case SCP_SERVER_STATE_INTERNAL_ERR: + /* internal error occurred (eg. malloc() error, ecc.) */ + log_message(LOG_LEVEL_ERROR, "libscp internal error occurred."); + break; + default: + /* dummy: scp_v1s_request_password won't generate any other */ + /* error other than the ones before */ + log_message(LOG_LEVEL_ALWAYS, "unknown return from %s", f); + break; + } +} |