]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/users.cpp
Remove /summon and /users (I think 15+ years of being marked deprecated is enough...
[user/henk/code/inspircd.git] / src / users.cpp
index de745d32575da5fc942116c8ef49104219408d69..4f5c567d253f222e49fb5dd49902eed6fa00c45f 100644 (file)
@@ -12,9 +12,6 @@
  */
 
 #include "inspircd.h"
-#include "configreader.h"
-#include "channels.h"
-#include "users.h"
 #include <stdarg.h>
 #include "socketengine.h"
 #include "wildcard.h"
@@ -351,8 +348,10 @@ userrec::userrec(InspIRCd* Instance, const std::string &uid) : ServerInstance(In
        else
                strlcpy(uuid, uid.c_str(), UUID_LENGTH);
 
+       ServerInstance->Log(DEBUG,"New UUID for user: %s (%s)", uuid, uid.empty() ? "allocated new" : "used remote");
+
        user_hash::iterator finduuid = Instance->uuidlist->find(uuid);
-       if (finduuid != Instance->uuidlist->end())
+       if (finduuid == Instance->uuidlist->end())
                (*Instance->uuidlist)[uuid] = this;
        else
                throw CoreException("Duplicate UUID "+std::string(uuid)+" in userrec constructor");
@@ -831,16 +830,9 @@ void userrec::UnOper()
                        // unset their oper type (what IS_OPER checks), and remove +o
                        *this->oper = 0;
                        this->modes[UM_OPERATOR] = 0;
-
-                       // remove them from the opers list.
-                       for (std::vector<userrec*>::iterator a = ServerInstance->all_opers.begin(); a < ServerInstance->all_opers.end(); a++)
-                       {
-                               if (*a == this)
-                               {
-                                       ServerInstance->all_opers.erase(a);
-                                       return;
-                               }
-                       }
+                       
+                       // remove the user from the oper list. Will remove multiple entries as a safeguard against bug #404
+                       ServerInstance->all_opers.remove(this);
                }
        }
 
@@ -874,7 +866,18 @@ void userrec::AddClient(InspIRCd* Instance, int socket, int port, bool iscached,
        /* NOTE: Calling this one parameter constructor for userrec automatically
         * allocates a new UUID and places it in the hash_map.
         */
-       userrec* New = new userrec(Instance);
+       userrec* New = NULL;
+       try
+       {
+               New = new userrec(Instance);
+       }
+       catch (...)
+       {
+               Instance->Log(DEFAULT,"*** WTF *** Duplicated UUID! -- Crack smoking monkies have been unleashed.");
+               Instance->WriteOpers("*** WARNING *** Duplicate UUID allocated!");
+               return;
+       }
+
        int j = 0;
 
        Instance->unregistered_count++;
@@ -1375,7 +1378,7 @@ void userrec::Write(std::string text)
 
        try
        {
-               /* ServerInstance->Log(DEBUG,"C[%d] <- %s", this->GetFd(), text.c_str());
+               /* ServerInstance->Log(DEBUG,"C[%d] O %s", this->GetFd(), text.c_str());
                 * WARNING: The above debug line is VERY loud, do NOT
                 * enable it till we have a good way of filtering it
                 * out of the logs (e.g. 1.2 would be good).