]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/users.cpp
Decide that it wasn't quite appropriate :(
[user/henk/code/inspircd.git] / src / users.cpp
index 8089f5c235fc0e4bc9959dc114dcca8189319d01..3acc8f2a0cc2bc1c8009b21f9d3a5b28ee5f5d48 100644 (file)
@@ -64,7 +64,7 @@ template<typename T> inline string ConvToStr(const T &in)
 userrec::userrec()
 {
        // the PROPER way to do it, AVOID bzero at *ALL* costs
-       *nick = *ident = *host = *dhost = *fullname = *modes = *awaymsg = *oper = 0;
+       *password = *nick = *ident = *host = *dhost = *fullname = *modes = *awaymsg = *oper = 0;
        server = (char*)FindServerNamePtr(Config->ServerName);
        reset_due = TIME;
        lines_in = fd = lastping = signon = idle_lastmsg = nping = registered = 0;
@@ -211,7 +211,7 @@ bool userrec::HasPermission(std::string &command)
                return true;
        
        // are they even an oper at all?
-       if (strchr(this->modes,'o'))
+       if (*this->oper)
        {
                for (int j =0; j < Config->ConfValueEnum("type",&Config->config_f); j++)
                {
@@ -276,7 +276,8 @@ bool userrec::AddBuffer(std::string a)
 
 bool userrec::BufferIsReady()
 {
-        for (unsigned int i = 0; i < recvq.length(); i++)
+       unsigned int t = recvq.length();
+        for (unsigned int i = 0; i < t; i++)
                if (recvq[i] == '\n')
                        return true;
         return false;
@@ -293,7 +294,7 @@ std::string userrec::GetBuffer()
                return "";
         char* line = (char*)recvq.c_str();
         std::string ret = "";
-        while ((*line != '\n') && (strlen(line)))
+        while ((*line != '\n') && (*line))
         {
                 ret = ret + *line;
                 line++;
@@ -396,6 +397,7 @@ void kill_link(userrec *user,const char* r)
         log(DEBUG,"closing fd %lu",(unsigned long)user->fd);
 
         if (user->registered == 7) {
+               purge_empty_chans(user);
                 FOREACH_MOD(I_OnUserQuit,OnUserQuit(user,reason));
                 WriteCommonExcept(user,"QUIT :%s",reason);
         }
@@ -408,7 +410,14 @@ void kill_link(userrec *user,const char* r)
         {
                if (Config->GetIOHook(user->port))
                {
-                       Config->GetIOHook(user->port)->OnRawSocketClose(user->fd);
+                       try
+                       {
+                               Config->GetIOHook(user->port)->OnRawSocketClose(user->fd);
+                       }
+                        catch (ModuleException& modexcept)
+                        {
+                                log(DEBUG,"Module exception cought: %s",modexcept.GetReason()); \
+                        }
                }
                 ServerInstance->SE->DelFd(user->fd);
                 user->CloseSocket();
@@ -417,7 +426,6 @@ void kill_link(userrec *user,const char* r)
         // this must come before the WriteOpers so that it doesnt try to fill their buffer with anything
         // if they were an oper with +s.
         if (user->registered == 7) {
-                purge_empty_chans(user);
                 // fix by brain: only show local quits because we only show local connects (it just makes SENSE)
                 if (user->fd > -1)
                         WriteOpers("*** Client exiting: %s!%s@%s [%s]",user->nick,user->ident,user->host,reason);
@@ -471,7 +479,14 @@ void kill_link_silent(userrec *user,const char* r)
         {
                if (Config->GetIOHook(user->port))
                {
-                       Config->GetIOHook(user->port)->OnRawSocketClose(user->fd);
+                       try
+                       {
+                               Config->GetIOHook(user->port)->OnRawSocketClose(user->fd);
+                       }
+                        catch (ModuleException& modexcept)
+                        {
+                                log(DEBUG,"Module exception cought: %s",modexcept.GetReason()); \
+                        }
                }
                 ServerInstance->SE->DelFd(user->fd);
                 user->CloseSocket();
@@ -504,7 +519,7 @@ void AddWhoWas(userrec* u)
 {
         whowas_hash::iterator iter = whowas.find(u->nick);
         WhoWasUser *a = new WhoWasUser();
-        strlcpy(a->nick,u->nick,NICKMAX);
+        strlcpy(a->nick,u->nick,NICKMAX-1);
         strlcpy(a->ident,u->ident,IDENTMAX);
         strlcpy(a->dhost,u->dhost,160);
         strlcpy(a->host,u->host,160);
@@ -593,7 +608,7 @@ void AddClient(int socket, int port, bool iscached, in_addr ip4)
         log(DEBUG,"AddClient: %d %d %s",socket,port,ipaddr);
 
         clientlist[tempnick]->fd = socket;
-        strlcpy(clientlist[tempnick]->nick, tn2,NICKMAX);
+        strlcpy(clientlist[tempnick]->nick, tn2,NICKMAX-1);
        /* We don't know the host yet, dns lookup could still be going on,
         * so instead we just put the ip address here, for now.
         */
@@ -728,11 +743,13 @@ void FullConnectUser(userrec* user, CullList* Goners)
        if (FindMatchingLocal(user) > a.maxlocal)
        {
                Goners->AddItem(user,"No more connections allowed from your host via this connect class (local)");
+               WriteOpers("*** WARNING: maximum LOCAL connections (%ld) exceeded for IP %s",a.maxlocal,(char*)inet_ntoa(user->ip4));
                return;
        }
-       if (FindMatchingGlobal(user) > a.maxglobal)
+       else if (FindMatchingGlobal(user) > a.maxglobal)
        {
                Goners->AddItem(user,"No more connections allowed from your host via this connect class (global)");
+               WriteOpers("*** WARNING: maximum GLOBAL connections (%ld) exceeded for IP %s",a.maxglobal,(char*)inet_ntoa(user->ip4));
                return;
        }