~ubuntu-branches/ubuntu/hardy/pidgin/hardy

« back to all changes in this revision

Viewing changes to libpurple/protocols/jabber/auth.c

  • Committer: Bazaar Package Importer
  • Author(s): Pedro Fragoso
  • Date: 2007-12-21 02:48:06 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20071221024806-pd44a5k9tiyh12mp
Tags: 1:2.3.1-2ubuntu1
* Sync with Debian, remaining Ubuntu changes; (LP: #177811)
  - Set Maintainer to Ubuntu Core Developers.
  - Add build-deps on liblaunchpad-integration-dev, intltool,
    libnm-glib-dev (for --enable-nm) (Ubuntu #112720).
  - Drop build-deps on libsilc-1.1-2-dev | libsilc-dev (>= 1.1.1) as 
    this library is in universe.
  - Drop the libpurple0 recommends on libpurple-bin.
  - Add a gaim transitionnal package for upgrades.
  - Ship compatibility symlinks via debian/gaim.links.
  - Pass --enable-nm to configure to enable NetworkManager support.
  - Pass --disable-silc to configure to disable silc support even if 
    it's installed in the build environment.
  - Add X-Ubuntu-Gettext-Domain to the desktop file and update the
    translation templates in common-install-impl::.
   - Update debian/prefs.xml to set the notify plugin prefs
    /plugins/gtk/X11/notify/* and set /pidgin/plugins/loaded to load 
    the notify plugin; Ubuntu: #13389.
  - Add LPI integration patch, 02_lpi.
  - Add patch 04_let_crasher_for_apport to stop catching the SIGSEGV signal
    and let apport handle it.
  - Add patch 05_default_to_irc_ubuntu_com to set the default IRC 
    server to irc.ubuntu.com.
  - Add autoconf patch, 70_autoconf.

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
                                        "<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>", -1);
51
51
                        return TRUE;
52
52
                } else if(xmlnode_get_child(starttls, "required")) {
53
 
                        purple_connection_error(js->gc, _("Server requires TLS/SSL for login.  No TLS/SSL support found."));
 
53
                        purple_connection_error_reason (js->gc,
 
54
                                PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT,
 
55
                                _("Server requires TLS/SSL for login.  No TLS/SSL support found."));
54
56
                        return TRUE;
55
57
                }
56
58
        }
113
115
 
114
116
static void disallow_plaintext_auth(PurpleAccount *account)
115
117
{
116
 
        purple_connection_error(account->gc, _("Server requires plaintext authentication over an unencrypted stream"));
 
118
        purple_connection_error_reason (account->gc,
 
119
                PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR,
 
120
                _("Server requires plaintext authentication over an unencrypted stream"));
117
121
}
118
122
 
119
123
#ifdef HAVE_CYRUS_SASL
331
335
                                 * error here.
332
336
                                 */
333
337
                                } else {
334
 
                                        purple_connection_error(js->gc, _("Server does not use any supported authentication method"));
 
338
                                        purple_connection_error_reason (js->gc,
 
339
                                                PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE,
 
340
                                                _("Server does not use any supported authentication method"));
335
341
                                        return;
336
342
                                }
337
343
                                /* not reached */
386
392
                jabber_send(js, auth);
387
393
                xmlnode_free(auth);
388
394
        } else {
389
 
                purple_connection_error(js->gc, "SASL authentication failed\n");
 
395
                purple_connection_error_reason (js->gc,
 
396
                        PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE,
 
397
                        "SASL authentication failed\n");
390
398
        }
391
399
}
392
400
 
459
467
        mechs = xmlnode_get_child(packet, "mechanisms");
460
468
 
461
469
        if(!mechs) {
462
 
                purple_connection_error(js->gc, _("Invalid response from server."));
 
470
                purple_connection_error_reason (js->gc,
 
471
                        PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
 
472
                        _("Invalid response from server."));
463
473
                return;
464
474
        }
465
475
 
519
529
                }
520
530
                finish_plaintext_authentication(js);
521
531
        } else {
522
 
                purple_connection_error(js->gc,
 
532
                purple_connection_error_reason (js->gc,
 
533
                                PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE,
523
534
                                _("Server does not use any supported authentication method"));
524
535
        }
525
536
#endif
532
543
        if(type && !strcmp(type, "result")) {
533
544
                jabber_stream_set_state(js, JABBER_STREAM_CONNECTED);
534
545
        } else {
535
 
                char *msg = jabber_parse_error(js, packet);
 
546
                PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
 
547
                char *msg = jabber_parse_error(js, packet, &reason);
536
548
                xmlnode *error;
537
549
                const char *err_code;
538
550
 
 
551
                /* FIXME: Why is this not in jabber_parse_error? */
539
552
                if((error = xmlnode_get_child(packet, "error")) &&
540
553
                                        (err_code = xmlnode_get_attrib(error, "code")) &&
541
554
                                        !strcmp(err_code, "401")) {
542
 
                        js->gc->wants_to_die = TRUE;
 
555
                        reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED;
543
556
                        /* Clear the pasword if it isn't being saved */
544
557
                        if (!purple_account_get_remember_password(js->gc->account))
545
558
                                purple_account_set_password(js->gc->account, NULL);
546
559
                }
547
560
 
548
 
                purple_connection_error(js->gc, msg);
 
561
                purple_connection_error_reason (js->gc, reason, msg);
549
562
                g_free(msg);
550
563
        }
551
564
}
558
571
        const char *pw = purple_connection_get_password(js->gc);
