]> jfr.im git - irc/quakenet/snircd-patchqueue.git/blame_incremental - accountcollision.patch
split.patch - fixed for conflict with staffpriv.patch
[irc/quakenet/snircd-patchqueue.git] / accountcollision.patch
... / ...
CommitLineData
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
14diff -r aa908af5cc1f include/ircd_features.h
15--- a/include/ircd_features.h Wed Jan 28 19:53:55 2009 +0100
16+++ b/include/ircd_features.h Wed Jan 28 20:14:05 2009 +0100
17@@ -102,6 +102,7 @@
18 FEAT_AUTH_TIMEOUT,
19 FEAT_ANNOUNCE_INVITES,
20 FEAT_WELCOME,
21+ FEAT_ACCOUNT_COLLISION_KILLS,
22
23 /* features that affect all operators */
24 FEAT_EXTENDED_CHECKCMD,
25diff -r aa908af5cc1f include/numeric.h
26--- a/include/numeric.h Wed Jan 28 19:53:55 2009 +0100
27+++ b/include/numeric.h Wed Jan 28 20:14:05 2009 +0100
28@@ -362,6 +362,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 */
36diff -r aa908af5cc1f ircd/ircd_features.c
37--- a/ircd/ircd_features.c Wed Jan 28 19:53:55 2009 +0100
38+++ b/ircd/ircd_features.c Wed Jan 28 20:14:05 2009 +0100
39@@ -356,6 +356,7 @@
40 F_I(AUTH_TIMEOUT, 0, 9, 0),
41 F_B(ANNOUNCE_INVITES, 0, 0, 0),
42 F_B(WELCOME, 0, 1, 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),
47diff -r aa908af5cc1f ircd/m_account.c
48--- a/ircd/m_account.c Wed Jan 28 19:53:55 2009 +0100
49+++ b/ircd/m_account.c Wed Jan 28 20:14:05 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@@ -113,6 +115,7 @@
64 time_t acc_create;
65 unsigned long acc_id;
66 unsigned long long acc_flags;
67+ int diff_acc;
68
69 if (parc < 5)
70 return need_more_params(sptr, "ACCOUNT");
71@@ -136,12 +139,55 @@
72 * all other elements match
73 */
74 if (IsAccount(acptr)) {
75- if (strcmp(cli_user(acptr)->account, parv[2]) ||
76+ if ((diff_acc = strcmp(cli_user(acptr)->account, parv[2])) ||
77 (cli_user(acptr)->acc_create != acc_create) ||
78- (cli_user(acptr)->acc_id != acc_id))
79- return protocol_violation(cptr, "ACCOUNT for already registered user %s "
80- "(%s -> %s)", cli_name(acptr),
81- cli_user(acptr)->account, parv[2]);
82+ (cli_user(acptr)->acc_id != acc_id)) {
83+
84+ /* license to KILL for account collisions */
85+ /* TODO: what if just the timestamp differs?
86+ * account and ID are the same
87+ * could we not resolve the conflict without KILL?
88+ * ie. oldest timestamp overrules?
89+ */
90+ if (feature_bool(FEAT_ACCOUNT_COLLISION_KILLS)) {
91+ /* inform ops */
92+ /* accounts differ */
93+ if (diff_acc)
94+ sendto_opmask_butone(0, SNO_OLDSNO,
95+ "Account collision from %C on %C (%s <- %C %s (Different account))",
96+ sptr, acptr, cli_user(acptr)->account, cptr, parv[2]);
97+
98+ /* account IDs differ */
99+ else if (cli_user(acptr)->acc_id != acc_id)
100+ sendto_opmask_butone(0, SNO_OLDSNO,
101+ "Account collision from %C on %C (%lu <- %C %lu (Different ID))",
102+ sptr, acptr,cli_user(acptr)->acc_id, cptr, acc_id);
103+
104+ /* timestamps differ */
105+ else
106+ sendto_opmask_butone(0, SNO_OLDSNO,
107+ "Account collision from %C on %C (%Tu <- %C %Tu (Different timestamp))",
108+ sptr, acptr, cli_user(acptr)->acc_create, cptr, acc_create);
109+
110+ /* tell victim why we kill them */
111+ /* TODO: send the account we got here (parv[2]) or just a *? */
112+ send_reply(acptr, ERR_ACCOUNTCOLLISION, "*");
113+
114+ /* Inform the rest of the net... */
115+ ServerStats->is_kill++;
116+ sendcmdto_serv_butone(&me, CMD_KILL, 0, "%C :%s (account collision)",
117+ acptr, cli_name(&me));
118+
119+ /* don't go sending off a QUIT message... */
120+ SetFlag(acptr, FLAG_KILLED);
121+
122+ /* remove them locally. */
123+ return exit_client_msg(cptr, acptr, &me, "Killed (%s (account collision))",
124+ feature_str(FEAT_HIS_SERVERNAME));
125+ } else
126+ return protocol_violation(cptr, "ACCOUNT for already registered user %s "
127+ "(%s -> %s)", cli_name(acptr), cli_user(acptr)->account, parv[2]);
128+ }
129
130 cli_user(acptr)->acc_flags = acc_flags;
131
132diff -r aa908af5cc1f ircd/s_err.c
133--- a/ircd/s_err.c Wed Jan 28 19:53:55 2009 +0100
134+++ b/ircd/s_err.c Wed Jan 28 20:14:05 2009 +0100
135@@ -902,7 +902,7 @@
136 /* 434 */
137 { 0 },
138 /* 435 */
139- { 0 },
140+ { ERR_ACCOUNTCOLLISION, "%s :Account collision KILL", "435" },
141 /* 436 */
142 { ERR_NICKCOLLISION, "%s :Nickname collision KILL", "436" },
143 /* 437 */