]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Merge insp20
authorattilamolnar <attilamolnar@hush.com>
Wed, 5 Jun 2013 23:07:22 +0000 (01:07 +0200)
committerattilamolnar <attilamolnar@hush.com>
Wed, 5 Jun 2013 23:07:22 +0000 (01:07 +0200)
36 files changed:
1  2 
configure
include/command_parse.h
include/usermanager.h
make/template/main.mk
src/command_parse.cpp
src/commands/cmd_who.cpp
src/inspircd.cpp
src/listensocket.cpp
src/modes/umode_o.cpp
src/modules/extra/m_geoip.cpp
src/modules/extra/m_mysql.cpp
src/modules/extra/m_pgsql.cpp
src/modules/extra/m_ssl_gnutls.cpp
src/modules/m_alias.cpp
src/modules/m_cban.cpp
src/modules/m_channames.cpp
src/modules/m_connectban.cpp
src/modules/m_dccallow.cpp
src/modules/m_filter.cpp
src/modules/m_httpd_acl.cpp
src/modules/m_kicknorejoin.cpp
src/modules/m_nicklock.cpp
src/modules/m_operprefix.cpp
src/modules/m_passforward.cpp
src/modules/m_rline.cpp
src/modules/m_sasl.cpp
src/modules/m_shun.cpp
src/modules/m_spanningtree/main.cpp
src/modules/m_spanningtree/netburst.cpp
src/modules/m_spanningtree/utils.h
src/modules/m_svshold.cpp
src/modules/m_userip.cpp
src/usermanager.cpp
src/users.cpp
win/CMakeLists.txt
win/inspircd_win32wrapper.cpp

diff --cc configure
Simple merge
index a49fc0b6e07410732368f3f732af23d3ead98ced,f9e3a740c3012bc3e955f2b6da841600707cdde7..4a88a8ec8ca29cb0220e4b82b2809bf738a7bcdf
   */
  
  
 -#ifndef COMMAND_PARSE_H
 -#define COMMAND_PARSE_H
 +#pragma once
  
- /** A list of dll/so files containing the command handlers for the core
-  */
- typedef std::map<std::string, void*> SharedObjectList;
  /** This class handles command management and parsing.
   * It allows you to add and remove commands from the map,
   * call command handlers by name, and chop up comma seperated
@@@ -49,10 -42,8 +41,8 @@@ class CoreExport CommandParse
         * @param user The user to parse the command for
         * @param cmd The command string to process
         */
 -      bool ProcessCommand(LocalUser *user, std::string &cmd);
 +      void ProcessCommand(LocalUser* user, std::string& cmd);
  
   public:
        /** Command list, a hash_map of command names to Command*
         */