559
572
 
560
573
        if(!type) {
561
 
                purple_connection_error(js->gc, _("Invalid response from server."));
 
574
                purple_connection_error_reason (js->gc,
 
575
                        PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
 
576
                        _("Invalid response from server."));
562
577
                return;
563
578
        } else if(!strcmp(type, "error")) {
564
 
                char *msg = jabber_parse_error(js, packet);
565
 
                purple_connection_error(js->gc, msg);
 
579
                PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
 
580
                char *msg = jabber_parse_error(js, packet, &reason);
 
581
                purple_connection_error_reason (js->gc, reason, msg);
566
582
                g_free(msg);
567
583
        } else if(!strcmp(type, "result")) {
568
584
                query = xmlnode_get_child(packet, "query");
606
622
                        }
607
623
                        finish_plaintext_authentication(js);
608
624
                } else {
609
 
                        purple_connection_error(js->gc,
610
 
                                        _("Server does not use any supported authentication method"));
 
625
                        purple_connection_error_reason (js->gc,
 
626
                                PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE,
 
627
                                _("Server does not use any supported authentication method"));
611
628
                        return;
612
629
                }
613
630
        }
773
790
                GHashTable *parts;
774
791
 
775
792
                if(!enc_in) {
776
 
                        purple_connection_error(js->gc, _("Invalid response from server."));
 
793
                        purple_connection_error_reason (js->gc,
 
794
                                PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
 
795
                                _("Invalid response from server."));
777
796
                        return;
778
797
                }
779
798
 
794
813
                                                "<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl' />",
795
814
                                                -1);
796
815
                        } else {
797
 
                                purple_connection_error(js->gc, _("Invalid challenge from server"));
 
816
                                purple_connection_error_reason (js->gc,
 
817
                                        PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
 
818
                                        _("Invalid challenge from server"));
798
819
                        }
799
820
                        g_free(js->expected_rspauth);
800
821
                } else {
817
838
                                realm = js->user->domain;
818
839
 
819
840
                        if (nonce == NULL || realm == NULL)
820
 
                                purple_connection_error(js->gc, _("Invalid challenge from server"));
 
841
                                purple_connection_error_reason (js->gc,
 
842
                                        PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
 
843
                                        _("Invalid challenge from server"));
821
844
                        else {
822
845
                                GString *response = g_string_new("");
823
846
                                char *a2;
889
912
                g_free(dec_in);
890
913
                if (js->sasl_state != SASL_CONTINUE && js->sasl_state != SASL_OK) {
891
914
                        purple_debug_error("jabber", "Error is %d : %s\n",js->sasl_state,sasl_errdetail(js->sasl));
892
 
                        purple_connection_error(js->gc, _("SASL error"));
 
915
                        purple_connection_error_reason (js->gc,
 
916
                                PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
 
917
                                _("SASL error"));
893
918
                        return;
894
919
                } else {
895
920
                        response = xmlnode_new("response");
914
939
#endif
915
940
 
916
941
        if(!ns || strcmp(ns, "urn:ietf:params:xml:ns:xmpp-sasl")) {
917
 
                purple_connection_error(js->gc, _("Invalid response from server."));
 
942
                purple_connection_error_reason (js->gc,
 
943
                        PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
 
944
                        _("Invalid response from server."));
918
945
                return;
919
946
        }
920
947
 
939
966
 
940
967
                if (js->sasl_state != SASL_OK) {
941
968
                        /* This should never happen! */
942
 
                        purple_connection_error(js->gc, _("Invalid response from server."));
 
969
                        purple_connection_error_reason (js->gc,
 
970
                                PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
 
971
                                _("Invalid response from server."));
943
972
                }
944
973
        }
945
974
        /* If we've negotiated a security layer, we need to enable it */
955
984
 
956
985
void jabber_auth_handle_failure(JabberStream *js, xmlnode *packet)
957
986
{
958
 
        char *msg = jabber_parse_error(js, packet);
 
987
        PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
 
988
        char *msg = jabber_parse_error(js, packet, &reason);
959
989
 
960
990
        if(!msg) {
961
 
                purple_connection_error(js->gc, _("Invalid response from server."));
 
991
                purple_connection_error_reason (js->gc,
 
992
                        PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
 
993
                        _("Invalid response from server."));
962
994
        } else {
963
 
                purple_connection_error(js->gc, msg);
 
995
                purple_connection_error_reason (js->gc, reason, msg);
964
996
                g_free(msg);
965
997
        }
966
998
}