/*
* ircd_parser.y: A yacc/bison parser for ircd config files.
* This is part of ircu, an Internet Relay Chat server.
- * The contents of this file are Copyright(C) 2001 by Andrew Miller, the
- * ircd-hybrid team and the ircu team.
+ * The contents of this file are Copyright 2001 Diane Bruce,
+ * Andrew Miller, the ircd-hybrid team and the ircu team.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
#include "hash.h"
#include "ircd.h"
#include "ircd_alloc.h"
+#include "ircd_auth.h"
#include "ircd_chattr.h"
#include "ircd_log.h"
#include "ircd_reply.h"
struct ServerConf *sconf;
struct qline *qconf = NULL;
struct s_map *smap;
+ struct Privs privs;
+ struct Privs privs_dirty;
static void parse_error(char *pattern,...) {
static char error_buffer[1024];
%token YES
%token NO
%token OPER
-%token PORT
%token VHOST
-%token MASK
%token HIDDEN
%token MOTD
%token JUPE
%token PSEUDO
%token PREPEND
%token USERMODE
+%token IAUTH
+%token TIMEOUT
/* and now a lot of priviledges... */
%token TPRIV_CHAN_LIMIT TPRIV_MODE_LCHAN TPRIV_DEOP_LCHAN TPRIV_WALK_LCHAN
-%token TPRIV_KILL TPRIV_LOCAL_KILL TPRIV_REHASH TPRIV_RESTART TPRIV_DIE
-%token TPRIV_GLINE TPRIV_LOCAL_GLINE TPRIV_JUPE TPRIV_LOCAL_JUPE
+%token TPRIV_LOCAL_KILL TPRIV_REHASH TPRIV_RESTART TPRIV_DIE
+%token TPRIV_GLINE TPRIV_LOCAL_GLINE TPRIV_LOCAL_JUPE TPRIV_LOCAL_BADCHAN
%token TPRIV_LOCAL_OPMODE TPRIV_OPMODE TPRIV_SET TPRIV_WHOX TPRIV_BADCHAN
-%token TPRIV_LOCAL_BADCHAN
%token TPRIV_SEE_CHAN TPRIV_SHOW_INVIS TPRIV_SHOW_ALL_INVIS TPRIV_PROPAGATE
%token TPRIV_UNLIMIT_QUERY TPRIV_DISPLAY TPRIV_SEE_OPERS TPRIV_WIDE_GLINE
+%token TPRIV_FORCE_OPMODE TPRIV_FORCE_LOCAL_OPMODE
/* and some types... */
%type <num> sizespec
%type <num> timespec timefactor factoredtimes factoredtime
block: adminblock | generalblock | classblock | connectblock |
serverblock | operblock | portblock | jupeblock | clientblock |
killblock | cruleblock | motdblock | featuresblock | quarantineblock |
- pseudoblock | error;
+ pseudoblock | iauthblock | error;
/* The timespec, sizespec and expr was ripped straight from
* ircd-hybrid-7. */
{
if (localConf.numeric == 0)
localConf.numeric = yylval.num;
- else
+ else if (localConf.numeric != yylval.num)
parse_error("Redefinition of server numeric %i (%i)",yylval.num,
localConf.numeric);
};
{
if (localConf.name == NULL)
DupString(localConf.name, yylval.text);
- else
+ else if (strcmp(localConf.name, yylval.text))
parse_error("Redefinition of server name %s (%s)",yylval.text,
localConf.name);
};
generalvhost: VHOST '=' QSTRING ';'
{
- if (INADDR_NONE ==
- (localConf.vhost_address.s_addr = inet_addr(yylval.text)))
- localConf.vhost_address.s_addr = INADDR_ANY;
+ ircd_aton(&localConf.vhost_address, yylval.text);
};
adminblock: ADMIN '{' adminitems '}'
maxlinks = 0;
sendq = 0;
pass = NULL;
+ memset(&privs, 0, sizeof(privs));
+ memset(&privs_dirty, 0, sizeof(privs_dirty));
} '{' classitems '}'
{
if (name != NULL)
{
- add_class(name, tping, tconn, maxlinks, sendq);
- find_class(name)->default_umode = pass;
+ struct ConnectionClass *c_class;
+ add_class(name, tping, tconn, maxlinks, sendq);
+ c_class = find_class(name);
+ c_class->default_umode = pass;
+ memcpy(&c_class->privs, &privs, sizeof(c_class->privs));
+ memcpy(&c_class->privs_dirty, &privs_dirty, sizeof(c_class->privs_dirty));
}
else {
parse_error("Missing name in class block");
} ';';
classitems: classitem classitems | classitem;
classitem: classname | classpingfreq | classconnfreq | classmaxlinks |
- classsendq | classusermode | error;
+ classsendq | classusermode | priv | error;
classname: NAME '=' QSTRING ';'
{
MyFree(name);
port = 0;
} '{' connectitems '}'
{
- if (name != NULL && pass != NULL && host != NULL && c_class != NULL &&
- /*ccount < MAXCONFLINKS &&*/ !strchr(host, '*') &&
- !strchr(host, '?'))
+ if (name != NULL && pass != NULL && host != NULL && c_class != NULL
+ && !strchr(host, '*') && !strchr(host, '?'))
{
aconf = make_conf();
aconf->status = CONF_SERVER;
aconf->name = name;
aconf->passwd = pass;
aconf->conn_class = c_class;
- aconf->port = port;
+ aconf->address.port = port;
aconf->status = CONF_SERVER;
aconf->host = host;
aconf->next = GlobalConfList;
- aconf->ipnum.s_addr = INADDR_NONE;
lookup_confhost(aconf);
GlobalConfList = aconf;
}
{
aconf = (struct ConfItem*) MyMalloc(sizeof(*aconf));
memset(aconf, 0, sizeof(*aconf));
+ aconf->status = CONF_LEAF;
} '{' serveritems '}'
{
if (aconf->status == 0)
{
aconf = (struct ConfItem*) MyMalloc(sizeof(*aconf));
memset(aconf, 0, sizeof(*aconf));
+ memset(&privs, 0, sizeof(privs));
+ memset(&privs_dirty, 0, sizeof(privs_dirty));
aconf->status = CONF_OPERATOR;
} '{' operitems '}' ';'
{
- if (aconf->name != NULL && aconf->passwd != NULL && aconf->host != NULL)
+ if (aconf->name != NULL && aconf->passwd != NULL && aconf->host != NULL
+ && aconf->conn_class != NULL)
{
+ memcpy(&aconf->privs, &privs, sizeof(aconf->privs));
+ memcpy(&aconf->privs_dirty, &privs_dirty, sizeof(aconf->privs_dirty));
+ if (!PrivHas(&privs_dirty, PRIV_PROPAGATE)
+ && !PrivHas(&aconf->conn_class->privs_dirty, PRIV_PROPAGATE))
+ parse_error("Operator block for %s and class %s have no LOCAL setting", aconf->name, aconf->conn_class->cc_name);
aconf->next = GlobalConfList;
GlobalConfList = aconf;
}
}
};
operitems: operitem | operitems operitem;
-operitem: opername | operpass | operhost | operclass | operpriv | error;
+operitem: opername | operpass | operhost | operclass | priv | error;
opername: NAME '=' QSTRING ';'
{
aconf->conn_class = find_class(yylval.text);
};
-operpriv: privtype '=' yesorno ';'
+priv: privtype '=' yesorno ';'
{
- PrivSet(&aconf->privs_dirty, $1);
+ PrivSet(&privs_dirty, $1);
if (($3 == 1) ^ invert)
- PrivSet(&aconf->privs, $1);
+ PrivSet(&privs, $1);
else
- PrivClr(&aconf->privs, $1);
+ PrivClr(&privs, $1);
invert = 0;
};
TPRIV_MODE_LCHAN { $$ = PRIV_MODE_LCHAN; } |
TPRIV_DEOP_LCHAN { $$ = PRIV_DEOP_LCHAN; } |
TPRIV_WALK_LCHAN { $$ = PRIV_WALK_LCHAN; } |
- TPRIV_KILL { $$ = PRIV_KILL; } |
+ KILL { $$ = PRIV_KILL; } |
TPRIV_LOCAL_KILL { $$ = PRIV_LOCAL_KILL; } |
TPRIV_REHASH { $$ = PRIV_REHASH; } |
TPRIV_RESTART { $$ = PRIV_RESTART; } |
TPRIV_DIE { $$ = PRIV_DIE; } |
TPRIV_GLINE { $$ = PRIV_GLINE; } |
TPRIV_LOCAL_GLINE { $$ = PRIV_LOCAL_GLINE; } |
- TPRIV_JUPE { $$ = PRIV_JUPE; } |
+ JUPE { $$ = PRIV_JUPE; } |
TPRIV_LOCAL_JUPE { $$ = PRIV_LOCAL_JUPE; } |
TPRIV_LOCAL_OPMODE { $$ = PRIV_LOCAL_OPMODE; } |
TPRIV_OPMODE { $$ = PRIV_OPMODE; }|
TPRIV_DISPLAY { $$ = PRIV_DISPLAY; } |
TPRIV_SEE_OPERS { $$ = PRIV_SEE_OPERS; } |
TPRIV_WIDE_GLINE { $$ = PRIV_WIDE_GLINE; } |
- LOCAL { $$ = PRIV_PROPAGATE; invert = 1; };
+ LOCAL { $$ = PRIV_PROPAGATE; invert = 1; } |
+ TPRIV_FORCE_OPMODE { $$ = PRIV_FORCE_OPMODE; } |
+ TPRIV_FORCE_LOCAL_OPMODE { $$ = PRIV_FORCE_LOCAL_OPMODE; };
yesorno: YES { $$ = 1; } | NO { $$ = 0; };
if (port > 0 && port <= 0xFFFF)
{
add_listener(port, host, pass, tconn, tping);
- host = pass = NULL;
}
else
{
- MyFree(host);
- MyFree(pass);
parse_error("Bad port block");
}
+ MyFree(host);
+ MyFree(pass);
+ host = pass = NULL;
};
portitems: portitem portitems | portitem;
portitem: portnumber | portvhost | portmask | portserver | porthidden | error;
}
DupString(dconf->hostmask, h);
DupString(dconf->usermask, u);
- if (strchr(yylval.text, '.'))
- {
- int c_class;
- char ipname[16];
- int ad[4] = { 0 };
- int bits2 = 0;
- dconf->flags |= DENY_FLAGS_IP;
- c_class = sscanf(dconf->hostmask, "%d.%d.%d.%d/%d",
- &ad[0], &ad[1], &ad[2], &ad[3], &bits2);
- if (c_class != 5) {
- dconf->bits = c_class * 8;
- }
- else {
- dconf->bits = bits2;
- }
- ircd_snprintf(0, ipname, sizeof(ipname), "%d.%d.%d.%d", ad[0], ad[1],
- ad[2], ad[3]);
- dconf->address = inet_addr(ipname);
- }
+ ipmask_parse(dconf->hostmask, &dconf->address, &dconf->bits);
};
killreal: REAL '=' QSTRING ';'
smap->services = nh;
}
};
+
+iauthblock: IAUTH '{'
+{
+ pass = host = NULL;
+ port = 0;
+ tconn = 60;
+ tping = 60;
+} iauthitems '}' ';'
+{
+ if (!name || !host || !port) {
+ log_write(LS_CONFIG, L_ERROR, 0, "IAuth block needs a server name and port.");
+ return 0;
+ }
+ iauth_connect(host, port, pass, tconn, tping);
+ MyFree(pass);
+ MyFree(host);
+ pass = host = NULL;
+};
+
+iauthitems: iauthitem iauthitems | iauthitem;
+iauthitem: iauthpass | iauthhost | iauthport | iauthconnfreq | iauthtimeout | error;
+iauthpass: PASS '=' QSTRING ';'
+{
+ MyFree(pass);
+ DupString(pass, yylval.text);
+};
+iauthhost: HOST '=' QSTRING ';'
+{
+ MyFree(host);
+ DupString(host, yylval.text);
+};
+iauthport: PORT '=' NUMBER ';'
+{
+ port = yylval.num;
+};
+iauthconnfreq: CONNECTFREQ '=' timespec ';'
+{
+ tconn = yylval.num;
+};
+iauthtimeout: TIMEOUT '=' timespec ';'
+{
+ tping = yylval.num;
+};