From 94d86632dcb4a21864e541d2574cabee1e62012f Mon Sep 17 00:00:00 2001 From: Stephen Bennett Date: Wed, 30 Mar 2011 11:30:47 +0100 Subject: [PATCH 1/9] Disallow mIRC italics in channel names when disable_fake_channels --- src/match.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/match.c b/src/match.c index a0509c48..a4b54971 100644 --- a/src/match.c +++ b/src/match.c @@ -684,7 +684,7 @@ const unsigned int CharAttrs[] = { /* 26 */ CNTRL_C | CHAN_C | NONEOS_C, /* 27 */ CNTRL_C | CHAN_C | NONEOS_C, /* 28 */ CNTRL_C | CHAN_C | NONEOS_C, -/* 29 */ CNTRL_C | CHAN_C | NONEOS_C, +/* 29 */ CNTRL_C | CHAN_C | NONEOS_C | FCHAN_C, /* 30 */ CNTRL_C | CHAN_C | NONEOS_C, /* 31 */ CNTRL_C | CHAN_C | FCHAN_C | NONEOS_C, /* SP */ PRINT_C | SPACE_C, From b19d3c5186ef095c46e99cd0b9c42137274913a4 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Thu, 31 Mar 2011 00:05:42 +0200 Subject: [PATCH 2/9] Style: use a consistent order for the _C constants. --- src/match.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/match.c b/src/match.c index a4b54971..18d7472f 100644 --- a/src/match.c +++ b/src/match.c @@ -684,7 +684,7 @@ const unsigned int CharAttrs[] = { /* 26 */ CNTRL_C | CHAN_C | NONEOS_C, /* 27 */ CNTRL_C | CHAN_C | NONEOS_C, /* 28 */ CNTRL_C | CHAN_C | NONEOS_C, -/* 29 */ CNTRL_C | CHAN_C | NONEOS_C | FCHAN_C, +/* 29 */ CNTRL_C | CHAN_C | FCHAN_C | NONEOS_C, /* 30 */ CNTRL_C | CHAN_C | NONEOS_C, /* 31 */ CNTRL_C | CHAN_C | FCHAN_C | NONEOS_C, /* SP */ PRINT_C | SPACE_C, From 8e00d87838d0592b1b955a502fb5b37171b62852 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Thu, 17 Mar 2011 10:45:57 -0500 Subject: [PATCH 3/9] bantool: _XOPEN_SOURCE should die in a fire --- bandb/bantool.c | 1 - 1 file changed, 1 deletion(-) diff --git a/bandb/bantool.c b/bandb/bantool.c index 3b7f949a..81797449 100644 --- a/bandb/bantool.c +++ b/bandb/bantool.c @@ -38,7 +38,6 @@ * */ -#define _XOPEN_SOURCE #include #include #include From d8c45202e39f71ca967b7c1264c8b8911afc0755 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Thu, 31 Mar 2011 00:18:32 -0500 Subject: [PATCH 4/9] sasl: remove checks for impossible conditions --- modules/m_sasl.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/modules/m_sasl.c b/modules/m_sasl.c index 41bf823d..b17e6bdc 100644 --- a/modules/m_sasl.c +++ b/modules/m_sasl.c @@ -77,12 +77,6 @@ mr_authenticate(struct Client *client_p, struct Client *source_p, if(!IsCapable(source_p, CLICAP_SASL)) return 0; - if (strlen(client_p->id) == 3) - { - exit_client(client_p, client_p, client_p, "Mixing client and server protocol"); - return 0; - } - if(source_p->preClient->sasl_complete) { sendto_one(source_p, form_str(ERR_SASLALREADY), me.name, EmptyString(source_p->name) ? "*" : source_p->name); @@ -111,6 +105,7 @@ mr_authenticate(struct Client *client_p, struct Client *source_p, else sendto_one(agent_p, ":%s ENCAP %s SASL %s %s C %s", me.id, agent_p->servptr->name, source_p->id, agent_p->id, parv[1]); + source_p->preClient->sasl_out++; return 0; From 27126f911d358d07aa145218646ecc4f2f94c96f Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Thu, 31 Mar 2011 00:35:58 -0500 Subject: [PATCH 5/9] sasl: first attempt at ircv3.1 AUTHENTICATE EXTERNAL support --- include/client.h | 1 + modules/m_sasl.c | 26 ++++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/include/client.h b/include/client.h index 2c3597f7..8eaa971a 100644 --- a/include/client.h +++ b/include/client.h @@ -292,6 +292,7 @@ struct PreClient char sasl_agent[IDLEN]; unsigned char sasl_out; unsigned char sasl_complete; + unsigned char sasl_external; rb_dlink_list dnsbl_queries; /* list of struct BlacklistClient * */ struct Blacklist *dnsbl_listed; /* first dnsbl where it's listed */ diff --git a/modules/m_sasl.c b/modules/m_sasl.c index b17e6bdc..a4c5e24d 100644 --- a/modules/m_sasl.c +++ b/modules/m_sasl.c @@ -1,6 +1,6 @@ /* modules/m_sasl.c * Copyright (C) 2006 Michael Tharp - * Copyright (C) 2006 charybdis development team + * Copyright (C) 2006, 2011 charybdis development team * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -67,6 +67,10 @@ mapi_hfn_list_av1 sasl_hfnlist[] = { DECLARE_MODULE_AV1(sasl, NULL, NULL, sasl_clist, NULL, sasl_hfnlist, "$Revision: 1409 $"); +/* + * parv[1] = mechanism. + * in ircv3.1, if this is EXTERNAL, we just send the certificate fingerprint. + */ static int mr_authenticate(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) @@ -100,8 +104,16 @@ mr_authenticate(struct Client *client_p, struct Client *source_p, agent_p = find_id(source_p->preClient->sasl_agent); if(agent_p == NULL) + { + if (!strcasecmp(parv[1], "EXTERNAL")) + { + if (source_p->certfp) + source_p->preClient->sasl_external++; + } + sendto_server(NULL, NULL, CAP_TS6|CAP_ENCAP, NOCAPS, ":%s ENCAP * SASL %s * S %s", me.id, source_p->id, parv[1]); + } else sendto_one(agent_p, ":%s ENCAP %s SASL %s %s C %s", me.id, agent_p->servptr->name, source_p->id, agent_p->id, parv[1]); @@ -147,8 +159,18 @@ me_sasl(struct Client *client_p, struct Client *source_p, else if(!*target_p->preClient->sasl_agent) rb_strlcpy(target_p->preClient->sasl_agent, parv[1], IDLEN); - if(*parv[3] == 'C') + if(*parv[3] == 'C' && !target_p->preClient->sasl_external) sendto_one(target_p, "AUTHENTICATE %s", parv[4]); + else if(*parv[3] == 'C' && *target_p->preClient->sasl_agent) + { + unsigned char *message; + + message = rb_base64_encode((unsigned char *) target_p->certfp, strlen(target_p->certfp)); + sendto_one(agent_p, ":%s ENCAP %s SASL %s %s C %s", me.id, agent_p->servptr->name, + source_p->id, agent_p->id, message); + + rb_free(message); + } else if(*parv[3] == 'D') { if(*parv[4] == 'F') From 1b19fe8b5ed80bd5053cb1767fc5e6a402705fed Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Thu, 31 Mar 2011 23:26:26 +0200 Subject: [PATCH 6/9] Revert "sasl: remove checks for impossible conditions". This check is not impossible and can be triggered by sending a PASS command like a server would send first. This backs out changeset 8cba4464feec. --- modules/m_sasl.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/m_sasl.c b/modules/m_sasl.c index a4c5e24d..3345b212 100644 --- a/modules/m_sasl.c +++ b/modules/m_sasl.c @@ -81,6 +81,12 @@ mr_authenticate(struct Client *client_p, struct Client *source_p, if(!IsCapable(source_p, CLICAP_SASL)) return 0; + if (strlen(client_p->id) == 3) + { + exit_client(client_p, client_p, client_p, "Mixing client and server protocol"); + return 0; + } + if(source_p->preClient->sasl_complete) { sendto_one(source_p, form_str(ERR_SASLALREADY), me.name, EmptyString(source_p->name) ? "*" : source_p->name); @@ -117,7 +123,6 @@ mr_authenticate(struct Client *client_p, struct Client *source_p, else sendto_one(agent_p, ":%s ENCAP %s SASL %s %s C %s", me.id, agent_p->servptr->name, source_p->id, agent_p->id, parv[1]); - source_p->preClient->sasl_out++; return 0; From f62f94b094b2d0f8ef11fe8cdd0b8b6a38acafc7 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Mon, 4 Apr 2011 00:44:07 +0200 Subject: [PATCH 7/9] Back out AUTHENTICATE EXTERNAL so I can do it differently. The current approach is fundamentally broken as it allows anyone in that knows the certfp and uses an old ircd as their server. --- include/client.h | 1 - modules/m_sasl.c | 26 ++------------------------ 2 files changed, 2 insertions(+), 25 deletions(-) diff --git a/include/client.h b/include/client.h index 8eaa971a..2c3597f7 100644 --- a/include/client.h +++ b/include/client.h @@ -292,7 +292,6 @@ struct PreClient char sasl_agent[IDLEN]; unsigned char sasl_out; unsigned char sasl_complete; - unsigned char sasl_external; rb_dlink_list dnsbl_queries; /* list of struct BlacklistClient * */ struct Blacklist *dnsbl_listed; /* first dnsbl where it's listed */ diff --git a/modules/m_sasl.c b/modules/m_sasl.c index 3345b212..41bf823d 100644 --- a/modules/m_sasl.c +++ b/modules/m_sasl.c @@ -1,6 +1,6 @@ /* modules/m_sasl.c * Copyright (C) 2006 Michael Tharp - * Copyright (C) 2006, 2011 charybdis development team + * Copyright (C) 2006 charybdis development team * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -67,10 +67,6 @@ mapi_hfn_list_av1 sasl_hfnlist[] = { DECLARE_MODULE_AV1(sasl, NULL, NULL, sasl_clist, NULL, sasl_hfnlist, "$Revision: 1409 $"); -/* - * parv[1] = mechanism. - * in ircv3.1, if this is EXTERNAL, we just send the certificate fingerprint. - */ static int mr_authenticate(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) @@ -110,16 +106,8 @@ mr_authenticate(struct Client *client_p, struct Client *source_p, agent_p = find_id(source_p->preClient->sasl_agent); if(agent_p == NULL) - { - if (!strcasecmp(parv[1], "EXTERNAL")) - { - if (source_p->certfp) - source_p->preClient->sasl_external++; - } - sendto_server(NULL, NULL, CAP_TS6|CAP_ENCAP, NOCAPS, ":%s ENCAP * SASL %s * S %s", me.id, source_p->id, parv[1]); - } else sendto_one(agent_p, ":%s ENCAP %s SASL %s %s C %s", me.id, agent_p->servptr->name, source_p->id, agent_p->id, parv[1]); @@ -164,18 +152,8 @@ me_sasl(struct Client *client_p, struct Client *source_p, else if(!*target_p->preClient->sasl_agent) rb_strlcpy(target_p->preClient->sasl_agent, parv[1], IDLEN); - if(*parv[3] == 'C' && !target_p->preClient->sasl_external) + if(*parv[3] == 'C') sendto_one(target_p, "AUTHENTICATE %s", parv[4]); - else if(*parv[3] == 'C' && *target_p->preClient->sasl_agent) - { - unsigned char *message; - - message = rb_base64_encode((unsigned char *) target_p->certfp, strlen(target_p->certfp)); - sendto_one(agent_p, ":%s ENCAP %s SASL %s %s C %s", me.id, agent_p->servptr->name, - source_p->id, agent_p->id, message); - - rb_free(message); - } else if(*parv[3] == 'D') { if(*parv[4] == 'F') From 572488e0295bd054d9b75021d3cfe8faf56afb4f Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Mon, 4 Apr 2011 00:59:20 +0200 Subject: [PATCH 8/9] If the sasl mechanism is EXTERNAL, send the certfp in the initial S message. --- modules/m_sasl.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/m_sasl.c b/modules/m_sasl.c index 41bf823d..8dbbf0e7 100644 --- a/modules/m_sasl.c +++ b/modules/m_sasl.c @@ -106,8 +106,15 @@ mr_authenticate(struct Client *client_p, struct Client *source_p, agent_p = find_id(source_p->preClient->sasl_agent); if(agent_p == NULL) - sendto_server(NULL, NULL, CAP_TS6|CAP_ENCAP, NOCAPS, ":%s ENCAP * SASL %s * S %s", me.id, - source_p->id, parv[1]); + { + if (!strcmp(parv[1], "EXTERNAL") && source_p->certfp != NULL) + sendto_server(NULL, NULL, CAP_TS6|CAP_ENCAP, NOCAPS, ":%s ENCAP * SASL %s * S %s %s", me.id, + source_p->id, parv[1], + source_p->certfp); + else + sendto_server(NULL, NULL, CAP_TS6|CAP_ENCAP, NOCAPS, ":%s ENCAP * SASL %s * S %s", me.id, + source_p->id, parv[1]); + } else sendto_one(agent_p, ":%s ENCAP %s SASL %s %s C %s", me.id, agent_p->servptr->name, source_p->id, agent_p->id, parv[1]); From a1574df4a2c912943e1d5858e7fd3cb92e8b6345 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Wed, 6 Apr 2011 19:05:08 +0200 Subject: [PATCH 9/9] Allow kick_on_split_riding to protect channels with mlocked keys. Do kick_on_split_riding if services sends an SJOIN with a lower TS and a different key. This relies on services restoring TS (changets option in atheme) and services not immediately parting after receiving the KICK, which is the case in recent atheme. For invite-only channels, still only do kick_on_split_riding in netbursts. Services is assumed to handle this itself (atheme does). --- modules/core/m_join.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/core/m_join.c b/modules/core/m_join.c index c4308b07..070d8588 100644 --- a/modules/core/m_join.c +++ b/modules/core/m_join.c @@ -639,12 +639,15 @@ ms_sjoin(struct Client *client_p, struct Client *source_p, int parc, const char { /* If configured, kick people trying to join +i/+k * channels by recreating them on split servers. - * Don't kick if the source has sent EOB (services - * deopping everyone by TS-1 SJOIN). + * If the source has sent EOB, assume this is some + * sort of hack by services. If cmode +i is set, + * services can send kicks if needed; if the key + * differs, services cannot kick in a race-free + * manner so do so here. * -- jilles */ if (ConfigChannel.kick_on_split_riding && - !HasSentEob(source_p) && - ((mode.mode & MODE_INVITEONLY) || + ((!HasSentEob(source_p) && + mode.mode & MODE_INVITEONLY) || (mode.key[0] != 0 && irccmp(mode.key, oldmode->key) != 0))) { struct membership *msptr;