mirror of
https://github.com/unrealircd/unrealircd.git
synced 2026-07-02 18:33:13 +02:00
Add oper class parser and structs
This commit is contained in:
@@ -105,6 +105,7 @@ extern void ipport_seperate(char *string, char **ip, char **port);
|
||||
ConfigItem_class *Find_class(char *name);
|
||||
ConfigItem_deny_dcc *Find_deny_dcc(char *name);
|
||||
ConfigItem_oper *Find_oper(char *name);
|
||||
ConfigItem_operclass *Find_operclass(char *name);
|
||||
ConfigItem_listen *Find_listen(char *ipmask, int port);
|
||||
ConfigItem_ulines *Find_uline(char *host);
|
||||
ConfigItem_except *Find_except(aClient *, char *host, short type);
|
||||
@@ -117,6 +118,10 @@ ConfigItem_vhost *Find_vhost(char *name);
|
||||
ConfigItem_deny_channel *Find_channel_allowed(aClient *cptr, char *name);
|
||||
ConfigItem_alias *Find_alias(char *name);
|
||||
ConfigItem_help *Find_Help(char *command);
|
||||
|
||||
|
||||
|
||||
|
||||
int AllowClient(aClient *cptr, struct hostent *hp, char *sockhost, char *username);
|
||||
int parse_netmask(const char *text, struct irc_netmask *netmask);
|
||||
int match_ip(struct IN_ADDR addr, char *uhost, char *mask, struct irc_netmask *netmask);
|
||||
|
||||
@@ -89,6 +89,7 @@ typedef struct _configitem_files ConfigItem_files;
|
||||
typedef struct _configitem_admin ConfigItem_admin;
|
||||
typedef struct _configitem_class ConfigItem_class;
|
||||
typedef struct _configitem_oper ConfigItem_oper;
|
||||
typedef struct _configitem_operclass ConfigItem_operclass;
|
||||
typedef struct _configitem_oper_from ConfigItem_oper_from;
|
||||
typedef struct _configitem_drpass ConfigItem_drpass;
|
||||
typedef struct _configitem_ulines ConfigItem_ulines;
|
||||
@@ -148,6 +149,16 @@ typedef struct PendingNet aPendingNet;
|
||||
typedef unsigned int u_int32_t; /* XXX Hope this works! */
|
||||
#endif
|
||||
|
||||
typedef enum OperClassEntryType { OPERCLASSENTRY_ALLOW=1, OPERCLASSENTRY_DENY=2} OperClassEntryType;
|
||||
|
||||
typedef enum OperPermission { OPER_ALLOW=1, OPER_DENY=2} OperPermission;
|
||||
|
||||
typedef struct _operClass OperClass;
|
||||
typedef struct _operClassACL OperClassACL;
|
||||
typedef struct _operClassACLEntry OperClassACLEntry;
|
||||
typedef struct _operClassACLEntryVar OperClassACLEntryVar;
|
||||
typedef struct _operClassCheckParams OperClassCheckParams;
|
||||
|
||||
#ifndef VMSP
|
||||
#include "class.h"
|
||||
#include "dbuf.h" /* THIS REALLY SHOULDN'T BE HERE!!! --msa */
|
||||
@@ -1181,6 +1192,49 @@ struct _configitem_allow {
|
||||
#endif /* INET6 */
|
||||
};
|
||||
|
||||
struct _operClassACLEntryVar
|
||||
{
|
||||
OperClassACLEntryVar *prev,*next;
|
||||
char* name;
|
||||
char* value;
|
||||
};
|
||||
|
||||
struct _operClassACLEntry
|
||||
{
|
||||
OperClassACLEntry *prev,*next;
|
||||
OperClassACLEntryVar *variables;
|
||||
OperClassEntryType type;
|
||||
};
|
||||
|
||||
struct _operClassACL
|
||||
{
|
||||
OperClassACL *prev,*next;
|
||||
char *name;
|
||||
OperClassACLEntry *entries;
|
||||
OperClassACL *acls;
|
||||
};
|
||||
|
||||
struct _operClass
|
||||
{
|
||||
char *ISA;
|
||||
char *name;
|
||||
OperClassACL *acls;
|
||||
};
|
||||
|
||||
struct _operClassCheckParams
|
||||
{
|
||||
char *action;
|
||||
aClient *sptr;
|
||||
aClient *victim;
|
||||
aChannel *channel;
|
||||
void *extra;
|
||||
};
|
||||
|
||||
struct _configitem_operclass {
|
||||
ConfigItem *prev, *next;
|
||||
OperClass *classStruct;
|
||||
};
|
||||
|
||||
struct _configitem_oper {
|
||||
ConfigItem *prev, *next;
|
||||
ConfigFlag flag;
|
||||
|
||||
+105
@@ -74,6 +74,7 @@ static int _conf_admin (ConfigFile *conf, ConfigEntry *ce);
|
||||
static int _conf_me (ConfigFile *conf, ConfigEntry *ce);
|
||||
static int _conf_files (ConfigFile *conf, ConfigEntry *ce);
|
||||
static int _conf_oper (ConfigFile *conf, ConfigEntry *ce);
|
||||
static int _conf_operclass (ConfigFile *conf, ConfigEntry *ce);
|
||||
static int _conf_class (ConfigFile *conf, ConfigEntry *ce);
|
||||
static int _conf_drpass (ConfigFile *conf, ConfigEntry *ce);
|
||||
static int _conf_ulines (ConfigFile *conf, ConfigEntry *ce);
|
||||
@@ -109,6 +110,7 @@ static int _test_admin (ConfigFile *conf, ConfigEntry *ce);
|
||||
static int _test_me (ConfigFile *conf, ConfigEntry *ce);
|
||||
static int _test_files (ConfigFile *conf, ConfigEntry *ce);
|
||||
static int _test_oper (ConfigFile *conf, ConfigEntry *ce);
|
||||
static int _test_operclass (ConfigFile *conf, ConfigEntry *ce);
|
||||
static int _test_class (ConfigFile *conf, ConfigEntry *ce);
|
||||
static int _test_drpass (ConfigFile *conf, ConfigEntry *ce);
|
||||
static int _test_ulines (ConfigFile *conf, ConfigEntry *ce);
|
||||
@@ -153,6 +155,7 @@ static ConfigCommand _ConfigCommands[] = {
|
||||
{ "me", _conf_me, _test_me },
|
||||
{ "official-channels", _conf_offchans, _test_offchans },
|
||||
{ "oper", _conf_oper, _test_oper },
|
||||
{ "operclass", _conf_operclass, _test_operclass },
|
||||
{ "set", _conf_set, _test_set },
|
||||
{ "spamfilter", _conf_spamfilter, _test_spamfilter },
|
||||
{ "tld", _conf_tld, _test_tld },
|
||||
@@ -348,6 +351,7 @@ ConfigItem_drpass *conf_drpass = NULL;
|
||||
ConfigItem_ulines *conf_ulines = NULL;
|
||||
ConfigItem_tld *conf_tld = NULL;
|
||||
ConfigItem_oper *conf_oper = NULL;
|
||||
ConfigItem_operclass *conf_operclass = NULL;
|
||||
ConfigItem_listen *conf_listen = NULL;
|
||||
ConfigItem_allow *conf_allow = NULL;
|
||||
ConfigItem_except *conf_except = NULL;
|
||||
@@ -2512,6 +2516,20 @@ ConfigItem_oper *Find_oper(char *name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ConfigItem_operclass *Find_operclass(char *name)
|
||||
{
|
||||
ConfigItem_operclass *p;
|
||||
if (!name)
|
||||
return NULL;
|
||||
|
||||
for (p = conf_operclass; p; p= (ConfigItem_operclass *) p->next)
|
||||
{
|
||||
if (!strcmp(name,p->classStruct->name))
|
||||
return (p);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int count_oper_sessions(char *name)
|
||||
{
|
||||
int count = 0;
|
||||
@@ -3428,6 +3446,93 @@ int _test_files(ConfigFile *conf, ConfigEntry *ce)
|
||||
return errors;
|
||||
}
|
||||
|
||||
/*
|
||||
* The operclass {} block parser
|
||||
*/
|
||||
|
||||
OperClassACLEntry* _conf_parseACLEntry(ConfigEntry *ce)
|
||||
{
|
||||
ConfigEntry *cep;
|
||||
OperClassACLEntry *entry = NULL;
|
||||
entry = MyMallocEx(sizeof(OperClassACLEntry));
|
||||
|
||||
if (!strcmp(ce->ce_varname,"allow"))
|
||||
entry->type = OPERCLASSENTRY_ALLOW;
|
||||
else
|
||||
entry->type = OPERCLASSENTRY_DENY;
|
||||
|
||||
for (cep = ce->ce_entries; cep; cep = cep->ce_next)
|
||||
{
|
||||
OperClassACLEntryVar *var = MyMallocEx(sizeof(OperClassACLEntryVar));
|
||||
var->name = strdup(cep->ce_varname);
|
||||
if (cep->ce_vardata)
|
||||
{
|
||||
var->value = strdup(cep->ce_vardata);
|
||||
}
|
||||
AddListItem(var,entry->variables);
|
||||
}
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
OperClassACL* _conf_parseACL(char* name, ConfigEntry *ce)
|
||||
{
|
||||
ConfigEntry *cep;
|
||||
ConfigEntry *cepp;
|
||||
OperClassACL *acl = NULL;
|
||||
acl = MyMallocEx(sizeof(OperClassACL));
|
||||
acl->name = strdup(name);
|
||||
for (cep = ce->ce_entries; cep; cep = cep->ce_next)
|
||||
{
|
||||
if (!strcmp(cep->ce_varname, "deny") || !strcmp(cep->ce_varname, "allow"))
|
||||
{
|
||||
OperClassACLEntry *entry = _conf_parseACLEntry(cep);
|
||||
AddListItem(entry,acl->entries);
|
||||
}
|
||||
else {
|
||||
OperClassACL *subAcl = _conf_parseACL(cep->ce_varname,cep);
|
||||
AddListItem(subAcl,acl->acls);
|
||||
}
|
||||
}
|
||||
|
||||
return acl;
|
||||
}
|
||||
|
||||
int _conf_operclass(ConfigFile *conf, ConfigEntry *ce)
|
||||
{
|
||||
ConfigEntry *cep;
|
||||
ConfigEntry *cepp;
|
||||
ConfigItem_operclass *operClass = NULL;
|
||||
operClass = MyMallocEx(sizeof(ConfigItem_operclass));
|
||||
operClass->classStruct = MyMallocEx(sizeof(OperClass));
|
||||
operClass->classStruct->name = strdup(ce->ce_vardata);
|
||||
|
||||
for (cep = ce->ce_entries; cep; cep = cep->ce_next)
|
||||
{
|
||||
if (!strcmp(cep->ce_varname, "parent"))
|
||||
{
|
||||
operClass->classStruct->ISA = strdup(cep->ce_vardata);
|
||||
}
|
||||
else if (!strcmp(cep->ce_varname, "privileges"))
|
||||
{
|
||||
for (cepp = cep->ce_entries; cepp; cepp = cepp->ce_next)
|
||||
{
|
||||
OperClassACL *acl = _conf_parseACL(cepp->ce_varname,cepp);
|
||||
AddListItem(acl,operClass->classStruct->acls);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AddListItem(operClass, conf_operclass);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _test_operclass(ConfigFile *conf, ConfigEntry *ce)
|
||||
{
|
||||
/* Stub - add validation later */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* The oper {} block parser
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user