]> jfr.im git - irc/quakenet/snircd-patchqueue.git/blob - accountcollision.patch
add: accountcollision.patch
[irc/quakenet/snircd-patchqueue.git] / accountcollision.patch
1 Add account collision kills, controlled by feature ACCOUNT_COLLISION_KILLS
2
3 include/ircd_features.h
4 ircd/ircd_features.c
5 add new feature
6
7 include/numeric.h
8 ircd/s_err.c
9 add new numerc 435 ERR_ACCOUNTCOLLISION (mirrored after 436 ERR_NICKCOLLISION)
10
11 ircd/m_account.c
12 add the account collision kills
13
14 diff -r b193092040a9 include/ircd_features.h
15 --- a/include/ircd_features.h Fri Jan 23 12:53:22 2009 +0100
16 +++ b/include/ircd_features.h Fri Jan 23 15:08:41 2009 +0100
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,
25 diff -r b193092040a9 include/numeric.h
26 --- a/include/numeric.h Fri Jan 23 12:53:22 2009 +0100
27 +++ b/include/numeric.h Fri Jan 23 15:08:41 2009 +0100
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 */
36 diff -r b193092040a9 ircd/ircd_features.c
37 --- a/ircd/ircd_features.c Fri Jan 23 12:53:22 2009 +0100
38 +++ b/ircd/ircd_features.c Fri Jan 23 15:08:41 2009 +0100
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),
47 diff -r b193092040a9 ircd/m_account.c
48 --- a/ircd/m_account.c Fri Jan 23 12:53:22 2009 +0100
49 +++ b/ircd/m_account.c Fri Jan 23 15:08:41 2009 +0100
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"
63 @@ -138,10 +140,34 @@
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?
75 + * account and ID are the same
76 + * could we not resolve the conflict without KILL?
77 + */
78 + if (feature_bool(FEAT_ACCOUNT_COLLISION_KILLS)) {
79 + /* inform ops */
80 + sendto_opmask_butone(0, SNO_OLDSNO,
81 + "Account collision from %C on %C (%s:%Tu:%lu <- %C %s:%Tu:%lu)", sptr, acptr,
82 + cli_user(acptr)->account, cli_user(acptr)->acc_create, cli_user(acptr)->acc_id,
83 + cptr, parv[2], acc_create, acc_id);
84 + /* tell victim why we kill them */
85 + send_reply(acptr, ERR_ACCOUNTCOLLISION, parv[2]);
86 + /* Inform the rest of the net... */
87 + ServerStats->is_kill++;
88 + sendcmdto_serv_butone(&me, CMD_KILL, 0, "%C :%s (account collision)",
89 + acptr, cli_name(&me));
90 + /* don't go sending off a QUIT message... */
91 + SetFlag(acptr, FLAG_KILLED);
92 + /* remove them locally. */
93 + return exit_client_msg(cptr, acptr, &me, "Killed (%s (account collision))",
94 + feature_str(FEAT_HIS_SERVERNAME));
95 + } else
96 + return protocol_violation(cptr, "ACCOUNT for already registered user %s "
97 + "(%s -> %s)", cli_name(acptr), cli_user(acptr)->account, parv[2]);
98 + }
99
100 cli_user(acptr)->acc_flags = acc_flags;
101
102 diff -r b193092040a9 ircd/s_err.c
103 --- a/ircd/s_err.c Fri Jan 23 12:53:22 2009 +0100
104 +++ b/ircd/s_err.c Fri Jan 23 15:08:41 2009 +0100
105 @@ -902,7 +902,7 @@
106 /* 434 */
107 { 0 },
108 /* 435 */
109 - { 0 },
110 + { ERR_ACCOUNTCOLLISION, "%s :Account collision KILL", "435" },
111 /* 436 */
112 { ERR_NICKCOLLISION, "%s :Nickname collision KILL", "436" },
113 /* 437 */