diff options
Diffstat (limited to 'src')
39 files changed, 114 insertions, 83 deletions
diff --git a/src/channels.cpp b/src/channels.cpp index 8e7d4af06..0b8945aca 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -804,7 +804,6 @@ void Channel::UserList(User *user) dlen = curlen = snprintf(list,MAXBUF,"%s %c %s :", user->nick.c_str(), this->IsModeSet('s') ? '@' : this->IsModeSet('p') ? '*' : '=', this->name.c_str()); ptr = list + dlen; - ptrlen = 0; numusers = 0; } diff --git a/src/commands/cmd_away.cpp b/src/commands/cmd_away.cpp index e3bfbe55e..aafabba28 100644 --- a/src/commands/cmd_away.cpp +++ b/src/commands/cmd_away.cpp @@ -13,8 +13,8 @@ #include "inspircd.h" -#ifndef __CMD_AWAY_H__ -#define __CMD_AWAY_H__ +#ifndef CMD_AWAY_H +#define CMD_AWAY_H // include the common header files diff --git a/src/commands/cmd_commands.cpp b/src/commands/cmd_commands.cpp index 4b1e3e9be..bac56807e 100644 --- a/src/commands/cmd_commands.cpp +++ b/src/commands/cmd_commands.cpp @@ -13,8 +13,8 @@ #include "inspircd.h" -#ifndef __CMD_COMMANDS_H__ -#define __CMD_COMMANDS_H__ +#ifndef CMD_COMMANDS_H +#define CMD_COMMANDS_H // include the common header files diff --git a/src/commands/cmd_eline.cpp b/src/commands/cmd_eline.cpp index 537d39208..6c8586c01 100644 --- a/src/commands/cmd_eline.cpp +++ b/src/commands/cmd_eline.cpp @@ -26,8 +26,8 @@ * --------------------------------------------------- */ -#ifndef __CMD_ELINE_H__ -#define __CMD_ELINE_H__ +#ifndef CMD_ELINE_H +#define CMD_ELINE_H // include the common header files diff --git a/src/commands/cmd_ison.cpp b/src/commands/cmd_ison.cpp index f964c7442..a26cfed55 100644 --- a/src/commands/cmd_ison.cpp +++ b/src/commands/cmd_ison.cpp @@ -13,8 +13,8 @@ #include "inspircd.h" -#ifndef __CMD_ISON_H__ -#define __CMD_ISON_H__ +#ifndef CMD_ISON_H +#define CMD_ISON_H // include the common header files diff --git a/src/commands/cmd_join.cpp b/src/commands/cmd_join.cpp index 17a71688a..e473053e5 100644 --- a/src/commands/cmd_join.cpp +++ b/src/commands/cmd_join.cpp @@ -13,8 +13,8 @@ #include "inspircd.h" -#ifndef __CMD_JOIN_H__ -#define __CMD_JOIN_H__ +#ifndef CMD_JOIN_H +#define CMD_JOIN_H // include the common header files diff --git a/src/commands/cmd_links.cpp b/src/commands/cmd_links.cpp index 951c798ea..e48d452cd 100644 --- a/src/commands/cmd_links.cpp +++ b/src/commands/cmd_links.cpp @@ -13,8 +13,8 @@ #include "inspircd.h" -#ifndef __CMD_LINKS_H__ -#define __CMD_LINKS_H__ +#ifndef CMD_LINKS_H +#define CMD_LINKS_H // include the common header files diff --git a/src/commands/cmd_lusers.cpp b/src/commands/cmd_lusers.cpp index 4a2f4f7df..ca970bbb6 100644 --- a/src/commands/cmd_lusers.cpp +++ b/src/commands/cmd_lusers.cpp @@ -13,8 +13,8 @@ #include "inspircd.h" -#ifndef __CMD_LUSERS_H__ -#define __CMD_LUSERS_H__ +#ifndef CMD_LUSERS_H +#define CMD_LUSERS_H // include the common header files diff --git a/src/commands/cmd_names.cpp b/src/commands/cmd_names.cpp index 8fbccb77f..6238bff87 100644 --- a/src/commands/cmd_names.cpp +++ b/src/commands/cmd_names.cpp @@ -13,8 +13,8 @@ #include "inspircd.h" -#ifndef __CMD_NAMES_H__ -#define __CMD_NAMES_H__ +#ifndef CMD_NAMES_H +#define CMD_NAMES_H // include the common header files diff --git a/src/commands/cmd_userhost.cpp b/src/commands/cmd_userhost.cpp index 126b49ee4..5b00524d7 100644 --- a/src/commands/cmd_userhost.cpp +++ b/src/commands/cmd_userhost.cpp @@ -13,8 +13,8 @@ #include "inspircd.h" -#ifndef __CMD_USERHOST_H__ -#define __CMD_USERHOST_H__ +#ifndef CMD_USERHOST_H +#define CMD_USERHOST_H // include the common header files diff --git a/src/commands/cmd_version.cpp b/src/commands/cmd_version.cpp index 3064c9440..eacce31bb 100644 --- a/src/commands/cmd_version.cpp +++ b/src/commands/cmd_version.cpp @@ -13,8 +13,8 @@ #include "inspircd.h" -#ifndef __CMD_VERSION_H__ -#define __CMD_VERSION_H__ +#ifndef CMD_VERSION_H +#define CMD_VERSION_H // include the common header files diff --git a/src/commands/cmd_whois.cpp b/src/commands/cmd_whois.cpp index dc2e3ae51..ea1d94291 100644 --- a/src/commands/cmd_whois.cpp +++ b/src/commands/cmd_whois.cpp @@ -78,7 +78,7 @@ CmdResult CommandWhois::Handle (const std::vector<std::string>& parameters, User { /* no such nick/channel */ user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), !parameters[userindex].empty() ? parameters[userindex].c_str() : "*"); - user->WriteNumeric(318, "%s %s :End of /WHOIS list.",user->nick.c_str(), parameters[userindex].empty() ? parameters[userindex].c_str() : "*"); + user->WriteNumeric(318, "%s %s :End of /WHOIS list.",user->nick.c_str(), !parameters[userindex].empty() ? parameters[userindex].c_str() : "*"); return CMD_FAILURE; } diff --git a/src/configreader.cpp b/src/configreader.cpp index a1a244501..eecf01d8d 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -505,6 +505,7 @@ void ServerConfig::Fill() Limits.MaxGecos = ConfValue("limits")->getInt("maxgecos", 128); Limits.MaxAway = ConfValue("limits")->getInt("maxaway", 200); InvBypassModes = options->getBool("invitebypassmodes", true); + NoSnoticeStack = options->getBool("nosnoticestack", false); range(SoftLimit, 10, ServerInstance->SE->GetMaxFds(), ServerInstance->SE->GetMaxFds(), "<performance:softlimit>"); range(MaxConn, 0, SOMAXCONN, SOMAXCONN, "<performance:somaxconn>"); diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 86223ae95..1a856898f 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -595,23 +595,36 @@ InspIRCd::InspIRCd(int argc, char** argv) : } } - if (isatty(0) && isatty(1) && isatty(2)) + /* Explicitly shut down stdio's stdin/stdout/stderr. + * + * The previous logic here was to only do this if stdio was connected to a controlling + * terminal. However, we must do this always to avoid information leaks and other + * problems related to stdio. + * + * The only exception is if we are in debug mode. + * + * -- nenolod + */ + if ((!do_nofork) && (!do_testsuite) && (!Config->cmdline.forcedebug)) { - /* We didn't start from a TTY, we must have started from a background process - - * e.g. we are restarting, or being launched by cron. Dont kill parent, and dont - * close stdin/stdout - */ - if ((!do_nofork) && (!do_testsuite)) - { - fclose(stdin); - fclose(stderr); - if (!Config->cmdline.forcedebug) - fclose(stdout); - } - else - { - Logs->Log("STARTUP", DEFAULT,"Keeping pseudo-tty open as we are running in the foreground."); - } + int fd; + + fclose(stdin); + fclose(stderr); + fclose(stdout); + + fd = open("/dev/null", O_RDWR); + if (dup2(fd, 0) < 0) + Logs->Log("STARTUP", DEFAULT, "Failed to dup /dev/null to stdin."); + if (dup2(fd, 1) < 0) + Logs->Log("STARTUP", DEFAULT, "Failed to dup /dev/null to stdout."); + if (dup2(fd, 2) < 0) + Logs->Log("STARTUP", DEFAULT, "Failed to dup /dev/null to stderr."); + close(fd); + } + else + { + Logs->Log("STARTUP", DEFAULT,"Keeping pseudo-tty open as we are running in the foreground."); } #else WindowsIPC = new IPC; diff --git a/src/modules/account.h b/src/modules/account.h index 8f4631cc8..77f84ec4d 100644 --- a/src/modules/account.h +++ b/src/modules/account.h @@ -11,8 +11,8 @@ * --------------------------------------------------- */ -#ifndef __ACCOUNT_H__ -#define __ACCOUNT_H__ +#ifndef ACCOUNT_H +#define ACCOUNT_H #include <map> #include <string> diff --git a/src/modules/extra/README b/src/modules/extra/README index 6dc9bb18a..2478b57cf 100644 --- a/src/modules/extra/README +++ b/src/modules/extra/README @@ -3,8 +3,7 @@ For example, m_filter_pcre requires the PCRE libraries. To compile any of these modules first ensure you have the required dependencies (read the online documentation at http://wiki.inspircd.org/) and then symlink -the .cpp file from this directory into the parent directory (src/modules/) and -re-configure your inspircd with ./configure -modupdate to detect the new module. +the .cpp file from this directory into the parent directory (src/modules/). Alternatively, use the command: ./configure --enable-extras=m_extra.cpp, which will automatically take care of symlinking the module of that name and any headers it needs diff --git a/src/modules/extra/m_ldapauth.cpp b/src/modules/extra/m_ldapauth.cpp index 4fae7a2e7..a3d80b8f3 100644 --- a/src/modules/extra/m_ldapauth.cpp +++ b/src/modules/extra/m_ldapauth.cpp @@ -46,6 +46,7 @@ class ModuleLDAPAuth : public Module std::string killreason; std::string username; std::string password; + std::vector<std::string> whitelistedcidrs; int searchscope; bool verbose; bool useusername; @@ -73,6 +74,7 @@ public: void OnRehash(User* user) { ConfigReader Conf; + whitelistedcidrs.clear(); base = Conf.ReadValue("ldapauth", "baserdn", 0); attribute = Conf.ReadValue("ldapauth", "attribute", 0); @@ -85,6 +87,16 @@ public: verbose = Conf.ReadFlag("ldapauth", "verbose", 0); /* Set to true if failed connects should be reported to operators */ useusername = Conf.ReadFlag("ldapauth", "userfield", 0); + ConfigTagList whitelisttags = ServerInstance->Config->ConfTags("ldapwhitelist"); + + for (ConfigIter i = whitelisttags.first; i != whitelisttags.second; ++i) + { + std::string cidr = i->second->getString("cidr"); + if (!cidr.empty()) { + whitelistedcidrs.push_back(cidr); + } + } + if (scope == "base") searchscope = LDAP_SCOPE_BASE; else if (scope == "onelevel") @@ -128,6 +140,15 @@ public: return MOD_RES_PASSTHRU; } + for (std::vector<std::string>::iterator i = whitelistedcidrs.begin(); i != whitelistedcidrs.end(); i++) + { + if (InspIRCd::MatchCIDR(user->GetIPString(), *i, ascii_case_insensitive_map)) + { + ldapAuthed.set(user,1); + return MOD_RES_PASSTHRU; + } + } + if (!CheckCredentials(user)) { ServerInstance->Users->QuitUser(user, killreason); diff --git a/src/modules/hash.h b/src/modules/hash.h index 7e93f0ddc..c2b8abfd1 100644 --- a/src/modules/hash.h +++ b/src/modules/hash.h @@ -11,8 +11,8 @@ * --------------------------------------------------- */ -#ifndef __HASH_H__ -#define __HASH_H__ +#ifndef HASH_H +#define HASH_H #include "modules.h" diff --git a/src/modules/httpd.h b/src/modules/httpd.h index 40e619ea3..18876be20 100644 --- a/src/modules/httpd.h +++ b/src/modules/httpd.h @@ -13,8 +13,8 @@ #include "base.h" -#ifndef __HTTPD_H__ -#define __HTTPD_H__ +#ifndef HTTPD_H +#define HTTPD_H #include <string> #include <sstream> diff --git a/src/modules/m_cap.h b/src/modules/m_cap.h index d2d094c85..919075a0a 100644 --- a/src/modules/m_cap.h +++ b/src/modules/m_cap.h @@ -11,8 +11,8 @@ * --------------------------------------------------- */ -#ifndef __CAP_H__ -#define __CAP_H__ +#ifndef M_CAP_H +#define M_CAP_H #include <map> #include <string> diff --git a/src/modules/m_regex.h b/src/modules/m_regex.h index 523f9f0d3..fc196fac1 100644 --- a/src/modules/m_regex.h +++ b/src/modules/m_regex.h @@ -11,8 +11,8 @@ * --------------------------------------------------- */ -#ifndef _M_REGEX_H -#define _M_REGEX_H +#ifndef M_REGEX_H +#define M_REGEX_H #include "inspircd.h" diff --git a/src/modules/m_spanningtree/cachetimer.h b/src/modules/m_spanningtree/cachetimer.h index 2ed6c9fff..7b68f5779 100644 --- a/src/modules/m_spanningtree/cachetimer.h +++ b/src/modules/m_spanningtree/cachetimer.h @@ -11,8 +11,8 @@ * --------------------------------------------------- */ -#ifndef __TIMESYNC_H__ -#define __TIMESYNC_H__ +#ifndef M_SPANNINGTREE_CACHETIMER_H +#define M_SPANNINGTREE_CACHETIMER_H #include "timer.h" diff --git a/src/modules/m_spanningtree/commands.h b/src/modules/m_spanningtree/commands.h index 09591b4e4..358acaa29 100644 --- a/src/modules/m_spanningtree/commands.h +++ b/src/modules/m_spanningtree/commands.h @@ -11,8 +11,8 @@ * --------------------------------------------------- */ -#ifndef __COMMANDS_H__ -#define __COMMANDS_H__ +#ifndef M_SPANNINGTREE_COMMANDS_H +#define M_SPANNINGTREE_COMMANDS_H #include "main.h" diff --git a/src/modules/m_spanningtree/fjoin.cpp b/src/modules/m_spanningtree/fjoin.cpp index ea217b398..8846b2fbc 100644 --- a/src/modules/m_spanningtree/fjoin.cpp +++ b/src/modules/m_spanningtree/fjoin.cpp @@ -93,7 +93,6 @@ CmdResult CommandFJoin::Handle(const std::vector<std::string>& params, User *src parameterlist param_list; if (Utils->AnnounceTSChange) chan->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :TS for %s changed from %lu to %lu", chan->name.c_str(), channel.c_str(), (unsigned long) ourTS, (unsigned long) TS); - ourTS = TS; // while the name is equal in case-insensitive compare, it might differ in case; use the remote version chan->name = channel; chan->age = TS; diff --git a/src/modules/m_spanningtree/link.h b/src/modules/m_spanningtree/link.h index c60cb0bb7..942389167 100644 --- a/src/modules/m_spanningtree/link.h +++ b/src/modules/m_spanningtree/link.h @@ -11,8 +11,8 @@ * --------------------------------------------------- */ -#ifndef __LINK_H__ -#define __LINK_H__ +#ifndef M_SPANNINGTREE_LINK_H +#define M_SPANNINGTREE_LINK_H class Link : public refcountbase { diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h index ce7709189..735c31049 100644 --- a/src/modules/m_spanningtree/main.h +++ b/src/modules/m_spanningtree/main.h @@ -11,8 +11,8 @@ * --------------------------------------------------- */ -#ifndef __ST_MAIN__ -#define __ST_MAIN__ +#ifndef M_SPANNINGTREE_MAIN_H +#define M_SPANNINGTREE_MAIN_H #include "inspircd.h" #include <stdarg.h> diff --git a/src/modules/m_spanningtree/protocolinterface.h b/src/modules/m_spanningtree/protocolinterface.h index 762946901..7559897bd 100644 --- a/src/modules/m_spanningtree/protocolinterface.h +++ b/src/modules/m_spanningtree/protocolinterface.h @@ -1,5 +1,5 @@ -#ifndef _SPANNINGTREE_PROTOCOL_INT_ -#define _SPANNINGTREE_PROTOCOL_INT_ +#ifndef M_SPANNINGTREE_PROTOCOLINTERFACE_H +#define M_SPANNINGTREE_PROTOCOLINTERFACE_H class SpanningTreeUtilities; class ModuleSpanningTree; diff --git a/src/modules/m_spanningtree/resolvers.h b/src/modules/m_spanningtree/resolvers.h index 348debe47..af22331f1 100644 --- a/src/modules/m_spanningtree/resolvers.h +++ b/src/modules/m_spanningtree/resolvers.h @@ -11,8 +11,8 @@ * --------------------------------------------------- */ -#ifndef __RESOLVERS__H__ -#define __RESOLVERS__H__ +#ifndef M_SPANNINGTREE_RESOLVERS_H +#define M_SPANNINGTREE_RESOLVERS_H #include "socket.h" #include "inspircd.h" diff --git a/src/modules/m_spanningtree/treeserver.h b/src/modules/m_spanningtree/treeserver.h index 7eb19d9a1..65d095c5a 100644 --- a/src/modules/m_spanningtree/treeserver.h +++ b/src/modules/m_spanningtree/treeserver.h @@ -11,8 +11,8 @@ * --------------------------------------------------- */ -#ifndef __TREESERVER_H__ -#define __TREESERVER_H__ +#ifndef M_SPANNINGTREE_TREESERVER_H +#define M_SPANNINGTREE_TREESERVER_H #include "treesocket.h" diff --git a/src/modules/m_spanningtree/treesocket.h b/src/modules/m_spanningtree/treesocket.h index 2ad4d68af..80f9e0798 100644 --- a/src/modules/m_spanningtree/treesocket.h +++ b/src/modules/m_spanningtree/treesocket.h @@ -11,8 +11,8 @@ * --------------------------------------------------- */ -#ifndef __TREESOCKET_H__ -#define __TREESOCKET_H__ +#ifndef M_SPANNINGTREE_TREESOCKET_H +#define M_SPANNINGTREE_TREESOCKET_H #include "socket.h" #include "inspircd.h" diff --git a/src/modules/m_spanningtree/utils.h b/src/modules/m_spanningtree/utils.h index 2e527ae12..2543eb04f 100644 --- a/src/modules/m_spanningtree/utils.h +++ b/src/modules/m_spanningtree/utils.h @@ -11,8 +11,8 @@ * --------------------------------------------------- */ -#ifndef __ST__UTIL__ -#define __ST__UTIL__ +#ifndef M_SPANNINGTREE_UTILS_H +#define M_SPANNINGTREE_UTILS_H #include "inspircd.h" diff --git a/src/modules/sasl.h b/src/modules/sasl.h index 9abfc558a..927a4fb02 100644 --- a/src/modules/sasl.h +++ b/src/modules/sasl.h @@ -11,8 +11,8 @@ * --------------------------------------------------- */ -#ifndef __SASL_H__ -#define __SASL_H__ +#ifndef SASL_H +#define SASL_H class SASLFallback : public Event { diff --git a/src/modules/spanningtree.h b/src/modules/spanningtree.h index ec3c36214..8a38d5588 100644 --- a/src/modules/spanningtree.h +++ b/src/modules/spanningtree.h @@ -11,8 +11,8 @@ * --------------------------------------------------- */ -#ifndef __SPANNINGTREE_H__ -#define __SPANNINGTREE_H__ +#ifndef SPANNINGTREE_H +#define SPANNINGTREE_H struct AddServerEvent : public Event { diff --git a/src/modules/ssl.h b/src/modules/ssl.h index e66e423aa..060c64a0e 100644 --- a/src/modules/ssl.h +++ b/src/modules/ssl.h @@ -11,8 +11,8 @@ * --------------------------------------------------- */ -#ifndef __SSL_H__ -#define __SSL_H__ +#ifndef SSL_H +#define SSL_H #include <map> #include <string> diff --git a/src/server.cpp b/src/server.cpp index 91b911ff2..cba395ebe 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -100,7 +100,6 @@ void InspIRCd::IncrementUID(int pos) for (int i = 3; i < (UUID_LENGTH - 1); i++) { current_uid[i] = 'A'; - pos = UUID_LENGTH - 1; } } else diff --git a/src/snomasks.cpp b/src/snomasks.cpp index f8e1fc158..e0849147b 100644 --- a/src/snomasks.cpp +++ b/src/snomasks.cpp @@ -83,7 +83,7 @@ SnomaskManager::SnomaskManager() void Snomask::SendMessage(const std::string &message, char mysnomask) { - if (message != LastMessage || mysnomask != LastLetter) + if (ServerInstance->Config->NoSnoticeStack || message != LastMessage || mysnomask != LastLetter) { this->Flush(); LastMessage = message; diff --git a/src/socketengines/socketengine_poll.cpp b/src/socketengines/socketengine_poll.cpp index d20ac35a2..b84cbc5de 100644 --- a/src/socketengines/socketengine_poll.cpp +++ b/src/socketengines/socketengine_poll.cpp @@ -14,8 +14,8 @@ #include "inspircd.h" #include "exitcodes.h" -#ifndef __SOCKETENGINE_POLL__ -#define __SOCKETENGINE_POLL__ +#ifndef SOCKETENGINE_POLL +#define SOCKETENGINE_POLL #include <vector> #include <string> diff --git a/src/socketengines/socketengine_ports.cpp b/src/socketengines/socketengine_ports.cpp index 258c89709..8a14c358b 100644 --- a/src/socketengines/socketengine_ports.cpp +++ b/src/socketengines/socketengine_ports.cpp @@ -15,8 +15,8 @@ #include "exitcodes.h" #include <port.h> -#ifndef __SOCKETENGINE_PORTS__ -#define __SOCKETENGINE_PORTS__ +#ifndef SOCKETENGINE_PORTS +#define SOCKETENGINE_PORTS #ifndef __sun # error You need Solaris 10 or later to make use of this code. diff --git a/src/users.cpp b/src/users.cpp index 6277f95f9..f8f9d0025 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -829,8 +829,8 @@ void LocalUser::FullConnect() FOREACH_MOD(I_OnPostConnect,OnPostConnect(this)); - ServerInstance->SNO->WriteToSnoMask('c',"Client connecting on port %d: %s!%s@%s [%s] [%s]", - this->GetServerPort(), this->nick.c_str(), this->ident.c_str(), this->host.c_str(), this->GetIPString(), this->fullname.c_str()); + ServerInstance->SNO->WriteToSnoMask('c',"Client connecting on port %d (class %s): %s!%s@%s [%s] [%s]", + this->GetServerPort(), this->MyClass->name.c_str(), this->nick.c_str(), this->ident.c_str(), this->host.c_str(), this->GetIPString(), this->fullname.c_str()); ServerInstance->Logs->Log("BANCACHE", DEBUG, "BanCache: Adding NEGATIVE hit for %s", this->GetIPString()); ServerInstance->BanCache->AddHit(this->GetIPString(), "", ""); // reset the flood penalty (which could have been raised due to things like auto +x) |