Simple merge
Simple merge
Simple merge
index c865cf67bf4a8a274f9bc0d3de0ff6931a30436f,f8926b9f7a473e1ac5835a370cb63d5a91cb5292..82d541a2a7829802df5728fb237b06aa934755a1
@@@ -252,11 -252,24 +252,11 @@@ CmdResult CommandWho::Handle (const std
        std::vector<std::string> whoresults;
        std::string initial = "352 " + user->nick + " ";
  
 -      char matchtext[MAXBUF];
 -      bool usingwildcards = false;
 -
        /* Change '0' into '*' so the wildcard matcher can grok it */
 -      if (parameters[0] == "0")
 -              strlcpy(matchtext, "*", MAXBUF);
 -      else
 -              strlcpy(matchtext, parameters[0].c_str(), MAXBUF);
 +      std::string matchtext = ((parameters[0] == "0") ? "*" : parameters[0]);
  
 -      for (const char* check = matchtext; *check; check++)
 -      {
 -              if (*check == '*' || *check == '?' || *check == '.')
 -              {
 -                      usingwildcards = true;
 -                      break;
 -              }
 -      }
 +      // WHO flags count as a wildcard
-       bool usingwildcards = ((parameters.size() > 1) || (matchtext.find_first_of("*?") != std::string::npos));
++      bool usingwildcards = ((parameters.size() > 1) || (matchtext.find_first_of("*?.") != std::string::npos));
  
        if (parameters.size() > 1)
        {
index fe33045692ede0004cedd1c8fcdb33cb94f2c6ab,1403cdef5a5805b10b22c08810839a22cc8a58af..0e4a6646fcd921af9b86cfbfea52d1a53c0ce9bb
@@@ -449,7 -509,8 +447,8 @@@ InspIRCd::InspIRCd(int argc, char** arg
        std::cout << con_green << "(C) InspIRCd Development Team." << con_reset << std::endl << std::endl;
        std::cout << "Developers:" << std::endl;
        std::cout << con_green << "\tBrain, FrostyCoolSlug, w00t, Om, Special, peavey" << std::endl;
-       std::cout << "\taquanight, psychon, dz, danieldg, jackmcbarn" << con_reset << std::endl << std::endl;
 -      std::cout << "\taquanight, psychon, dz, danieldg, jackmcbarn" << std::endl;\r
++      std::cout << "\taquanight, psychon, dz, danieldg, jackmcbarn" << std::endl;
+       std::cout << "\tAttila" << con_reset << std::endl << std::endl;
        std::cout << "Others:\t\t\t" << con_green << "See /INFO Output" << con_reset << std::endl;
  
        this->Modes = new ModeParser;
index f875bc6465c2c262a6bbbb6bd4a5f97d414717eb,ae11c3b48238b3155cfb2b52c9de0f2dac97ecb2..20cbe51ac8d21098182e4b0d8ec85cee990f3433
@@@ -42,35 -56,6 +60,19 @@@ ListenSocket::ListenSocket(ConfigTag* t
        if (rv >= 0)
                rv = ServerInstance->SE->Listen(this->fd, ServerInstance->Config->MaxConn);
  
- #ifdef IPV6_V6ONLY
-       /* This OS supports IPv6 sockets that can also listen for IPv4
-        * connections. If our address is "*" or empty, enable both v4 and v6 to
-        * allow for simpler configuration on dual-stack hosts. Otherwise, if it
-        * is "::" or an IPv6 address, disable support so that an IPv4 bind will
-        * work on the port (by us or another application).
-        */
-       if (bind_to.sa.sa_family == AF_INET6)
-       {
-               std::string addr = tag->getString("address");
-               const char enable = (addr.empty() || addr == "*") ? 0 : 1;
-               setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &enable, sizeof(enable));
-               // errors ignored intentionally
-       }
- #endif
 +      int timeout = tag->getInt("defer", 0);
 +      if (timeout && !rv)
 +      {
 +#ifdef USE_TCP_DEFER_ACCEPT
 +              setsockopt(fd, IPPROTO_TCP, TCP_DEFER_ACCEPT, &timeout, sizeof(timeout));
 +#elif defined USE_SO_ACCEPTFILTER
 +              struct accept_filter_arg afa;
 +              memset(&afa, 0, sizeof(afa));
 +              strcpy(afa.af_name, "dataready");
 +              setsockopt(fd, SOL_SOCKET, SO_ACCEPTFILTER, &afa, sizeof(afa));
 +#endif
 +      }
 +
        if (rv < 0)
        {
                int errstore = errno;
index de00d7f73a43ff455ded73641addebf0266e2942,a5f590ba03dc03c8091a276c326fe2431c6f8bd3..45b99b1d6d0ac6fc9686fcd5786cb92f64967aad
@@@ -32,7 -32,7 +32,7 @@@ ModeUserOperator::ModeUserOperator() : 
  ModeAction ModeUserOperator::OnModeChange(User* source, User* dest, Channel*, std::string&, bool adding)
  {
        /* Only opers can execute this class at all */
-       if (!ServerInstance->ULine(source->nick.c_str()) && !ServerInstance->ULine(source->server) && !source->IsOper())
 -      if (!ServerInstance->ULine(source->server) && !IS_OPER(source))
++      if (!ServerInstance->ULine(source->server) && !source->IsOper())
                return MODEACTION_DENY;
  
        /* Not even opers can GIVE the +o mode, only take it away */
index 7696146e8466443459b986590c3be7d3f27c4f7f,a36c39bc83cd3e6d078d311b4a11313df543a44f..ddc4e9a38a1ca74002a5d14ab5ff2e33377a63ea
@@@ -35,9 -35,9 +35,9 @@@ class ModuleGeoIP : public Modul
        LocalStringExt ext;
        GeoIP* gi;
  
-       void SetExt(LocalUser* user)
+       std::string* SetExt(LocalUser* user)
        {
 -              const char* c = GeoIP_country_code_by_addr(gi, user->GetIPString());
 +              const char* c = GeoIP_country_code_by_addr(gi, user->GetIPString().c_str());
                if (!c)
                        c = "UNK";
  
Simple merge
index 3df6b91bd098c35dce269899e0ab1c88dedab9ea,ac247548ac35c303a805734c483f112bb0c3f3f5..61e8d5bbbec974e5d6eb64377f2ab46516beccc9
@@@ -412,16 -412,16 +412,16 @@@ restart
                                if (param < p.size())
                                {
                                        std::string parm = p[param++];
-                                       char buffer[MAXBUF];
+                                       std::vector<char> buffer(parm.length() * 2 + 1);
  #ifdef PGSQL_HAS_ESCAPECONN
                                        int error;
-                                       PQescapeStringConn(sql, buffer, parm.c_str(), parm.length(), &error);
+                                       size_t escapedsize = PQescapeStringConn(sql, &buffer[0], parm.data(), parm.length(), &error);
                                        if (error)
 -                                              ServerInstance->Logs->Log("m_pgsql", DEBUG, "BUG: Apparently PQescapeStringConn() failed");
 +                                              ServerInstance->Logs->Log("m_pgsql", LOG_DEBUG, "BUG: Apparently PQescapeStringConn() failed");
  #else
-                                       PQescapeString         (buffer, parm.c_str(), parm.length());
+                                       size_t escapedsize = PQescapeString(&buffer[0], parm.data(), parm.length());
  #endif
-                                       res.append(buffer);
+                                       res.append(&buffer[0], escapedsize);
                                }
                        }
                }
                                if (it != p.end())
                                {
                                        std::string parm = it->second;
-                                       char buffer[MAXBUF];
+                                       std::vector<char> buffer(parm.length() * 2 + 1);
  #ifdef PGSQL_HAS_ESCAPECONN
                                        int error;
-                                       PQescapeStringConn(sql, buffer, parm.c_str(), parm.length(), &error);
+                                       size_t escapedsize = PQescapeStringConn(sql, &buffer[0], parm.data(), parm.length(), &error);
                                        if (error)
 -                                              ServerInstance->Logs->Log("m_pgsql", DEBUG, "BUG: Apparently PQescapeStringConn() failed");
 +                                              ServerInstance->Logs->Log("m_pgsql", LOG_DEBUG, "BUG: Apparently PQescapeStringConn() failed");
  #else
-                                       PQescapeString         (buffer, parm.c_str(), parm.length());
+                                       size_t escapedsize = PQescapeString(&buffer[0], parm.data(), parm.length());
  #endif
-                                       res.append(buffer);
+                                       res.append(&buffer[0], escapedsize);
                                }
                        }
                }
index 0659f631cfaee38a2860f1fd9f54c6b8b2a1c194,41e9d0c3d01905dfbc48eff1c8322acae40a0200..8faee2da7b710e6708ccf43f256020f73cbc9ea3
@@@ -213,7 -175,72 +175,71 @@@ class ModuleSSLGnuTLS : public Modul
                return str ? str : "UNKNOWN";
        }
  
+       static ssize_t gnutls_pull_wrapper(gnutls_transport_ptr_t session_wrap, void* buffer, size_t size)
+       {
+               issl_session* session = reinterpret_cast<issl_session*>(session_wrap);
+               if (session->socket->GetEventMask() & FD_READ_WILL_BLOCK)
+               {
+ #ifdef _WIN32
+                       gnutls_transport_set_errno(session->sess, EAGAIN);
+ #else
+                       errno = EAGAIN;
+ #endif
+                       return -1;
+               }
+               int rv = ServerInstance->SE->Recv(session->socket, reinterpret_cast<char *>(buffer), size, 0);
+ #ifdef _WIN32
+               if (rv < 0)
+               {
+                       /* Windows doesn't use errno, but gnutls does, so check SocketEngine::IgnoreError()
+                        * and then set errno appropriately.
+                        * The gnutls library may also have a different errno variable than us, see
+                        * gnutls_transport_set_errno(3).
+                        */
+                       gnutls_transport_set_errno(session->sess, SocketEngine::IgnoreError() ? EAGAIN : errno);
+               }
+ #endif
+               if (rv < (int)size)
+                       ServerInstance->SE->ChangeEventMask(session->socket, FD_READ_WILL_BLOCK);
+               return rv;
+       }
+       static ssize_t gnutls_push_wrapper(gnutls_transport_ptr_t session_wrap, const void* buffer, size_t size)
+       {
+               issl_session* session = reinterpret_cast<issl_session*>(session_wrap);
+               if (session->socket->GetEventMask() & FD_WRITE_WILL_BLOCK)
+               {
+ #ifdef _WIN32
+                       gnutls_transport_set_errno(session->sess, EAGAIN);
+ #else
+                       errno = EAGAIN;
+ #endif
+                       return -1;
+               }
+               int rv = ServerInstance->SE->Send(session->socket, reinterpret_cast<const char *>(buffer), size, 0);
+ #ifdef _WIN32
+               if (rv < 0)
+               {
+                       /* Windows doesn't use errno, but gnutls does, so check SocketEngine::IgnoreError()
+                        * and then set errno appropriately.
+                        * The gnutls library may also have a different errno variable than us, see
+                        * gnutls_transport_set_errno(3).
+                        */
+                       gnutls_transport_set_errno(session->sess, SocketEngine::IgnoreError() ? EAGAIN : errno);
+               }
+ #endif
+               if (rv < (int)size)
+                       ServerInstance->SE->ChangeEventMask(session->socket, FD_WRITE_WILL_BLOCK);
+               return rv;
+       }
   public:
 -
        ModuleSSLGnuTLS()
                : starttls(this), capHandler(this, "tls"), iohook(this, "ssl/gnutls", SERVICE_IOHOOK)
        {
Simple merge
index 5e629ed42ffc70763a9d6d111fcad712a3f24271,fb78e41b29cb45f9dede6dc908c219e94060c203..7dedb74415c214ff3511337b1dfcad3a553d27bb
   */
  class CBan : public XLine
  {
 -public:
 +private:
 +      std::string displaytext;
        irc::string matchtext;
  
-       CBan(time_t s_time, long d, std::string src, std::string re, std::string ch)
 +public:
+       CBan(time_t s_time, long d, const std::string& src, const std::string& re, const std::string& ch)
                : XLine(s_time, d, src, re, "CBAN")
        {
 +              this->displaytext = ch;
                this->matchtext = ch.c_str();
        }
  
Simple merge
Simple merge
index 5061cf250039a568a84c73c0e12fb06a8496e280,de7b6b7bfbab993e8c0e1c70da7fa8ad27e8d4d5..1024c4ab27911df71bfba3126f1d5bc8309d63e8
@@@ -163,10 -163,10 +163,10 @@@ class CommandDccallow : public Comman
                                        }
                                        else
                                        {
 -                                              length = ServerInstance->Duration(parameters[1]);
 +                                              length = InspIRCd::Duration(parameters[1]);
                                        }
  
-                                       if (!ServerInstance->IsValidMask(mask.c_str()))
+                                       if (!ServerInstance->IsValidMask(mask))
                                        {
                                                return CMD_FAILURE;
                                        }
Simple merge
index 982e514ade8651bf34abb07d1ce85986c5e0c1c4,c25cabc0ae5eb40cc135ed4acf268718ca835914..061d56f254ec5082657e5daa75c71f073f3d1b45
@@@ -45,7 -48,8 +45,7 @@@ class ModuleHTTPAccessList : public Mod
        std::vector<HTTPACL> acl_list;
  
   public:
-       void ReadConfig()
 -
+       void OnRehash(User* user)
        {
                acl_list.clear();
                ConfigTagList acls = ServerInstance->Config->ConfTags("httpdacl");
                }
        }
  
 -      void init()
 +      void init() CXX11_OVERRIDE
        {
-               ReadConfig();
-               Implementation eventlist[] = { I_OnEvent };
+               OnRehash(NULL);
+               Implementation eventlist[] = { I_OnEvent, I_OnRehash };
                ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
        }
  
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
index 6da24208ab1d7dcf4dfc3ca7a1a9ad9d8754611e,8bf4d30e7bf341d4d6ce773bc7c1734455bb586e..a06149b62d2c13cae70df5721664a6c9daed4eeb
@@@ -30,12 -30,16 +30,12 @@@ class Shun : public XLin
  public:
        std::string matchtext;
  
-       Shun(time_t s_time, long d, std::string src, std::string re, std::string shunmask)
+       Shun(time_t s_time, long d, const std::string& src, const std::string& re, const std::string& shunmask)
                : XLine(s_time, d, src, re, "SHUN")
+               , matchtext(shunmask)
        {
-               this->matchtext = shunmask;
        }
  
 -      ~Shun()
 -      {
 -      }
 -
        bool Matches(User *u)
        {
                // E: overrides shun
Simple merge
Simple merge
index d35d5f3ba494964d3828d9578cd8a0e63c8f69b8,d8176043e8929244fa3b9f80066a0f285170867c..a53298126646c48b5c4f55c4a8a75b68f7a61ce7
  class SVSHold : public XLine
  {
  public:
 -      irc::string nickname;
 +      std::string nickname;
  
-       SVSHold(time_t s_time, long d, std::string src, std::string re, std::string nick)
+       SVSHold(time_t s_time, long d, const std::string& src, const std::string& re, const std::string& nick)
                : XLine(s_time, d, src, re, "SVSHOLD")
        {
 -              this->nickname = nick.c_str();
 -      }
 -
 -      ~SVSHold()
 -      {
 +              this->nickname = nick;
        }
  
        bool Matches(User *u)
index 7cc2fa04d7bf2d3f28e776678855507b7cfdc694,bfac36b1a5ce2534e0a1c6a5a5b48ba616f63669..670e9a9d7a7c9a6f25634c5dd3f8f3fa6b22dd2e
@@@ -43,8 -45,24 +45,24 @@@ class CommandUserip : public Comman
                        User *u = ServerInstance->FindNick(parameters[i]);
                        if ((u) && (u->registered == REG_ALL))
                        {
 -                              retbuf = retbuf + u->nick + (IS_OPER(u) ? "*" : "") + "=";
 -                              if (IS_AWAY(u))
+                               // Anyone may query their own IP
+                               if (u != user)
+                               {
+                                       if (!checked_privs)
+                                       {
+                                               // Do not trigger the insufficient priviliges message more than once
+                                               checked_privs = true;
+                                               has_privs = user->HasPrivPermission("users/auspex");
+                                               if (!has_privs)
+                                                       user->WriteNumeric(ERR_NOPRIVILEGES, "%s :Permission Denied - You do not have the required operator privileges",user->nick.c_str());
+                                       }
+                                       if (!has_privs)
+                                               continue;
+                               }
 +                              retbuf = retbuf + u->nick + (u->IsOper() ? "*" : "") + "=";
 +                              if (u->IsAway())
                                        retbuf += "-";
                                else
                                        retbuf += "+";
Simple merge
diff --cc src/users.cpp
index 49c5c5e42e32ff8d49f30985149e4a4dd3bb36ea,2305ba8ce333cf0cf374b67e49df18abaf46c0b6..44834330b1e654d450e821686dec2983d89f57c0
@@@ -506,9 -545,12 +506,12 @@@ CullResult LocalUser::cull(
        // overwritten in UserManager::AddUser() with the real iterator so this check
        // is only a precaution currently.
        if (localuseriter != ServerInstance->Users->local_users.end())
+       {
+               ServerInstance->Users->local_count--;
                ServerInstance->Users->local_users.erase(localuseriter);
+       }
        else
 -              ServerInstance->Logs->Log("USERS", DEFAULT, "ERROR: LocalUserIter does not point to a valid entry for " + this->nick);
 +              ServerInstance->Logs->Log("USERS", LOG_DEFAULT, "ERROR: LocalUserIter does not point to a valid entry for " + this->nick);
  
        ClearInvites();
        eh.cull();
Simple merge
index 7a07868f90907fe3f545901731163445e72d9dd1,4592aa5d17c2b27eee0f6e86adc3891b5cbf4be9..2836674bbdf9e70f1f38c1e98f856011db3899bd
@@@ -56,18 -55,38 +56,38 @@@ CoreExport const char *insp_inet_ntop(i
  
  CoreExport int insp_inet_pton(int af, const char *src, void *dst)
  {
-       sockaddr_in sa;
-       int len = sizeof(SOCKADDR);
-       int rv = WSAStringToAddressA((LPSTR)src, af, NULL, (LPSOCKADDR)&sa, &len);
-       if(rv >= 0)
+       int address_length;
+       sockaddr_storage sa;
+       sockaddr_in* sin = reinterpret_cast<sockaddr_in*>(&sa);
+       sockaddr_in6* sin6 = reinterpret_cast<sockaddr_in6*>(&sa);
+       switch (af)
        {
-               if(WSAGetLastError() == WSAEINVAL)
-                       rv = 0;
-               else
-                       rv = 1;
+               case AF_INET:
+                       address_length = sizeof(sockaddr_in);
+                       break;
+               case AF_INET6:
+                       address_length = sizeof(sockaddr_in6);
+                       break;
+               default:
+                       return -1;
        }
-       memcpy(dst, &sa.sin_addr, sizeof(struct in_addr));
-       return rv;
+       if (!WSAStringToAddress(static_cast<LPSTR>(const_cast<char *>(src)), af, NULL, reinterpret_cast<LPSOCKADDR>(&sa), &address_length))
+       {
+               switch (af)
+               {
+                       case AF_INET:
+                               memcpy(dst, &sin->sin_addr, sizeof(in_addr));
+                               break;
+                       case AF_INET6:
+                               memcpy(dst, &sin6->sin6_addr, sizeof(in6_addr));
+                               break;
+               }
+               return 1;
+       }
 -      
++
+       return 0;
  }
  
  CoreExport DIR * opendir(const char * path)
@@@ -144,7 -163,7 +164,7 @@@ int getopt_long(int ___argc, char *cons
  //                                    optind++;               // Trash this next argument, we won't be needing it.
                                        par = ___argv[optind-1];
                                }
--                      }                       
++                      }
  
                        // increment the argument for next time
  //                    optind++;
                        {
                                if (__longopts[i].val == -1 || par == 0)
                                        return 1;
--                              
++
                                return __longopts[i].val;
--                      }                       
++                      }
                        break;
                }
        }