]> jfr.im git - irc/quakenet/snircd-patchqueue.git/blame - realusername.patch
Refresh patch
[irc/quakenet/snircd-patchqueue.git] / realusername.patch
CommitLineData
ac2ec87d 1Use realusername where needed instead of username
2
8bbb5ea4 3Use realusername when looking for Operator blocks, Kill blocks, and G-lines.
4
ac2ec87d 5Use realusername when matching usernames in WHO (provided the target user is +h, and the source user is an oper).
6
7Use realusername when checking the user@IP in nick collisions to determine which one to kill.
8
9Copy realusername from username where username itself is copied - do not copy from cli_username()
10as that is the one provided by the client (may contain bad chars?) and does not have the ~ prefix.
11
12TODO:
13
14Check realusername in bans/silences too? Currently it only matches the visible username.
15
16WHOWAS does not save the realusername, only the realhost.
17
405f6b2f 18diff -r 4677b599b0cc ircd/gline.c
ac2ec87d 19--- a/ircd/gline.c
20+++ b/ircd/gline.c
21@@ -259,7 +259,7 @@
22 match(gline->gl_nick, cli_name(acptr)) !=0)
23 continue;
24
25- if (cli_user(acptr)->username &&
26+ if (cli_user(acptr)->realusername &&
27 match(gline->gl_user, (cli_user(acptr))->realusername) != 0)
28 continue;
29
30@@ -415,8 +415,8 @@
31 continue;
32
33 ircd_snprintf(0, namebuf, sizeof(namebuf), "%s@%s",
34- cli_user(acptr)->username, cli_user(acptr)->host);
35- ircd_snprintf(0, ipbuf, sizeof(ipbuf), "%s@%s", cli_user(acptr)->username,
36+ cli_user(acptr)->realusername, cli_user(acptr)->host); /* TODO: should be realhost? ircu bug? */
37+ ircd_snprintf(0, ipbuf, sizeof(ipbuf), "%s@%s", cli_user(acptr)->realusername,
38 ircd_ntoa(&cli_ip(acptr)));
39
40 if (!match(mask, namebuf)
41@@ -1342,7 +1342,7 @@
42 if (match(gline->gl_nick, nick) != 0)
43 continue;
44
45- if (match(gline->gl_user, (cli_user(cptr))->username) != 0)
46+ if (match(gline->gl_user, (cli_user(cptr))->realusername) != 0)
47 continue;
48
49 if (GlineIsIpMask(gline)) {
405f6b2f 50diff -r 4677b599b0cc ircd/m_nick.c
ac2ec87d 51--- a/ircd/m_nick.c
52+++ b/ircd/m_nick.c
53@@ -421,7 +421,7 @@
54 */
55 base64toip(parv[parc - 3], &ip);
56 differ = (0 != memcmp(&cli_ip(acptr), &ip, sizeof(cli_ip(acptr)))) ||
57- (0 != ircd_strcmp(cli_user(acptr)->username, parv[4]));
58+ (0 != ircd_strcmp(cli_user(acptr)->realusername, parv[4]));
59 sendto_opmask_butone(0, SNO_OLDSNO, "Nick collision on %C (%C %Tu <- "
60 "%C %Tu (%s user@host))", acptr, cli_from(acptr),
61 cli_lastnick(acptr), cptr, lastnick,
62@@ -435,7 +435,7 @@
63 * compare IP address and username
64 */
65 differ = (0 != memcmp(&cli_ip(acptr), &cli_ip(sptr), sizeof(cli_ip(acptr)))) ||
66- (0 != ircd_strcmp(cli_user(acptr)->username, cli_user(sptr)->username));
67+ (0 != ircd_strcmp(cli_user(acptr)->realusername, cli_user(sptr)->realusername));
68 sendto_opmask_butone(0, SNO_OLDSNO, "Nick change collision from %C to "
69 "%C (%C %Tu <- %C %Tu)", sptr, acptr, cli_from(acptr),
70 cli_lastnick(acptr), cptr, lastnick);
405f6b2f 71diff -r 4677b599b0cc ircd/m_who.c
ac2ec87d 72--- a/ircd/m_who.c
73+++ b/ircd/m_who.c
74@@ -389,6 +389,10 @@
75 || matchexec(cli_name(acptr), mymask, minlen))
76 && ((!(matchsel & WHO_FIELD_UID))
77 || matchexec(cli_user(acptr)->username, mymask, minlen))
78+ && ((!(matchsel & WHO_FIELD_UID))
79+ || !IsSetHost(acptr)
80+ || !IsAnOper(sptr)
81+ || matchexec(cli_user(acptr)->realusername, mymask, minlen))
82 && ((!(matchsel & WHO_FIELD_SER))
83 || (!(HasFlag(cli_user(acptr)->server, FLAG_MAP))))
84 && ((!(matchsel & WHO_FIELD_HOS))
85@@ -428,6 +432,10 @@
86 || matchexec(cli_name(acptr), mymask, minlen))
87 && ((!(matchsel & WHO_FIELD_UID))
88 || matchexec(cli_user(acptr)->username, mymask, minlen))
89+ && ((!(matchsel & WHO_FIELD_UID))
90+ || !IsSetHost(acptr)
91+ || !IsAnOper(sptr)
92+ || matchexec(cli_user(acptr)->realusername, mymask, minlen))
93 && ((!(matchsel & WHO_FIELD_SER))
94 || (!(HasFlag(cli_user(acptr)->server, FLAG_MAP))))
95 && ((!(matchsel & WHO_FIELD_HOS))
405f6b2f 96diff -r 4677b599b0cc ircd/s_auth.c
ac2ec87d 97--- a/ircd/s_auth.c
98+++ b/ircd/s_auth.c
99@@ -232,6 +232,7 @@
100 char last;
101 char *reason;
102
103+ /* TODO: */
104 if (FlagHas(&auth->flags, AR_IAUTH_USERNAME))
105 {
106 ircd_strncpy(cli_user(sptr)->username, cli_username(sptr), USERLEN);
107@@ -264,6 +265,7 @@
108 || ((user->username[0] == '~') && (user->username[1] == '\0')))
109 return exit_client(sptr, sptr, &me, "USER: Bogus userid.");
110
111+ /* TODO: */
112 /* Have to set up "realusername" before doing the gline check below */
113 ircd_strncpy(user->realusername, user->username, USERLEN);
114
115@@ -1063,7 +1065,9 @@
116 FlagClr(&auth->flags, AR_NEEDS_USER);
117 cptr = auth->client;
118 ircd_strncpy(cli_info(cptr), userinfo, REALLEN);
119+ /* TODO: */
120 ircd_strncpy(cli_user(cptr)->username, username, USERLEN);
121+ ircd_strncpy(cli_user(cptr)->realusername, username, USERLEN);
122 ircd_strncpy(cli_user(cptr)->host, cli_sockhost(cptr), HOSTLEN);
123 if (IAuthHas(iauth, IAUTH_UNDERNET))
124 sendto_iauth(cptr, "U %s %s %s :%s", username, hostname, servername, userinfo);
125@@ -1723,8 +1727,11 @@
126 {
127 assert(cli_auth(cli) != NULL);
128 FlagClr(&cli_auth(cli)->flags, AR_AUTH_PENDING);
129- if (!EmptyString(params[0]))
130+ /* TODO: */
131+ if (!EmptyString(params[0])) {
132 ircd_strncpy(cli_user(cli)->username, params[0], USERLEN);
133+ ircd_strncpy(cli_user(cli)->realusername, params[0], USERLEN);
134+ }
135 return 1;
136 }
137
405f6b2f 138diff -r 4677b599b0cc ircd/s_conf.c
ac2ec87d 139--- a/ircd/s_conf.c
140+++ b/ircd/s_conf.c
141@@ -647,8 +647,8 @@
8bbb5ea4 142 0 != ircd_strcmp(tmp->name, name))
143 continue;
144 if (tmp->username
145- && (EmptyString(cli_username(cptr))
146- || match(tmp->username, cli_username(cptr))))
147+ && (EmptyString(cli_user(cptr)->realusername)
148+ || match(tmp->username, cli_user(cptr)->realusername)))
149 continue;
150 if (tmp->addrbits < 0)
151 {
ac2ec87d 152@@ -1061,7 +1061,7 @@
8bbb5ea4 153 return 0;
154
155 host = cli_sockhost(cptr);
156- name = cli_user(cptr)->username;
157+ name = cli_user(cptr)->realusername;
158 realname = cli_info(cptr);
159
160 assert(strlen(host) <= HOSTLEN);
405f6b2f 161diff -r 4677b599b0cc ircd/s_misc.c
ac2ec87d 162--- a/ircd/s_misc.c
163+++ b/ircd/s_misc.c
164@@ -399,7 +399,7 @@
165 if (IsUser(victim))
166 log_write(LS_USER, L_TRACE, 0, "%Tu %i %s@%s %s %s %s%s %s :%s",
167 cli_firsttime(victim), on_for,
168- cli_user(victim)->username, cli_sockhost(victim),
169+ cli_user(victim)->realusername, cli_sockhost(victim),
170 ircd_ntoa(&cli_ip(victim)),
171 IsAccount(victim) ? cli_username(victim) : "0",
172 NumNick(victim), /* two %s's */