From 743c10e4ca5acd45e670b335a07b5bf3ab754ab6 Mon Sep 17 00:00:00 2001 From: aquanight Date: Sun, 23 Mar 2008 20:43:35 +0000 Subject: Add ability to control what opertypes can set what operonly user/chan modes. This works the same way as commands, in that modes allowed by classes are added together, and * allows all. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9176 e03df62e-2008-0410-955e-edbf42e46eb7 --- include/configreader.h | 9 ++++++++- include/mode.h | 5 +++++ include/users.h | 17 +++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/configreader.h b/include/configreader.h index 3120d3d59..b94687b43 100644 --- a/include/configreader.h +++ b/include/configreader.h @@ -203,9 +203,16 @@ struct MultiConfig */ typedef std::map opertype_t; +struct operclass_data +{ + char* commandlist; + char* cmodelist; + char* umodelist; +}; + /** A Set of oper classes */ -typedef std::map operclass_t; +typedef std::map operclass_t; /** This class holds the bulk of the runtime configuration for the ircd. diff --git a/include/mode.h b/include/mode.h index ca610e46a..f6022c090 100644 --- a/include/mode.h +++ b/include/mode.h @@ -14,6 +14,11 @@ #ifndef __MODE_H #define __MODE_H +/* Forward declarations. */ +class User; + +#include "channels.h" + /** * Holds the values for different type of modes * that can exist, USER or CHANNEL type. diff --git a/include/users.h b/include/users.h index d1f61932e..a12282ac9 100644 --- a/include/users.h +++ b/include/users.h @@ -18,6 +18,8 @@ #include "connection.h" #include "dns.h" +#include "mode.h" + /** Channel status for a user */ enum ChanStatus { @@ -455,6 +457,12 @@ class CoreExport User : public connection std::map* AllowedOperCommands; + /** Allowed user modes from oper classes. */ + bool AllowedUserModes[64]; + + /** Allowed channel modes from oper classes. */ + bool AllowedChanModes[64]; + public: /** Contains a pointer to the connect class a user is on from - this will be NULL for remote connections. * The pointer is guarenteed to *always* be valid. :) @@ -755,6 +763,15 @@ class CoreExport User : public connection */ bool HasPermission(const std::string &command); + /** Returns true or false if a user can set a privileged user or channel mode. + * This is done by looking up their oper type from User::oper, then referencing + * this to their oper classes, and checking the modes they can set. + * @param mode The mode the check + * @param type ModeType (MODETYPE_CHANNEL or MODETYPE_USER). + * @return True if the user can set or unset this mode. + */ + bool HasModePermission(unsigned char mode, ModeType type); + /** Calls read() to read some data for this user using their fd. * @param buffer The buffer to read into * @param size The size of data to read -- cgit v1.2.3