diff options
author | Adam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-12-01 00:06:21 +0000 |
---|---|---|
committer | Adam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-12-01 00:06:21 +0000 |
commit | b5242e3be0801abd0edebf62955b1d1b6cd3fd7d (patch) | |
tree | 2aa6d1c88fef3a0cfb12fee3e216a8cdcddc6af6 /src | |
parent | 84ac00e953c9d8a03bd7b76bcdf5de26832edcfa (diff) |
Fixed bug #1106 - Anope now keeps track of users cloaked hosts as well as virtual host and will use both in matching for things
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/stable@2679 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src')
-rw-r--r-- | src/actions.c | 9 | ||||
-rw-r--r-- | src/core/hs_off.c | 6 | ||||
-rw-r--r-- | src/nickserv.c | 22 | ||||
-rw-r--r-- | src/protocol/rageircd.c | 2 | ||||
-rw-r--r-- | src/protocol/solidircd.c | 2 | ||||
-rw-r--r-- | src/protocol/ultimate3.c | 2 | ||||
-rw-r--r-- | src/protocol/unreal31.c | 9 | ||||
-rw-r--r-- | src/protocol/unreal32.c | 19 | ||||
-rw-r--r-- | src/protocol/viagra.c | 2 | ||||
-rw-r--r-- | src/users.c | 16 |
10 files changed, 59 insertions, 30 deletions
diff --git a/src/actions.c b/src/actions.c index 31cf2db8f..6be45c112 100644 --- a/src/actions.c +++ b/src/actions.c @@ -181,7 +181,8 @@ void common_unban(ChannelInfo * ci, char *nick) for (ban = ci->c->bans->entries; ban; ban = next) { next = ban->next; if (entry_match(ban, u->nick, u->username, u->host, ip) || - entry_match(ban, u->nick, u->username, u->vhost, ip)) { + entry_match(ban, u->nick, u->username, u->vhost, ip) || + entry_match(ban, u->nick, u->username, u->chost, ip)) { anope_cmd_mode(whosends(ci), ci->name, "-b %s", ban->mask); if (ircdcap->tsmode) av[3] = ban->mask; @@ -240,10 +241,10 @@ char *common_get_vhost(User * u) if (!u) return NULL; - if (ircd->vhostmode && (u->mode & ircd->vhostmode)) - return u->vhost; - else if (ircd->vhost && u->vhost) + if (ircd->vhostmode && (u->mode & ircd->vhostmode) && u->vhost) return u->vhost; + else if (ircd->vhostmode && (u->mode & ircd->vhostmode) && u->chost) + return u->chost; else return u->host; } diff --git a/src/core/hs_off.c b/src/core/hs_off.c index 54bfeca75..045061657 100644 --- a/src/core/hs_off.c +++ b/src/core/hs_off.c @@ -75,8 +75,12 @@ int do_off(User * u) vident = getvIdent(u->nick); if (vhost == NULL && vident == NULL) notice_lang(s_HostServ, u, HOST_NOT_ASSIGNED); - else + else { anope_cmd_vhost_off(u); + if (u->vhost) + free(u->vhost); + u->vhost = NULL; + } } else { notice_lang(s_HostServ, u, HOST_ID); } diff --git a/src/nickserv.c b/src/nickserv.c index 5c3b1b72c..770bff060 100644 --- a/src/nickserv.c +++ b/src/nickserv.c @@ -1281,8 +1281,7 @@ NickCore *findcore(const char *nick) int is_on_access(User * u, NickCore * nc) { int i; - char *buf; - char *buf2 = NULL; + char *buf, *buf2 = NULL, *buf3 = NULL; if (nc->accesscount == 0) return 0; @@ -1294,24 +1293,33 @@ int is_on_access(User * u, NickCore * nc) buf2 = scalloc(strlen(u->username) + strlen(u->vhost) + 2, 1); sprintf(buf2, "%s@%s", u->username, u->vhost); } + if (u->chost) + { + buf3 = scalloc(strlen(u->username) + strlen(u->chost) + 2, 1); + sprintf(buf2, "%s@%s", u->username, u->chost); + } } for (i = 0; i < nc->accesscount; i++) { - if (match_wild_nocase(nc->access[i], buf) - || (ircd->vhost ? match_wild_nocase(nc->access[i], buf2) : 0)) { + if (match_wild_nocase(nc->access[i], buf) || (buf2 && match_wild_nocase(nc->access[i], buf2)) || (buf3 && match_wild_nocase(nc->access[i], buf3))) + { free(buf); if (ircd->vhost) { if (u->vhost) { free(buf2); } + if (u->chost) + free(buf3); } return 1; } } free(buf); - if (ircd->vhost) { - free(buf2); - } + if (buf2) + free(buf2); + if (buf3) + free(buf3); + return 0; } diff --git a/src/protocol/rageircd.c b/src/protocol/rageircd.c index 5ad02f5ec..4103fc202 100644 --- a/src/protocol/rageircd.c +++ b/src/protocol/rageircd.c @@ -668,7 +668,7 @@ void rageircd_cmd_topic(char *whosets, char *chan, char *whosetit, void rageircd_cmd_vhost_off(User * u) { - send_cmd(s_HostServ, "SVSMODE %s -x", u->nick); + common_svsmode(u, "-x", NULL); notice_lang(s_HostServ, u, HOST_OFF_UNREAL, u->nick, ircd->vhostchar); } diff --git a/src/protocol/solidircd.c b/src/protocol/solidircd.c index 52e6c5dd4..dbcff821a 100644 --- a/src/protocol/solidircd.c +++ b/src/protocol/solidircd.c @@ -1388,7 +1388,7 @@ void solidircd_cmd_vhost_on(char *nick, char *vIdent, char *vhost) void solidircd_cmd_vhost_off(User * u) { - send_cmd(s_HostServ, "SVSMODE %s -v", u->nick); + common_svsmode(u, "-v", NULL); notice_lang(s_HostServ, u, HOST_OFF_UNREAL, u->nick, ircd->vhostchar); } diff --git a/src/protocol/ultimate3.c b/src/protocol/ultimate3.c index 5afde95e0..2a328186d 100644 --- a/src/protocol/ultimate3.c +++ b/src/protocol/ultimate3.c @@ -720,7 +720,7 @@ void ultimate3_cmd_remove_akill(char *user, char *host) void ultimate3_cmd_vhost_off(User * u) { - send_cmd(s_HostServ, "SVSMODE %s -x", u->nick); + common_svsmode(u, "-x", NULL); notice_lang(s_HostServ, u, HOST_OFF_UNREAL, u->nick, ircd->vhostchar); } diff --git a/src/protocol/unreal31.c b/src/protocol/unreal31.c index 2284a9faf..76a31c4cf 100644 --- a/src/protocol/unreal31.c +++ b/src/protocol/unreal31.c @@ -424,6 +424,12 @@ void unreal_set_umode(User * user, int ac, char **av) } break; case 'x': + if (!add) + { + if (user->vhost) + free(user->vhost); + user->vhost = NULL; + } update_host(user); break; } @@ -518,7 +524,8 @@ void unreal_cmd_topic(char *whosets, char *chan, char *whosetit, void unreal_cmd_vhost_off(User * u) { - send_cmd(s_HostServ, "SVSMODE %s -xt", u->nick); + common_svsmode(u, "-xt", NULL); + common_svsmode(u, "+x", NULL); notice_lang(s_HostServ, u, HOST_OFF_UNREAL, u->nick, ircd->vhostchar); } diff --git a/src/protocol/unreal32.c b/src/protocol/unreal32.c index 0919fabbe..f93dc8236 100644 --- a/src/protocol/unreal32.c +++ b/src/protocol/unreal32.c @@ -489,6 +489,12 @@ void unreal_set_umode(User * user, int ac, char **av) } break; case 'x': + if (!add) + { + if (user->vhost) + free(user->vhost); + user->vhost = NULL; + } update_host(user); break; } @@ -532,18 +538,9 @@ void unreal_cmd_topic(char *whosets, char *chan, char *whosetit, void unreal_cmd_vhost_off(User * u) { - if (UseSVS2MODE) { - send_cmd(s_HostServ, "%s %s -xt", send_token("SVS2MODE", "v"), - u->nick); - send_cmd(s_HostServ, "%s %s +x", send_token("SVS2MODE", "v"), - u->nick); - } else { - send_cmd(s_HostServ, "%s %s -xt", send_token("SVSMODE", "n"), - u->nick); - send_cmd(s_HostServ, "%s %s +x", send_token("SVSMODE", "n"), - u->nick); + common_svsmode(u, "-xt", NULL); + common_svsmode(u, "+x", NULL); - } notice_lang(s_HostServ, u, HOST_OFF); } diff --git a/src/protocol/viagra.c b/src/protocol/viagra.c index d53e0a7c3..f8a465fa9 100644 --- a/src/protocol/viagra.c +++ b/src/protocol/viagra.c @@ -812,7 +812,7 @@ void viagra_cmd_topic(char *whosets, char *chan, char *whosetit, void viagra_cmd_vhost_off(User * u) { - send_cmd(NULL, "SVSMODE %s -x", u->nick); + common_svsmode(u, "-x", NULL); notice_lang(s_HostServ, u, HOST_OFF_UNREAL, u->nick, ircd->vhostchar); } diff --git a/src/users.c b/src/users.c index e8487be4b..fe098bd2e 100644 --- a/src/users.c +++ b/src/users.c @@ -224,6 +224,8 @@ void delete_user(User * user) alog("debug: delete_user(): free user data"); free(user->username); free(user->host); + if (user->chost) + free(user->chost); if (user->vhost) free(user->vhost); if (user->vident) @@ -633,6 +635,14 @@ User *do_nick(const char *source, char *nick, char *username, char *host, user->realname = sstrdup(realname); user->timestamp = ts; user->my_signon = time(NULL); + /* Initially set both the vhost and cloaked host to the users cloaked host, vhost will be changed + * later if they get a real vhost, chost however should *never* be changed to anything else. + * It is possible that on most IRCds (Unreal) a server splits and then comes back, reintroducing clients + * with a vhost (not a cloaked host) and never informing Anope about the real cloaked host. For now I'm + * leaving this open (we should prboably request a USERHOST or so) as this won't occur that much, and any + * fixes to this problem are ugly. - Adam + */ + user->chost = vhost ? sstrdup(vhost) : sstrdup(host); user->vhost = vhost ? sstrdup(vhost) : sstrdup(host); if (uid) { user->uid = sstrdup(uid); /* p10/ts6 stuff */ @@ -1002,11 +1012,13 @@ int match_usermask(const char *mask, User * user) result = match_wild_nocase(nick, user->nick) && match_wild_nocase(username, user->username) && (match_wild_nocase(host, user->host) - || match_wild_nocase(host, user->vhost)); + || match_wild_nocase(host, user->vhost) + || match_wild_nocase(host, user->chost)); } else { result = match_wild_nocase(username, user->username) && (match_wild_nocase(host, user->host) - || match_wild_nocase(host, user->vhost)); + || match_wild_nocase(host, user->vhost) + || match_wild_nocase(host, user->chost)); } free(mask2); |