]> jfr.im git - irc/quakenet/snircd-patchqueue.git/blob - realusername.patch
rename patch files
[irc/quakenet/snircd-patchqueue.git] / realusername.patch
1 Use realusername where needed instead of username
2
3 Use realusername when looking for Operator blocks, Kill blocks, and G-lines.
4
5 Use realusername when matching usernames in WHO (provided the target user is +h, and the source user is an oper).
6
7 Use realusername when checking the user@IP in nick collisions to determine which one to kill.
8
9 Copy realusername from username where username itself is copied - do not copy from cli_username()
10 as that is the one provided by the client (may contain bad chars?) and does not have the ~ prefix.
11
12 TODO:
13
14 Check realusername in bans/silences too? Currently it only matches the visible username.
15
16 WHOWAS does not save the realusername, only the realhost.
17
18 diff -r e7d4fe283cd0 ircd/gline.c
19 --- a/ircd/gline.c Sat Jul 20 14:54:45 2013 +0100
20 +++ b/ircd/gline.c Sat Jul 20 14:57:05 2013 +0100
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 @@ -416,8 +416,8 @@
31 continue;
32
33 ircd_snprintf(0, namebuf, sizeof(namebuf), "%s@%s",
34 - cli_user(acptr)->username, cli_user(acptr)->realhost);
35 - ircd_snprintf(0, ipbuf, sizeof(ipbuf), "%s@%s", cli_user(acptr)->username,
36 + cli_user(acptr)->realusername, cli_user(acptr)->realhost);
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 @@ -1354,7 +1354,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)) {
50 diff -r e7d4fe283cd0 ircd/m_nick.c
51 --- a/ircd/m_nick.c Sat Jul 20 14:54:45 2013 +0100
52 +++ b/ircd/m_nick.c Sat Jul 20 14:57:05 2013 +0100
53 @@ -415,7 +415,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 @@ -429,7 +429,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);
71 diff -r e7d4fe283cd0 ircd/m_who.c
72 --- a/ircd/m_who.c Sat Jul 20 14:54:45 2013 +0100
73 +++ b/ircd/m_who.c Sat Jul 20 14:57:05 2013 +0100
74 @@ -390,6 +390,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 @@ -429,6 +433,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))
96 diff -r e7d4fe283cd0 ircd/s_auth.c
97 --- a/ircd/s_auth.c Sat Jul 20 14:54:45 2013 +0100
98 +++ b/ircd/s_auth.c Sat Jul 20 14:57:05 2013 +0100
99 @@ -233,6 +233,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 @@ -265,6 +266,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 @@ -1065,7 +1067,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 @@ -1725,8 +1729,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
138 diff -r e7d4fe283cd0 ircd/s_conf.c
139 --- a/ircd/s_conf.c Sat Jul 20 14:54:45 2013 +0100
140 +++ b/ircd/s_conf.c Sat Jul 20 14:57:05 2013 +0100
141 @@ -645,8 +645,8 @@
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 {
152 @@ -1059,7 +1059,7 @@
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);
161 diff -r e7d4fe283cd0 ircd/s_misc.c
162 --- a/ircd/s_misc.c Sat Jul 20 14:54:45 2013 +0100
163 +++ b/ircd/s_misc.c Sat Jul 20 14:57:05 2013 +0100
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 cli_account(victim),
172 NumNick(victim), /* two %s's */