]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - src/s_user.c
[svn] Don't show the UID if a TS6 server sends a kick with
[irc/rqf/shadowircd.git] / src / s_user.c
index 1cc6d4c7c7252a5120caed2fa5b55e1862d51dc9..f4ff4b06bd50ff1eb9f5de4ebf1c5878790a34d5 100644 (file)
@@ -21,7 +21,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  *  USA
  *
- *  $Id: s_user.c 3201 2007-02-04 01:59:38Z jilles $
+ *  $Id: s_user.c 3293 2007-03-28 14:33:50Z jilles $
  */
 
 #include "stdinc.h"
@@ -65,6 +65,7 @@ extern char *crypt();
 
 char umodebuf[128];
 
+static int orphaned_umodes = 0;
 int user_modes[256] = {
        /* 0x00 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x0F */
        /* 0x10 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x1F */
@@ -414,21 +415,6 @@ register_local_user(struct Client *client_p, struct Client *source_p, const char
                return (CLIENT_EXITED);
        }
 
-       /* valid user name check */
-
-       if(!valid_username(source_p->username))
-       {
-               sendto_realops_snomask(SNO_REJ, L_ALL,
-                                    "Invalid username: %s (%s@%s)",
-                                    source_p->name, source_p->username, source_p->host);
-               ServerStats->is_ref++;
-               ircsprintf(tmpstr2, "Invalid username [%s]", source_p->username);
-               exit_client(client_p, source_p, &me, tmpstr2);
-               return (CLIENT_EXITED);
-       }
-
-       /* end of valid user name check */
-
        /* kline exemption extends to xline too */
        if(!IsExemptKline(source_p) &&
           find_xline(source_p->info, 1) != NULL)
@@ -447,7 +433,7 @@ register_local_user(struct Client *client_p, struct Client *source_p, const char
                                        source_p->sockhost, source_p->preClient->dnsbl_listed->host);
                else
                {
-                       dlink_list varlist;
+                       dlink_list varlist = { NULL, NULL, 0 };
 
                        substitution_append_var(&varlist, "nick", source_p->name);
                        substitution_append_var(&varlist, "ip", source_p->sockhost);
@@ -472,6 +458,21 @@ register_local_user(struct Client *client_p, struct Client *source_p, const char
                }
        }
 
+       /* valid user name check */
+
+       if(!valid_username(source_p->username))
+       {
+               sendto_realops_snomask(SNO_REJ, L_ALL,
+                                    "Invalid username: %s (%s@%s)",
+                                    source_p->name, source_p->username, source_p->host);
+               ServerStats->is_ref++;
+               ircsprintf(tmpstr2, "Invalid username [%s]", source_p->username);
+               exit_client(client_p, source_p, &me, tmpstr2);
+               return (CLIENT_EXITED);
+       }
+
+       /* end of valid user name check */
+
        /* Store original hostname -- jilles */
        strlcpy(source_p->orighost, source_p->host, HOSTLEN + 1);
 
@@ -520,7 +521,7 @@ register_local_user(struct Client *client_p, struct Client *source_p, const char
                add_to_id_hash(source_p->id, source_p);
        }
 
-       source_p->umodes |= ConfigFileEntry.default_umodes & ~ConfigFileEntry.oper_only_umodes;
+       source_p->umodes |= ConfigFileEntry.default_umodes & ~ConfigFileEntry.oper_only_umodes & ~orphaned_umodes;
 
        if (source_p->umodes & UMODE_INVISIBLE)
                Count.invisi++;
@@ -1055,8 +1056,9 @@ user_mode(struct Client *client_p, struct Client *source_p, int parc, const char
                        if((flag = user_modes[(unsigned char) *pm]))
                        {
                                if(MyConnect(source_p)
-                                  && !IsOper(source_p)
-                                  && (ConfigFileEntry.oper_only_umodes & flag))
+                                               && ((!IsOper(source_p)
+                                                       && (ConfigFileEntry.oper_only_umodes & flag))
+                                               || (orphaned_umodes & flag)))
                                {
                                        if (what == MODE_ADD || source_p->umodes & flag)
                                                badflag = YES;
@@ -1305,6 +1307,10 @@ oper_up(struct Client *source_p, struct oper_conf *oper_p)
        sendto_realops_snomask(SNO_GENERAL, L_ALL,
                             "%s (%s@%s) is now an operator", source_p->name,
                             source_p->username, source_p->host);
+       if(!(old & UMODE_INVISIBLE) && IsInvisible(source_p))
+               ++Count.invisi;
+       if((old & UMODE_INVISIBLE) && !IsInvisible(source_p))
+               --Count.invisi;
        send_umode_out(source_p, source_p, old);
        sendto_one(source_p, form_str(RPL_SNOMASK), me.name, source_p->name,
                   construct_snobuf(source_p->snomask));
@@ -1342,12 +1348,31 @@ construct_umodebuf(void)
 {
        int i;
        char *ptr = umodebuf;
+       static int prev_user_modes[128];
 
        *ptr = '\0';
 
        for (i = 0; i < 128; i++)
+       {
+               if (prev_user_modes[i] != 0 && prev_user_modes[i] != user_modes[i])
+               {
+                       if (user_modes[i] == 0)
+                       {
+                               orphaned_umodes |= prev_user_modes[i];
+                               sendto_realops_snomask(SNO_DEBUG, L_ALL, "Umode +%c is now orphaned", i);
+                       }
+                       else
+                       {
+                               orphaned_umodes &= ~prev_user_modes[i];
+                               sendto_realops_snomask(SNO_DEBUG, L_ALL, "Orphaned umode +%c is picked up by module", i);
+                       }
+                       user_modes[i] = prev_user_modes[i];
+               }
+               else
+                       prev_user_modes[i] = user_modes[i];
                if (user_modes[i])
                        *ptr++ = (char) i;
+       }
 
        *ptr++ = '\0';
 }
@@ -1427,8 +1452,8 @@ change_nick_user_host(struct Client *target_p,    const char *nick, const char *use
                                target_p->host, nick);
        }
 
-       strlcpy(target_p->username, user, USERLEN);
-       strlcpy(target_p->host, host, HOSTLEN);
+       strlcpy(target_p->username, user, sizeof target_p->username);
+       strlcpy(target_p->host, host, sizeof target_p->host);
 
        if (changed)
                add_history(target_p, 1);