]> jfr.im git - solanum.git/blobdiff - src/s_user.c
charybdis 3.5.0.
[solanum.git] / src / s_user.c
index 2d7705dc25f20a497453a2abaae2fb2985894d8d..77577bf18604c8fc6aa237217511b0b23a59d4ca 100644 (file)
@@ -219,7 +219,7 @@ show_lusers(struct Client *source_p)
 */
 
 int
-register_local_user(struct Client *client_p, struct Client *source_p, const char *username)
+register_local_user(struct Client *client_p, struct Client *source_p)
 {
        struct ConfItem *aconf, *xconf;
        struct User *user = source_p->user;
@@ -230,7 +230,6 @@ register_local_user(struct Client *client_p, struct Client *source_p, const char
 
        s_assert(NULL != source_p);
        s_assert(MyConnect(source_p));
-       s_assert(source_p->username != username);
 
        if(source_p == NULL)
                return -1;
@@ -265,12 +264,12 @@ register_local_user(struct Client *client_p, struct Client *source_p, const char
        client_p->localClient->last = rb_current_time();
 
        /* XXX - fixme. we shouldnt have to build a users buffer twice.. */
-       if(!IsGotId(source_p) && (strchr(username, '[') != NULL))
+       if(!IsGotId(source_p) && (strchr(source_p->username, '[') != NULL))
        {
                const char *p;
                int i = 0;
 
-               p = username;
+               p = source_p->username;
 
                while(*p && i < USERLEN)
                {
@@ -280,10 +279,11 @@ register_local_user(struct Client *client_p, struct Client *source_p, const char
                }
 
                myusername[i] = '\0';
-               username = myusername;
        }
+       else
+               rb_strlcpy(myusername, source_p->username, sizeof myusername);
 
-       if((status = check_client(client_p, source_p, username)) < 0)
+       if((status = check_client(client_p, source_p, myusername)) < 0)
                return (CLIENT_EXITED);
 
        /* Apply nick override */
@@ -339,7 +339,7 @@ register_local_user(struct Client *client_p, struct Client *source_p, const char
                /* dont replace username if its supposed to be spoofed --fl */
                if(!IsConfDoSpoofIp(aconf) || !strchr(aconf->info.name, '@'))
                {
-                       p = username;
+                       p = myusername;
 
                        if(!IsNoTilde(aconf))
                                source_p->username[i++] = '~';
@@ -597,12 +597,11 @@ introduce_client(struct Client *client_p, struct Client *source_p, struct User *
        char *p;
        hook_data_umode_changed hdata;
        hook_data_client hdata2;
-       char sockhost[HOSTLEN];
 
        if(MyClient(source_p))
-               send_umode(source_p, source_p, 0, 0, ubuf);
+               send_umode(source_p, source_p, 0, ubuf);
        else
-               send_umode(NULL, source_p, 0, 0, ubuf);
+               send_umode(NULL, source_p, 0, ubuf);
 
        if(!*ubuf)
        {
@@ -612,14 +611,6 @@ introduce_client(struct Client *client_p, struct Client *source_p, struct User *
 
        s_assert(has_id(source_p));
 
-       if(source_p->sockhost[0] == ':')
-       {
-               sockhost[0] = '0';
-               sockhost[1] = '\0';
-               rb_strlcat(sockhost, source_p->sockhost, sizeof(sockhost));
-       } else
-               strcpy(sockhost, source_p->sockhost);
-
        if (use_euid)
                sendto_server(client_p, NULL, CAP_EUID | CAP_TS6, NOCAPS,
                                ":%s EUID %s %d %ld %s %s %s %s %s %s %s :%s",
@@ -627,7 +618,7 @@ introduce_client(struct Client *client_p, struct Client *source_p, struct User *
                                source_p->hopcount + 1,
                                (long) source_p->tsinfo, ubuf,
                                source_p->username, source_p->host,
-                               IsIPSpoof(source_p) ? "0" : sockhost,
+                               IsIPSpoof(source_p) ? "0" : source_p->sockhost,
                                source_p->id,
                                IsDynSpoof(source_p) ? source_p->orighost : "*",
                                EmptyString(source_p->user->suser) ? "*" : source_p->user->suser,
@@ -639,7 +630,7 @@ introduce_client(struct Client *client_p, struct Client *source_p, struct User *
                      source_p->hopcount + 1,
                      (long) source_p->tsinfo, ubuf,
                      source_p->username, source_p->host,
-                     IsIPSpoof(source_p) ? "0" : sockhost,
+                     IsIPSpoof(source_p) ? "0" : source_p->sockhost,
                      source_p->id, source_p->info);
 
        if(!EmptyString(source_p->certfp))
@@ -734,6 +725,9 @@ valid_hostname(const char *hostname)
        if(hostname == NULL)
                return NO;
 
+       if(!strcmp(hostname, "localhost"))
+               return YES;
+
        if('.' == *p || ':' == *p || '/' == *p)
                return NO;
 
@@ -1161,7 +1155,7 @@ user_mode(struct Client *client_p, struct Client *source_p, int parc, const char
  * -avalon
  */
 void
-send_umode(struct Client *client_p, struct Client *source_p, int old, int sendmask, char *umode_buf)
+send_umode(struct Client *client_p, struct Client *source_p, int old, char *umode_buf)
 {
        int i;
        int flag;
@@ -1222,7 +1216,7 @@ send_umode_out(struct Client *client_p, struct Client *source_p, int old)
        char buf[BUFSIZE];
        rb_dlink_node *ptr;
 
-       send_umode(NULL, source_p, old, 0, buf);
+       send_umode(NULL, source_p, old, buf);
 
        RB_DLINK_FOREACH(ptr, serv_list.head)
        {
@@ -1237,7 +1231,7 @@ send_umode_out(struct Client *client_p, struct Client *source_p, int old)
        }
 
        if(client_p && MyClient(client_p))
-               send_umode(client_p, source_p, old, 0, buf);
+               send_umode(client_p, source_p, old, buf);
 }
 
 /*
@@ -1437,7 +1431,7 @@ change_nick_user_host(struct Client *target_p,    const char *nick, const char *use
                vsnprintf(reason, 255, format, ap);
                va_end(ap);
 
-               sendto_common_channels_local_butone(target_p, NOCAPS, ":%s!%s@%s QUIT :%s",
+               sendto_common_channels_local_butone(target_p, NOCAPS, CLICAP_CHGHOST, ":%s!%s@%s QUIT :%s",
                                target_p->name, target_p->username, target_p->host,
                                reason);
 
@@ -1462,9 +1456,9 @@ change_nick_user_host(struct Client *target_p,    const char *nick, const char *use
 
                        *mptr = '\0';
 
-                       sendto_channel_local_with_capability_butone(target_p, ALL_MEMBERS, NOCAPS, CLICAP_EXTENDED_JOIN, chptr,
+                       sendto_channel_local_with_capability_butone(target_p, ALL_MEMBERS, NOCAPS, CLICAP_EXTENDED_JOIN | CLICAP_CHGHOST, chptr,
                                                                    ":%s!%s@%s JOIN %s", nick, user, host, chptr->chname);
-                       sendto_channel_local_with_capability_butone(target_p, ALL_MEMBERS, CLICAP_EXTENDED_JOIN, NOCAPS, chptr,
+                       sendto_channel_local_with_capability_butone(target_p, ALL_MEMBERS, CLICAP_EXTENDED_JOIN, CLICAP_CHGHOST, chptr,
                                                                    ":%s!%s@%s JOIN %s %s :%s", nick, user, host, chptr->chname,
                                                                    EmptyString(target_p->user->suser) ? "*" : target_p->user->suser,
                                                                    target_p->info);
@@ -1480,21 +1474,24 @@ change_nick_user_host(struct Client *target_p,  const char *nick, const char *use
 
                /* Resend away message to away-notify enabled clients. */
                if (target_p->user->away)
-                       sendto_common_channels_local_butone(target_p, CLICAP_AWAY_NOTIFY, ":%s!%s@%s AWAY :%s",
-                                                           target_p->name, target_p->username, target_p->host,
+                       sendto_common_channels_local_butone(target_p, CLICAP_AWAY_NOTIFY, CLICAP_CHGHOST, ":%s!%s@%s AWAY :%s",
+                                                           nick, user, host,
                                                            target_p->user->away);
 
+               sendto_common_channels_local_butone(target_p, CLICAP_CHGHOST, NOCAPS,
+                                                   ":%s!%s@%s CHGHOST %s %s",
+                                                   target_p->name, target_p->username, target_p->host, user, host);
+
                if(MyClient(target_p) && changed_case)
                        sendto_one(target_p, ":%s!%s@%s NICK %s",
-                                       target_p->name, target_p->username, target_p->host, nick);
+                                       target_p->name, user, host, nick);
 
                /* TODO: send some snotes to SNO_NCHANGE/SNO_CCONN/SNO_CCONNEXT? */
        }
        else if(changed_case)
        {
-               sendto_common_channels_local(target_p, NOCAPS, ":%s!%s@%s NICK :%s",
-                               target_p->name, target_p->username,
-                               target_p->host, nick);
+               sendto_common_channels_local(target_p, NOCAPS, NOCAPS, ":%s!%s@%s NICK :%s",
+                               target_p->name, user, host, nick);
 
                if(MyConnect(target_p))
                        sendto_realops_snomask(SNO_NCHANGE, L_ALL,