diff options
author | rburchell <rburchell@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-02-15 15:22:20 +0000 |
---|---|---|
committer | rburchell <rburchell@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-02-15 15:22:20 +0000 |
commit | 83243793468c7af887404ca30c34146436682610 (patch) | |
tree | 11f6fb7ffd31bd3b2b6aab1a817d907db017f452 | |
parent | 855847f428412e85087384df73096d9056526937 (diff) |
Can now correctly tie users to opertypes.
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2063 5417fbe8-f217-4b02-8779-1006273d7864
-rw-r--r-- | include/opertype.h | 8 | ||||
-rw-r--r-- | include/services.h | 8 | ||||
-rw-r--r-- | src/Makefile | 6 | ||||
-rw-r--r-- | src/account.cpp | 34 | ||||
-rw-r--r-- | src/config.c | 33 | ||||
-rw-r--r-- | src/init.c | 32 | ||||
-rw-r--r-- | src/opertype.cpp | 9 |
7 files changed, 87 insertions, 43 deletions
diff --git a/include/opertype.h b/include/opertype.h index 9d5e77224..d6a3c4306 100644 --- a/include/opertype.h +++ b/include/opertype.h @@ -40,13 +40,13 @@ class OperType * @param cmdstr The string to check, e.g. botserv/set/private. * @return True if this opertype may run the specified command, false otherwise. */ - bool HasCommand(const std::string &cmdstr); + bool HasCommand(const std::string &cmdstr) const; /** Check whether this opertype has access to the given special permission. * @param privstr The priv to check for, e.g. users/auspex. * @return True if this opertype has the specified priv, false otherwise. */ - bool HasPriv(const std::string &privstr); + bool HasPriv(const std::string &privstr) const; /** Add the specified command to this opertype. * @param cmdstr The command mask to grant this opertype access to, e.g: nickserv/ *, chanserv/set/ *, botserv/set/private. @@ -57,4 +57,8 @@ class OperType * @param privstr The specified mask of privs to grant this opertype access to, e.g. users/auspex, users/ *, etc. */ void AddPriv(const std::string &privstr); + + /** Returns the name of this opertype. + */ + const std::string &GetName() const; }; diff --git a/include/services.h b/include/services.h index 6f7353111..549d39ba1 100644 --- a/include/services.h +++ b/include/services.h @@ -1377,4 +1377,12 @@ class Anope /*************************************************************************/ +/** Pair of nick/opertype lookup. It's stored like this currently, because config is parsed before db load. + * XXX: It would be nice to not need this. UGH. + */ +extern std::list<std::pair<std::string, std::string> > svsopers_in_config; +/** List of available opertypes. + */ +extern std::list<OperType *> MyOperTypes; + #endif /* SERVICES_H */ diff --git a/src/Makefile b/src/Makefile index 709f2ec77..0a65cd246 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,8 +1,8 @@ -OBJS = account.cpp actions.o base64.o bots.o botserv.o channels.o chanserv.o commands.o compat.o \ +OBJS = actions.o base64.o bots.o botserv.o channels.o chanserv.o commands.o compat.o \ config.o datafiles.o encrypt.o events.o hashcomp.o helpserv.o hostserv.o init.o ircd.o language.o log.o mail.o main.o \ memory.o memoserv.o messages.o misc.o modules.o news.o nickserv.o operserv.o \ process.o protocol.o send.o servers.o sessions.o slist.o sockutil.o opertype.o timeout.o users.o module.o modulemanager.o configreader.o \ - wildcard.o + wildcard.o nickcore.o INCLUDES = ../include/commands.h ../include/defs.h ../include/language.h \ ../include/pseudo.h ../include/sysconf.h ../include/config.h \ @@ -33,7 +33,7 @@ services: $(OBJS) mod_version @$(MAKEBIN) $(CC) $(CFLAGS) $(OBJS) $(ANOPELIBS) $(MLIBS) -o $@ $(LDFLAGS) $(OBJS): Makefile -account.o: account.cpp $(INCLUDES) +nickcore.o: nickcore.cpp $(INCLUDES) actions.o: actions.c $(INCLUDES) base64.o: base64.c $(INCLUDES) bots.o: bots.cpp $(INCLUDES) diff --git a/src/account.cpp b/src/account.cpp deleted file mode 100644 index b33646bbe..000000000 --- a/src/account.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "services.h"
-
-NickCore::NickCore()
-{
- next = prev = NULL;
- display = email = greet = url = NULL;
- ot = NULL;
- pass[0] = '\0';
- icq = flags = 0;
- language = accesscount = channelcount = 0;
- lastmail = 0;
-}
-
-bool NickCore::HasCommand(const std::string &cmdstr)
-{
- if (!this->ot)
- {
- // No opertype.
- return false;
- }
-
- return this->ot->HasCommand(cmdstr);
-}
-
-bool NickCore::HasPriv(const std::string &privstr)
-{
- if (!this->ot)
- {
- // No opertype.
- return false;
- }
-
- return this->ot->HasPriv(privstr);
-}
diff --git a/src/config.c b/src/config.c index 5bd4d4c42..bd2168f1a 100644 --- a/src/config.c +++ b/src/config.c @@ -271,11 +271,11 @@ static char *UlineServers; char **Ulines; int NumUlines; -static std::list<OperType *> MyOperTypes; +std::list<OperType *> MyOperTypes; /* Pair of nick/opertype lookup. It's stored like this currently, because config is parsed before db load. * XXX: It would be nice to not need this. */ -static std::list<std::pair<std::string, std::string> > svsopers_in_config; +std::list<std::pair<std::string, std::string> > svsopers_in_config; /*************************************************************************/ @@ -672,6 +672,35 @@ static bool DoOper(ServerConfig *conf, const char *, const char **, ValueList &v static bool DoneOpers(ServerConfig *, const char *, bool) { + // XXX: this is duplicated in config.c + for (std::list<std::pair<std::string, std::string> >::iterator it = svsopers_in_config.begin(); it != svsopers_in_config.end(); it++) + { + std::string nick = it->first; + std::string type = it->second; + + NickAlias *na = findnick(nick); + if (!na) + { + // Nonexistant nick + continue; + } + + if (!na->nc) + { + // Nick with no core (wtf?) + abort(); + } + + for (std::list<OperType *>::iterator tit = MyOperTypes.begin(); tit != MyOperTypes.end(); tit++) + { + OperType *ot = *tit; + if (ot->GetName() == type) + { + alog("Tied oper %s to type %s", na->nc->display, type.c_str()); + na->nc->ot = ot; + } + } + } return true; } diff --git a/src/init.c b/src/init.c index f8d664548..a70f883ee 100644 --- a/src/init.c +++ b/src/init.c @@ -547,6 +547,38 @@ int init_secondary(int ac, char **av) } alog("Databases loaded"); + // XXX: this is duplicated in type loading. + for (std::list<std::pair<std::string, std::string> >::iterator it = svsopers_in_config.begin(); it != svsopers_in_config.end(); it++) + { + std::string nick = it->first; + std::string type = it->second; + + NickAlias *na = findnick(nick); + if (!na) + { + // Nonexistant nick + alog("Oper nick %s is not registered", nick.c_str()); + continue; + } + + if (!na->nc) + { + // Nick with no core (wtf?) + abort(); + } + + for (std::list<OperType *>::iterator tit = MyOperTypes.begin(); tit != MyOperTypes.end(); tit++) + { + OperType *ot = *tit; + if (ot->GetName() == type) + { + alog("Tied oper %s to type %s", na->nc->display, type.c_str()); + na->nc->ot = ot; + } + } + } + // END DUPLICATION + /* this is only used on the first run of Anope. */ BotInfo *bi = findbot("NickServ"); diff --git a/src/opertype.cpp b/src/opertype.cpp index 440078f96..a90ac9de5 100644 --- a/src/opertype.cpp +++ b/src/opertype.cpp @@ -15,12 +15,12 @@ OperType::OperType(const std::string &nname) : name(nname) { } -bool OperType::HasCommand(const std::string &cmdstr) +bool OperType::HasCommand(const std::string &cmdstr) const { } -bool OperType::HasPriv(const std::string &privstr) +bool OperType::HasPriv(const std::string &privstr) const { } @@ -35,3 +35,8 @@ void OperType::AddPriv(const std::string &privstr) this->privs.push_back(privstr); } +const std::string &OperType::GetName() const +{ + return this->name; +} + |