diff options
author | Adam <Adam@anope.org> | 2012-10-22 00:54:30 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2012-10-22 00:54:30 -0400 |
commit | 0b9db15efc322336ddb08671ce68a3d45fb22520 (patch) | |
tree | 2e8149f370c63f08f2f197eaa92b1b36e857b0e9 /src/config.cpp | |
parent | d5b2f9cfa78ed176ffe1d9f2923799fdd37217a5 (diff) |
Add os_dns, a way to control your DNS zone via services
Diffstat (limited to 'src/config.cpp')
-rw-r--r-- | src/config.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/config.cpp b/src/config.cpp index b90c8598a..6347754fb 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -17,6 +17,14 @@ #include "opertype.h" #include "channels.h" #include "hashcomp.h" +#include "dns.h" + +#ifndef _WIN32 +#include <errno.h> +#include <sys/types.h> +#include <pwd.h> +#include <grp.h> +#endif /*************************************************************************/ @@ -200,6 +208,9 @@ ServerConfig::ServerConfig() : config_data(), NSDefFlags(NickCoreFlagStrings), C this->NameServer = "127.0.0.1"; } } + if (DNSEngine) + DNSEngine->SetFlag(SF_DEAD); + DNSEngine = new DNSManager(this->NameServer, this->DNSPort); if (this->CaseMap == "ascii") Anope::casemap = std::locale(std::locale(), new Anope::ascii_ctype<char>()); @@ -219,6 +230,31 @@ ServerConfig::ServerConfig() : config_data(), NSDefFlags(NickCoreFlagStrings), C if (this->SessionIPv4CIDR > 32 || this->SessionIPv6CIDR > 128) throw ConfigException("Session CIDR value out of range"); + +#ifndef _WIN32 + if (!this->User.empty()) + { + errno = 0; + struct passwd *u = getpwnam(this->User.c_str()); + if (u == NULL) + Log() << "Unable to setuid to " << this->User << ": " << Anope::LastError(); + else if (setuid(u->pw_uid) == -1) + Log() << "Unable to setuid to " << this->User << ": " << Anope::LastError(); + else + Log() << "Successfully set user to " << this->User; + } + if (!this->Group.empty()) + { + errno = 0; + struct group *g = getgrnam(this->Group.c_str()); + if (g == NULL) + Log() << "Unable to setgid to " << this->Group << ": " << Anope::LastError(); + else if (setuid(g->gr_gid) == -1) + Log() << "Unable to setgid to " << this->Group << ": " << Anope::LastError(); + else + Log() << "Successfully set group to " << this->Group; + } +#endif } bool ServerConfig::CheckOnce(const Anope::string &tag) @@ -1191,6 +1227,8 @@ ConfigItems::ConfigItems(ServerConfig *conf) {"networkinfo", "userlen", "10", new ValueContainerUInt(&conf->UserLen), DT_UINTEGER | DT_NORELOAD, NoValidation}, {"networkinfo", "hostlen", "64", new ValueContainerUInt(&conf->HostLen), DT_UINTEGER | DT_NORELOAD, NoValidation}, {"networkinfo", "chanlen", "32", new ValueContainerUInt(&conf->ChanLen), DT_UINTEGER | DT_NORELOAD, NoValidation}, + {"options", "user", "", new ValueContainerString(&conf->User), DT_STRING, NoValidation}, + {"options", "group", "", new ValueContainerString(&conf->Group), DT_STRING, NoValidation}, {"options", "casemap", "ascii", new ValueContainerString(&conf->CaseMap), DT_STRING, NoValidation}, {"options", "passlen", "32", new ValueContainerUInt(&conf->PassLen), DT_UINTEGER | DT_NORELOAD, NoValidation}, {"options", "seed", "0", new ValueContainerLUInt(&conf->Seed), DT_LUINTEGER, NoValidation}, @@ -1264,6 +1302,7 @@ ConfigItems::ConfigItems(ServerConfig *conf) {"mail", "memo_message", "", new ValueContainerString(&conf->MailMemoMessage), DT_STRING | DT_ALLOW_NEWLINE, ValidateMail}, {"dns", "nameserver", "127.0.0.1", new ValueContainerString(&conf->NameServer), DT_STRING, NoValidation}, {"dns", "timeout", "5", new ValueContainerTime(&conf->DNSTimeout), DT_TIME, NoValidation}, + {"dns", "port", "53", new ValueContainerInt(&conf->DNSPort), DT_INTEGER, NoValidation}, {"chanserv", "name", "", new ValueContainerString(&conf->ChanServ), DT_STRING, NoValidation}, {"chanserv", "defaults", "keeptopic secure securefounder signkick", new ValueContainerString(&CSDefaults), DT_STRING, ValidateChanServ}, {"chanserv", "maxregistered", "0", new ValueContainerUInt(&conf->CSMaxReg), DT_UINTEGER, ValidateChanServ}, |