aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--protocols/msn/msn.c10
-rw-r--r--protocols/msn/msn.h3
-rw-r--r--protocols/msn/ns.c5
-rw-r--r--protocols/msn/soap.c67
-rw-r--r--protocols/msn/soap.h2
5 files changed, 51 insertions, 36 deletions
diff --git a/protocols/msn/msn.c b/protocols/msn/msn.c
index 1467f033..65bdd9a6 100644
--- a/protocols/msn/msn.c
+++ b/protocols/msn/msn.c
@@ -63,7 +63,7 @@ static void msn_login( account_t *acc )
md->ic = ic;
md->away_state = msn_away_state_list;
md->domaintree = g_tree_new( msn_domaintree_cmp );
- md->ns->fd = md->auth->fd = -1;
+ md->ns->fd = -1;
msn_connections = g_slist_prepend( msn_connections, ic );
@@ -86,7 +86,6 @@ static void msn_logout( struct im_connection *ic )
*/
msn_ns_close( md->ns );
- msn_ns_close( md->auth );
while( md->switchboards )
msn_sb_destroy( md->switchboards->data );
@@ -96,6 +95,7 @@ static void msn_logout( struct im_connection *ic )
for( i = 0; i < sizeof( md->tokens ) / sizeof( md->tokens[0] ); i ++ )
g_free( md->tokens[i] );
g_free( md->lock_key );
+ g_free( md->pp_policy );
while( md->groups )
{
@@ -180,8 +180,6 @@ static void msn_set_away( struct im_connection *ic, char *state, char *message )
char *uux;
struct msn_data *md = ic->proto_data;
- strcpy( md->tokens[1], md->tokens[2] );
-
if( state == NULL )
md->away_state = msn_away_state_list;
else if( ( md->away_state = msn_away_state_by_name( state ) ) == NULL )
@@ -283,7 +281,7 @@ static void msn_add_permit( struct im_connection *ic, char *who )
static void msn_rem_permit( struct im_connection *ic, char *who )
{
- //msn_buddy_list_remove( ic, MSN_BUDDY_AL, who, NULL );
+ msn_buddy_list_remove( ic, MSN_BUDDY_AL, who, NULL );
}
static void msn_add_deny( struct im_connection *ic, char *who )
@@ -301,7 +299,7 @@ static void msn_add_deny( struct im_connection *ic, char *who )
static void msn_rem_deny( struct im_connection *ic, char *who )
{
- //msn_buddy_list_remove( ic, MSN_BUDDY_BL, who, NULL );
+ msn_buddy_list_remove( ic, MSN_BUDDY_BL, who, NULL );
}
static int msn_send_typing( struct im_connection *ic, char *who, int typing )
diff --git a/protocols/msn/msn.h b/protocols/msn/msn.h
index 3def01a4..829bbd4c 100644
--- a/protocols/msn/msn.h
+++ b/protocols/msn/msn.h
@@ -80,6 +80,7 @@ typedef enum
MSN_GOT_PROFILE = 1,
MSN_GOT_PROFILE_DN = 2,
MSN_DONE_ADL = 4,
+ MSN_REAUTHING = 8,
} msn_flags_t;
struct msn_handler_data
@@ -102,7 +103,7 @@ struct msn_data
{
struct im_connection *ic;
- struct msn_handler_data ns[1], auth[1];
+ struct msn_handler_data ns[1];
msn_flags_t flags;
int trId;
diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c
index 401461b2..d64a71ac 100644
--- a/protocols/msn/ns.c
+++ b/protocols/msn/ns.c
@@ -274,11 +274,6 @@ static int msn_ns_command( struct msn_handler_data *handler, char **cmd, int num
g_free( md->pp_policy );
md->pp_policy = g_strdup( cmd[4] );
msn_soap_passport_sso_request( ic, cmd[5] );
- if( handler == md->auth )
- {
- msn_ns_close( md->auth );
- return 0;
- }
}
else if( strcmp( cmd[2], "OK" ) == 0 )
{
diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c
index 592dbd4f..2c26271b 100644
--- a/protocols/msn/soap.c
+++ b/protocols/msn/soap.c
@@ -47,6 +47,7 @@ typedef enum
{
MSN_SOAP_OK,
MSN_SOAP_RETRY,
+ MSN_SOAP_REAUTH,
MSN_SOAP_ABORT,
} msn_soap_result_t;
@@ -133,6 +134,8 @@ static void msn_soap_handle_response( struct http_request *http_req )
return;
}
+ msn_soap_debug_print( http_req->reply_headers, http_req->reply_body );
+
if( http_req->body_size > 0 )
{
struct xt_parser *parser;
@@ -142,33 +145,45 @@ static void msn_soap_handle_response( struct http_request *http_req )
xt_feed( parser, http_req->reply_body, http_req->body_size );
if( http_req->status_code == 500 &&
( err = xt_find_path( parser->root, "soap:Body/soap:Fault/detail/errorcode" ) ) &&
- err->text_len > 0 && strcmp( err->text, "PassportAuthFail" ) == 0 )
+ err->text_len > 0 )
{
- struct msn_data *md = soap_req->ic->proto_data;
-
- xt_free( parser );
- if( md->auth->fd == -1 )
- msn_ns_connect( soap_req->ic, md->auth, MSN_NS_HOST, MSN_NS_PORT );
- md->soapq = g_slist_prepend( md->soapq, soap_req );
-
- return;
+ if( strcmp( err->text, "PassportAuthFail" ) == 0 )
+ {
+ xt_free( parser );
+ st = MSN_SOAP_REAUTH;
+ goto fail;
+ }
+ /* TODO: Handle/report other errors. */
}
xt_handle( parser, NULL, -1 );
xt_free( parser );
}
- msn_soap_debug_print( http_req->reply_headers, http_req->reply_body );
-
st = soap_req->handle_response( soap_req );
-
+
+fail:
g_free( soap_req->url );
g_free( soap_req->action );
g_free( soap_req->payload );
soap_req->url = soap_req->action = soap_req->payload = NULL;
if( st == MSN_SOAP_RETRY && --soap_req->ttl )
+ {
msn_soap_send_request( soap_req );
+ }
+ else if( st == MSN_SOAP_REAUTH )
+ {
+ struct msn_data *md = soap_req->ic->proto_data;
+
+ if( !( md->flags & MSN_REAUTHING ) )
+ {
+ /* Nonce shouldn't actually be touched for re-auths. */
+ msn_soap_passport_sso_request( soap_req->ic, "blaataap" );
+ md->flags |= MSN_REAUTHING;
+ }
+ md->soapq = g_slist_append( md->soapq, soap_req );
+ }
else
{
soap_req->free_data( soap_req );
@@ -241,7 +256,6 @@ struct msn_soap_passport_sso_data
static int msn_soap_passport_sso_build_request( struct msn_soap_req_data *soap_req )
{
- struct msn_soap_passport_sso_data *sd = soap_req->data;
struct im_connection *ic = soap_req->ic;
struct msn_data *md = ic->proto_data;
@@ -422,7 +436,7 @@ struct msn_soap_oim_send_data
char *to;
char *msg;
int number;
- int need_retry;
+ msn_soap_result_t need_retry;
};
static int msn_soap_oim_build_request( struct msn_soap_req_data *soap_req )
@@ -443,28 +457,36 @@ static int msn_soap_oim_build_request( struct msn_soap_req_data *soap_req )
oim->number, oim->number, oim->msg );
g_free( display_name_b64 );
+ oim->need_retry = MSN_SOAP_OK;
return MSN_SOAP_OK;
}
-static xt_status msn_soap_oim_send_challenge( struct xt_node *node, gpointer data )
+static xt_status msn_soap_oim_reauth( struct xt_node *node, gpointer data )
{
struct msn_soap_req_data *soap_req = data;
struct msn_soap_oim_send_data *oim = soap_req->data;
struct im_connection *ic = soap_req->ic;
struct msn_data *md = ic->proto_data;
+ struct xt_node *c;
- g_free( md->lock_key );
- md->lock_key = msn_p11_challenge( node->text );
-
- oim->need_retry = 1;
+ if( ( c = xt_find_node( node->children, "LockKeyChallenge" ) ) && c->text_len > 0 )
+ {
+ g_free( md->lock_key );
+ md->lock_key = msn_p11_challenge( c->text );
+ oim->need_retry = MSN_SOAP_RETRY;
+ }
+ if( xt_find_node( node->children, "RequiredAuthPolicy" ) )
+ {
+ oim->need_retry = MSN_SOAP_REAUTH;
+ }
return XT_HANDLED;
}
static const struct xt_handler_entry msn_soap_oim_send_parser[] = {
- { "LockKeyChallenge", "detail", msn_soap_oim_send_challenge },
- { NULL, NULL, NULL }
+ { "detail", "soap:Fault", msn_soap_oim_reauth },
+ { NULL, NULL, NULL }
};
static int msn_soap_oim_handle_response( struct msn_soap_req_data *soap_req )
@@ -473,8 +495,7 @@ static int msn_soap_oim_handle_response( struct msn_soap_req_data *soap_req )
if( soap_req->http_req->status_code == 500 && oim->need_retry && soap_req->ttl > 0 )
{
- oim->need_retry = 0;
- return MSN_SOAP_RETRY;
+ return oim->need_retry;
}
else if( soap_req->http_req->status_code == 200 )
{
diff --git a/protocols/msn/soap.h b/protocols/msn/soap.h
index 3a46af46..bd3e0245 100644
--- a/protocols/msn/soap.h
+++ b/protocols/msn/soap.h
@@ -125,7 +125,7 @@
"</wsp:AppliesTo>" \
"<wsse:PolicyReference xmlns=\"http://schemas.xmlsoap.org/ws/2003/06/secext\" URI=\"MBI_SSL\"></wsse:PolicyReference>" \
"</wst:RequestSecurityToken>" \
- "<wst:RequestSecurityToken Id=\"RST3\">" \
+ "<wst:RequestSecurityToken Id=\"RST4\">" \
"<wst:RequestType>http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue</wst:RequestType>" \
"<wsp:AppliesTo>" \
"<wsa:EndpointReference>" \