diff options
author | dequis <dx@dxzone.com.ar> | 2015-07-04 18:25:16 -0300 |
---|---|---|
committer | dequis <dx@dxzone.com.ar> | 2015-07-04 18:25:16 -0300 |
commit | 73dd021fa884bae857685e9a1beb44948c03399a (patch) | |
tree | 4d660c760455718e247844df1e368b2e9c52cad9 | |
parent | 632a232fc8d51df9b269d60fdf9f1a08355513ec (diff) |
jabber: Add SASL ANONYMOUS support (XEP-0175)
Use "account jabber set anonymous on" to have bitlbee try that method
-rw-r--r-- | doc/user-guide/commands.xml | 15 | ||||
-rw-r--r-- | protocols/jabber/jabber.c | 5 | ||||
-rw-r--r-- | protocols/jabber/sasl.c | 16 |
3 files changed, 33 insertions, 3 deletions
diff --git a/doc/user-guide/commands.xml b/doc/user-guide/commands.xml index 0de4dfcf..8c246d5e 100644 --- a/doc/user-guide/commands.xml +++ b/doc/user-guide/commands.xml @@ -1185,6 +1185,21 @@ </bitlbee-setting> + <bitlbee-setting name="anonymous" type="boolean" scope="account"> + <default>false</default> + + <description> + <para> + This enables SASL ANONYMOUS login for jabber accounts, as specified by XEP-0175. + </para> + + <para> + With this setting enabled, if the server allows this method, a password isn't required and the username part of the JID is ignored (you can use anonymous@jabber.example.com). Servers will usually assign you a random numeric username instead. + </para> + </description> + + </bitlbee-setting> + <bitlbee-setting name="ops" type="string" scope="global"> <default>both</default> <possible-values>both, root, user, none</possible-values> diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c index 431b3e54..38fb4966 100644 --- a/protocols/jabber/jabber.c +++ b/protocols/jabber/jabber.c @@ -84,7 +84,10 @@ static void jabber_init(account_t *acc) if (strcmp(acc->prpl->name, "hipchat") == 0) { set_setstr(&acc->set, "server", "chat.hipchat.com"); } else { - s = set_add(&acc->set, "oauth", "false", set_eval_oauth, acc); + set_add(&acc->set, "oauth", "false", set_eval_oauth, acc); + + /* this reuses set_eval_oauth, which clears the password */ + set_add(&acc->set, "anonymous", "false", set_eval_oauth, acc); } s = set_add(&acc->set, "ssl", "false", set_eval_bool, acc); diff --git a/protocols/jabber/sasl.c b/protocols/jabber/sasl.c index 45d52593..beb53fdd 100644 --- a/protocols/jabber/sasl.c +++ b/protocols/jabber/sasl.c @@ -53,8 +53,8 @@ xt_status sasl_pkt_mechanisms(struct xt_node *node, gpointer data) struct jabber_data *jd = ic->proto_data; struct xt_node *c, *reply; char *s; - int sup_plain = 0, sup_digest = 0, sup_gtalk = 0, sup_fb = 0; - int want_oauth = FALSE, want_hipchat = FALSE; + int sup_plain = 0, sup_digest = 0, sup_gtalk = 0, sup_fb = 0, sup_anonymous = 0; + int want_oauth = FALSE, want_hipchat = FALSE, want_anonymous = FALSE; GString *mechs; if (!sasl_supported(ic)) { @@ -73,6 +73,7 @@ xt_status sasl_pkt_mechanisms(struct xt_node *node, gpointer data) return XT_ABORT; } + want_anonymous = set_getbool(&ic->acc->set, "anonymous"); want_oauth = set_getbool(&ic->acc->set, "oauth"); want_hipchat = (jd->flags & JFLAG_HIPCHAT); @@ -83,6 +84,8 @@ xt_status sasl_pkt_mechanisms(struct xt_node *node, gpointer data) sup_plain = 1; } else if (c->text && g_strcasecmp(c->text, "DIGEST-MD5") == 0) { sup_digest = 1; + } else if (c->text && g_strcasecmp(c->text, "ANONYMOUS") == 0) { + sup_anonymous = 1; } else if (c->text && g_strcasecmp(c->text, "X-OAUTH2") == 0) { sup_gtalk = 1; } else if (c->text && g_strcasecmp(c->text, "X-FACEBOOK-PLATFORM") == 0) { @@ -141,6 +144,15 @@ xt_status sasl_pkt_mechanisms(struct xt_node *node, gpointer data) imc_logout(ic, FALSE); xt_free_node(reply); return XT_ABORT; + } else if (want_anonymous && sup_anonymous) { + xt_add_attr(reply, "mechanism", "ANONYMOUS"); + + /* Well, that was easy. */ + } else if (want_anonymous) { + imcb_error(ic, "Anonymous login requested, but not supported by server"); + imc_logout(ic, FALSE); + xt_free_node(reply); + return XT_ABORT; } else if (sup_digest) { xt_add_attr(reply, "mechanism", "DIGEST-MD5"); |