From dae6f5dbeea06085925586be1ea25c2bb1d59611 Mon Sep 17 00:00:00 2001 From: Stephen Bennett Date: Tue, 2 Feb 2010 21:31:50 +0000 Subject: [PATCH] Make sasl_usercloak.so update the original host, as well as the visible host if it hasn't already changed. Allows for the sasl spoof to be used to override services ones in some circumstances. --- extensions/sasl_usercloak.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/extensions/sasl_usercloak.c b/extensions/sasl_usercloak.c index d627b200..446bafed 100644 --- a/extensions/sasl_usercloak.c +++ b/extensions/sasl_usercloak.c @@ -44,7 +44,7 @@ check_new_user(void *vdata) if (EmptyString(source_p->user->suser)) return; - char *accountpart = strstr(source_p->host, "account"); + char *accountpart = strstr(source_p->orighost, "account"); if (!accountpart) return; @@ -52,8 +52,8 @@ check_new_user(void *vdata) memset(buf, 0, sizeof(buf)); char *dst = buf; - strncpy(buf, source_p->host, accountpart - source_p->host); - dst += accountpart - source_p->host; + strncpy(buf, source_p->orighost, accountpart - source_p->orighost); + dst += accountpart - source_p->orighost; int needhash = 0; @@ -64,7 +64,7 @@ check_new_user(void *vdata) /* Doesn't fit. Warn opers and bail. */ sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "Couldn't fit account name part %s in hostname for %s!%s@%s", - source_p->user->suser, source_p->name, source_p->username, source_p->host); + source_p->user->suser, source_p->name, source_p->username, source_p->orighost); return; } @@ -83,7 +83,7 @@ check_new_user(void *vdata) /* Doesn't fit. Warn opers and bail. */ sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "Couldn't fit account name part %s in hostname for %s!%s@%s", - source_p->user->suser, source_p->name, source_p->user, source_p->host); + source_p->user->suser, source_p->name, source_p->username, source_p->orighost); return; } @@ -99,5 +99,10 @@ check_new_user(void *vdata) /* just in case */ buf[HOSTLEN-1] = '\0'; - change_nick_user_host(source_p, source_p->name, source_p->username, buf, 0, "Changing host"); + /* If hostname has been changed already (probably by services cloak on SASL login), then + * leave it intact. If not, change it. In either case, update the original hostname. + */ + if (0 == irccmp(source_p->host, source_p->orighost)) + change_nick_user_host(source_p, source_p->name, source_p->username, buf, 0, "Changing host"); + strncpy(source_p->orighost, buf, HOSTLEN); }