]> jfr.im git - irc/quakenet/snircd-patchqueue.git/blame - accountcollision.patch
accountcollision.patch - reworked snomask messages
[irc/quakenet/snircd-patchqueue.git] / accountcollision.patch
CommitLineData
5902ea46 1Add account collision kills, controlled by feature ACCOUNT_COLLISION_KILLS
2
3include/ircd_features.h
4ircd/ircd_features.c
5 add new feature
6
7include/numeric.h
8ircd/s_err.c
9 add new numerc 435 ERR_ACCOUNTCOLLISION (mirrored after 436 ERR_NICKCOLLISION)
10
11ircd/m_account.c
12 add the account collision kills
13
d2b4e55a 14diff -r 981169e4fc94 include/ircd_features.h
15--- a/include/ircd_features.h Sat Jan 24 12:58:40 2009 +0100
16+++ b/include/ircd_features.h Sat Jan 24 19:16:22 2009 +0100
5902ea46 17@@ -101,6 +101,7 @@
18 FEAT_IRCD_RES_TIMEOUT,
19 FEAT_AUTH_TIMEOUT,
20 FEAT_ANNOUNCE_INVITES,
21+ FEAT_ACCOUNT_COLLISION_KILLS,
22
23 /* features that affect all operators */
24 FEAT_EXTENDED_CHECKCMD,
d2b4e55a 25diff -r 981169e4fc94 include/numeric.h
26--- a/include/numeric.h Sat Jan 24 12:58:40 2009 +0100
27+++ b/include/numeric.h Sat Jan 24 19:16:22 2009 +0100
5902ea46 28@@ -357,6 +357,7 @@
29 /* ERR_NORULES 434 unreal */
30 /* ERR_SERVICECONFUSED 435 ? */
31 /* ERR_BANONCHAN 435 dalnet */
32+#define ERR_ACCOUNTCOLLISION 435 /* QuakeNet extension */
33 #define ERR_NICKCOLLISION 436
34 #define ERR_BANNICKCHANGE 437 /* Undernet extension */
35 /* ERR_UNAVAILRESOURCE 437 IRCnet extension */
d2b4e55a 36diff -r 981169e4fc94 ircd/ircd_features.c
37--- a/ircd/ircd_features.c Sat Jan 24 12:58:40 2009 +0100
38+++ b/ircd/ircd_features.c Sat Jan 24 19:16:22 2009 +0100
5902ea46 39@@ -355,6 +355,7 @@
40 F_I(IRCD_RES_TIMEOUT, 0, 4, 0),
41 F_I(AUTH_TIMEOUT, 0, 9, 0),
42 F_B(ANNOUNCE_INVITES, 0, 0, 0),
43+ F_B(ACCOUNT_COLLISION_KILLS, 0, 0, 0),
44
45 /* features that affect all operators */
46 F_B(EXTENDED_CHECKCMD, 0, 0, 0),
d2b4e55a 47diff -r 981169e4fc94 ircd/m_account.c
48--- a/ircd/m_account.c Sat Jan 24 12:58:40 2009 +0100
49+++ b/ircd/m_account.c Sat Jan 24 19:16:22 2009 +0100
5902ea46 50@@ -82,10 +82,12 @@
51
52 #include "client.h"
53 #include "ircd.h"
54+#include "ircd_features.h"
55 #include "ircd_log.h"
56 #include "ircd_reply.h"
57 #include "ircd_string.h"
58 #include "msg.h"
59+#include "numeric.h"
60 #include "numnicks.h"
61 #include "s_debug.h"
62 #include "s_user.h"
d2b4e55a 63@@ -138,10 +140,45 @@
5902ea46 64 if (IsAccount(acptr)) {
65 if (strcmp(cli_user(acptr)->account, parv[2]) ||
66 (cli_user(acptr)->acc_create != acc_create) ||
67- (cli_user(acptr)->acc_id != acc_id))
68- return protocol_violation(cptr, "ACCOUNT for already registered user %s "
69- "(%s -> %s)", cli_name(acptr),
70- cli_user(acptr)->account, parv[2]);
71+ (cli_user(acptr)->acc_id != acc_id)) {
72+
73+ /* license to KILL for account collisions */
74+ /* TODO: what if just the timestamp differs?
d2b4e55a 75+ * account and ID are the same
76+ * could we not resolve the conflict without KILL?
77+ * ie. oldest timestamp overrules?
5902ea46 78+ */
79+ if (feature_bool(FEAT_ACCOUNT_COLLISION_KILLS)) {
80+ /* inform ops */
d2b4e55a 81+ if (strcmp(cli_user(acptr)->account, parv[2]))
82+ sendto_opmask_butone(0, SNO_OLDSNO,
83+ "Account collision from %C on %C (%s <- %C %s (Different account))",
84+ sptr, acptr, cli_user(acptr)->account, cptr, parv[2]);
85+ else if (cli_user(acptr)->acc_id != acc_id)
86+ sendto_opmask_butone(0, SNO_OLDSNO,
87+ "Account collision from %C on %C (%lu <- %C %lu (Different ID))",
88+ sptr, acptr,cli_user(acptr)->acc_id, cptr, acc_id);
89+ else
90+ sendto_opmask_butone(0, SNO_OLDSNO,
91+ "Account collision from %C on %C (%Tu <- %C %Tu (Different timestamp))",
92+ sptr, acptr, cli_user(acptr)->acc_create, cptr, acc_create);
93+
5902ea46 94+ /* tell victim why we kill them */
d2b4e55a 95+ /* TODO: send the account we got here (parv[2]) or just a *? */
96+ send_reply(acptr, ERR_ACCOUNTCOLLISION, "*");
5902ea46 97+ /* Inform the rest of the net... */
98+ ServerStats->is_kill++;
99+ sendcmdto_serv_butone(&me, CMD_KILL, 0, "%C :%s (account collision)",
100+ acptr, cli_name(&me));
101+ /* don't go sending off a QUIT message... */
102+ SetFlag(acptr, FLAG_KILLED);
103+ /* remove them locally. */
104+ return exit_client_msg(cptr, acptr, &me, "Killed (%s (account collision))",
105+ feature_str(FEAT_HIS_SERVERNAME));
106+ } else
107+ return protocol_violation(cptr, "ACCOUNT for already registered user %s "
108+ "(%s -> %s)", cli_name(acptr), cli_user(acptr)->account, parv[2]);
109+ }
110
111 cli_user(acptr)->acc_flags = acc_flags;
112
d2b4e55a 113diff -r 981169e4fc94 ircd/s_err.c
114--- a/ircd/s_err.c Sat Jan 24 12:58:40 2009 +0100
115+++ b/ircd/s_err.c Sat Jan 24 19:16:22 2009 +0100
5902ea46 116@@ -902,7 +902,7 @@
117 /* 434 */
118 { 0 },
119 /* 435 */
120- { 0 },
121+ { ERR_ACCOUNTCOLLISION, "%s :Account collision KILL", "435" },
122 /* 436 */
123 { ERR_NICKCOLLISION, "%s :Nickname collision KILL", "436" },
124 /* 437 */