Author: Isomer <isomer@undernet.org>
[ircu2.10.12-pk.git] / ircd / ircd_parser.y
index f545c003cf61e7d2c4dd4f69a47459039b4103ac..d47a9414787bb5c61e8d79f59160acc6dcf05be9 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * 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
@@ -32,6 +32,7 @@
 #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"
@@ -52,7 +53,6 @@
 #include "s_misc.h"
 #include "send.h"
 #include "struct.h"
-#include "support.h"
 #include "sys.h"
 #include <stdlib.h>
 #include <stdio.h>
   extern struct DenyConf*   denyConfList;
   extern struct CRuleConf*  cruleConfList;
   extern struct ServerConf* serverConfList;
-  extern struct qline     *GlobalQuarantineList;
+  extern struct s_map*      GlobalServiceMapList;
+  extern struct qline*      GlobalQuarantineList;
 
   int yylex(void);
   /* Now all the globals we need :/... */
-  int tping, tconn, maxlinks, sendq, port;
-  int stringno;
-  char *name, *pass, *host;
+  int tping, tconn, maxlinks, sendq, port, invert, stringno;
+  char *name, *pass, *host, *ip, *username, *origin, *hub_limit;
   char *stringlist[MAX_STRINGS];
   struct ConnectionClass *c_class;
-  struct ConfItem *aconf;
   struct DenyConf *dconf;
   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];
@@ -103,9 +104,12 @@ static void parse_error(char *pattern,...) {
 %token PINGFREQ
 %token CONNECTFREQ
 %token MAXLINKS
+%token MAXHOPS
 %token SENDQ
 %token NAME
 %token HOST
+%token IP
+%token USERNAME
 %token PASS
 %token LOCAL
 %token SECONDS
@@ -130,9 +134,7 @@ static void parse_error(char *pattern,...) {
 %token YES
 %token NO
 %token OPER
-%token PORT
 %token VHOST
-%token MASK
 %token HIDDEN
 %token MOTD
 %token JUPE
@@ -147,17 +149,21 @@ static void parse_error(char *pattern,...) {
 %token TFILE
 %token RULE
 %token ALL
-%token IP
 %token FEATURES
 %token QUARANTINE
+%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
@@ -174,9 +180,9 @@ static void parse_error(char *pattern,...) {
 /* Blocks in the config file... */
 blocks: blocks block | block;
 block: adminblock | generalblock | classblock | connectblock |
-       serverblock | operblock | portblock | jupeblock | clientblock |
+       uworldblock | operblock | portblock | jupeblock | clientblock |
        killblock | cruleblock | motdblock | featuresblock | quarantineblock |
-       error;
+       pseudoblock | iauthblock | error;
 
 /* The timespec, sizespec and expr was ripped straight from
  * ircd-hybrid-7. */
@@ -254,42 +260,52 @@ jupeitems: jupeitem jupeitems | jupeitem;
 jupeitem: jupenick | error;
 jupenick: NICK '=' QSTRING
 {
-  addNickJupes(yylval.text);
+  addNickJupes($3);
 } ';';
 
-generalblock: GENERAL '{' generalitems '}' ';' ;
+generalblock: GENERAL '{' generalitems '}'
+{
+  if (localConf.name == NULL)
+    parse_error("Your General block must contain a name.");
+  if (localConf.numeric == 0)
+    parse_error("Your General block must contain a numeric (between 1 and 4095).");
+} ';' ;
 generalitems: generalitem generalitems | generalitem;
 generalitem: generalnumeric | generalname | generalvhost | generaldesc | error;
 generalnumeric: NUMERIC '=' NUMBER ';'
 {
   if (localConf.numeric == 0)
-    localConf.numeric = yylval.num;
-  else
-    parse_error("Redefinition of server numeric %i (%i)",yylval.num,
+    localConf.numeric = $3;
+  else if (localConf.numeric != $3)
+    parse_error("Redefinition of server numeric %i (%i)", $3,
                localConf.numeric);
 };
 
 generalname: NAME '=' QSTRING ';'
 {
   if (localConf.name == NULL)
-    DupString(localConf.name, yylval.text);
-  else
-    parse_error("Redefinition of server name %s (%s)",yylval.text,
+    DupString(localConf.name, $3);
+  else if (strcmp(localConf.name, $3))
+    parse_error("Redefinition of server name %s (%s)", $3,
                localConf.name);
 };
 
 generaldesc: DESCRIPTION '=' QSTRING ';'
 {
   MyFree(localConf.description);
-  DupString(localConf.description, yylval.text);
-  ircd_strncpy(cli_info(&me), yylval.text, REALLEN);
+  DupString(localConf.description, $3);
+  ircd_strncpy(cli_info(&me), $3, REALLEN);
 };
 
 generalvhost: VHOST '=' QSTRING ';'
 {
-  if (INADDR_NONE ==
-      (localConf.vhost_address.s_addr = inet_addr(yylval.text)))
-    localConf.vhost_address.s_addr = INADDR_ANY;
+  struct irc_in_addr addr;
+  if (!ircd_aton(&addr, $3))
+      parse_error("Invalid virtual host '%s'.", $3);
+  else if (irc_in_addr_is_ipv4(&addr))
+    memcpy(&VirtualHost_v4.addr, &addr, sizeof(addr));
+  else
+    memcpy(&VirtualHost_v6.addr, &addr, sizeof(addr));
 };
 
 adminblock: ADMIN '{' adminitems '}'
@@ -306,277 +322,256 @@ adminitem: adminlocation | admincontact | error;
 adminlocation: LOCATION '=' QSTRING ';'
 {
  if (localConf.location1 == NULL)
-  DupString(localConf.location1, yylval.text);
+  DupString(localConf.location1, $3);
  else if (localConf.location2 == NULL)
-  DupString(localConf.location2, yylval.text);
+  DupString(localConf.location2, $3);
  /* Otherwise just drop it. -A1kmm */
 };
 admincontact: CONTACT '=' QSTRING ';'
 {
  if (localConf.contact != NULL)
    MyFree(localConf.contact);
- DupString(localConf.contact, yylval.text);
+ DupString(localConf.contact, $3);
 };
 
 classblock: CLASS {
-  name = NULL;
   tping = 90;
-  tconn = 0;
-  maxlinks = 0;
-  sendq = 0;
 } '{' classitems '}'
 {
   if (name != NULL)
   {
-   add_class(name, tping, tconn, maxlinks, sendq);
+    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");
   }
+  name = NULL;
+  pass = NULL;
+  tconn = 0;
+  maxlinks = 0;
+  sendq = 0;
+  memset(&privs, 0, sizeof(privs));
+  memset(&privs_dirty, 0, sizeof(privs_dirty));
 } ';';
 classitems: classitem classitems | classitem;
 classitem: classname | classpingfreq | classconnfreq | classmaxlinks |
-           classsendq | error;
+           classsendq | classusermode | priv | error;
 classname: NAME '=' QSTRING ';'
 {
   MyFree(name);
-  DupString(name, yylval.text);
+  DupString(name, $3);
 };
 classpingfreq: PINGFREQ '=' timespec ';'
 {
-  tping = yylval.num;
+  tping = $3;
 };
 classconnfreq: CONNECTFREQ '=' timespec ';'
 {
-  tconn = yylval.num;
+  tconn = $3;
 };
 classmaxlinks: MAXLINKS '=' expr ';'
 {
-  maxlinks = yylval.num;
+  maxlinks = $3;
 };
 classsendq: SENDQ '=' sizespec ';'
 {
-  sendq = yylval.num;
+  sendq = $3;
+};
+classusermode: USERMODE '=' QSTRING ';'
+{
+  MyFree(pass);
+  DupString(pass, $3);
 };
 
 connectblock: CONNECT
 {
- name = pass = host = NULL;
- c_class = NULL;
- port = 0;
+ maxlinks = 65535;
 } '{' 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;
+   struct ConfItem *aconf = make_conf(CONF_SERVER);
    aconf->name = name;
+   aconf->origin_name = origin;
    aconf->passwd = pass;
    aconf->conn_class = c_class;
-   aconf->port = port;
-   aconf->status = CONF_SERVER;
+   aconf->address.port = port;
    aconf->host = host;
-   aconf->next = GlobalConfList;
-   aconf->ipnum.s_addr = INADDR_NONE;
+   aconf->maximum = maxlinks;
+   aconf->hub_limit = hub_limit;
    lookup_confhost(aconf);
-   GlobalConfList = aconf;
  }
  else
  {
    MyFree(name);
    MyFree(pass);
    MyFree(host);
-   name = pass = host = NULL;
+   MyFree(origin);
+   MyFree(hub_limit);
    parse_error("Bad connect block");
  }
+ name = pass = host = origin = hub_limit = NULL;
+ c_class = NULL;
+ port = 0;
 }';';
 connectitems: connectitem connectitems | connectitem;
 connectitem: connectname | connectpass | connectclass | connecthost
-              | connectport | error;
+              | connectport | connectvhost | connectleaf | connecthub
+              | connecthublimit | connectmaxhops | error;
 connectname: NAME '=' QSTRING ';'
 {
  MyFree(name);
- DupString(name, yylval.text);
+ DupString(name, $3);
 };
 connectpass: PASS '=' QSTRING ';'
 {
  MyFree(pass);
- DupString(pass, yylval.text);
+ DupString(pass, $3);
 };
 connectclass: CLASS '=' QSTRING ';'
 {
- c_class = find_class(yylval.text);
+ c_class = find_class($3);
 };
 connecthost: HOST '=' QSTRING ';'
 {
  MyFree(host);
- DupString(host, yylval.text);
+ DupString(host, $3);
 };
 connectport: PORT '=' NUMBER ';'
 {
- port = yylval.num;
+ port = $3;
 };
-
-serverblock: SERVER
+connectvhost: VHOST '=' QSTRING ';'
 {
- aconf = (struct ConfItem*) MyMalloc(sizeof(*aconf));
- memset(aconf, 0, sizeof(*aconf));
-} '{' serveritems '}'
-{
- if (aconf->status == 0)
- {
-   MyFree(aconf->host);
-   MyFree(aconf->name);
-   MyFree(aconf);
-   aconf = NULL;
-   parse_error("Bad server block");
- }
- else
- {
-   aconf->next = GlobalConfList;
-   GlobalConfList = aconf;
- }
-} ';';
-serveritems: serveritem serveritems | serveritem;
-serveritem: servername | servermask | serverhub | serverleaf |
-             serveruworld | error;
-servername: NAME '=' QSTRING
+ MyFree(origin);
+ DupString(origin, $3);
+};
+connectleaf: LEAF ';'
 {
- MyFree(aconf->name);
- DupString(aconf->name, yylval.text);
-} ';' ;
-servermask: MASK '=' QSTRING
+ maxlinks = 0;
+};
+connecthub: HUB ';'
 {
- MyFree(aconf->host);
- DupString(aconf->host, yylval.text);
-} ';' ;
-/* XXX - perhaps we should do this the hybrid way in connect blocks
- * instead -A1kmm. */
-serverhub: HUB '=' YES ';'
+ MyFree(hub_limit);
+ DupString(hub_limit, "*");
+};
+connecthublimit: HUB '=' QSTRING ';'
 {
aconf->status |= CONF_HUB;
aconf->status &= ~CONF_LEAF;
-}
-| HUB '=' NO
MyFree(hub_limit);
DupString(hub_limit, $3);
+};
+connectmaxhops: MAXHOPS '=' expr ';'
 {
- aconf->status &= ~CONF_HUB;
-} ';'; 
-serverleaf: LEAF '=' YES ';'
+  maxlinks = $3;
+};
+
+uworldblock: UWORLD '{' uworlditems '}' ';'
 {
- if (!(aconf->status & CONF_HUB && aconf->status & CONF_UWORLD))
-  aconf->status |= CONF_LEAF;
+ if (name)
+ {
+  struct ConfItem *aconf = make_conf(CONF_UWORLD);
+  aconf->host = name;
+ }
  else
-  parse_error("Server is both leaf and a hub");
-}
-| LEAF '=' NO ';'
-{
aconf->status &= ~CONF_LEAF;
+ {
+  MyFree(name);
+  parse_error("Bad UWorld block");
+ }
name = NULL;
 };
-serveruworld: UWORLD '=' YES ';'
-{
- aconf->status |= CONF_UWORLD;
- aconf->status &= ~CONF_LEAF;
-}
-| UWORLD '=' NO ';'
+uworlditems: uworlditem uworlditems | uworlditem;
+uworlditem: uworldname | error;
+uworldname: NAME '=' QSTRING ';'
 {
-  aconf->status &= ~CONF_UWORLD;
+ MyFree(name);
+ DupString(name, $3);
 };
 
-operblock: OPER
-{
-  aconf = (struct ConfItem*) MyMalloc(sizeof(*aconf));
-  memset(aconf, 0, sizeof(*aconf));
-  aconf->status = CONF_OPERATOR;
-} '{' operitems '}' ';'
+operblock: OPER '{' operitems '}' ';'
 {
-  if (aconf->name != NULL && aconf->passwd != NULL && aconf->host != NULL)
+  if (name && pass && host && c_class)
   {
-    aconf->next = GlobalConfList;
-    GlobalConfList = aconf;
+    struct ConfItem *aconf = make_conf(CONF_OPERATOR);
+    aconf->name = name;
+    aconf->passwd = pass;
+    conf_parse_userhost(aconf, host);
+    aconf->conn_class = c_class;
+    memcpy(&aconf->privs, &privs, sizeof(aconf->privs));
+    memcpy(&aconf->privs_dirty, &privs_dirty, sizeof(aconf->privs_dirty));
+    if (!FlagHas(&privs_dirty, PRIV_PROPAGATE)
+        && !FlagHas(&c_class->privs_dirty, PRIV_PROPAGATE))
+      parse_error("Operator block for %s and class %s have no LOCAL setting", name, c_class->cc_name);
   }
   else
   {
     log_write(LS_CONFIG, L_ERROR, 0, "operator blocks need a name, password, and host.");
-    MyFree(aconf->name);
-    MyFree(aconf->passwd);
-    MyFree(aconf->host);
-    MyFree(aconf);
-    aconf = NULL;
+    MyFree(name);
+    MyFree(pass);
+    MyFree(host);
   }
+  name = pass = host = NULL;
+  c_class = NULL;
+  memset(&privs, 0, sizeof(privs));
+  memset(&privs_dirty, 0, sizeof(privs_dirty));
 };
 operitems: operitem | operitems operitem;
-operitem: opername | operpass | operlocal | operhost | operclass | operpriv | error;
-
+operitem: opername | operpass | operhost | operclass | priv | error;
 opername: NAME '=' QSTRING ';'
 {
-  MyFree(aconf->name);
-  DupString(aconf->name, yylval.text);
+  MyFree(name);
+  DupString(name, $3);
 };
-
 operpass: PASS '=' QSTRING ';'
 {
-  MyFree(aconf->passwd);
-  DupString(aconf->passwd, yylval.text);
-};
-
-operlocal: LOCAL '=' YES ';'
-{
-  /* XXX it would be good to get rid of local operators and add same
-   * permission values here. But for now, I am just going with local 
-   * opers... */
-  aconf->status = CONF_LOCOP;
-} | LOCAL '=' NO ';'
-{
-  aconf->status = CONF_OPERATOR;
+  MyFree(pass);
+  DupString(pass, $3);
 };
-
 operhost: HOST '=' QSTRING ';'
 {
- MyFree(aconf->host);
- if (!strchr(yylval.text, '@'))
+ MyFree(host);
+ if (!strchr($3, '@'))
  {
    int uh_len;
-   char *b = (char*) MyMalloc((uh_len = strlen(yylval.text)+3));
-   ircd_snprintf(0, b, uh_len, "*@%s", yylval.text);
-   aconf->host = b;
+   char *b = (char*) MyMalloc((uh_len = strlen($3)+3));
+   ircd_snprintf(0, b, uh_len, "*@%s", $3);
+   host = b;
  }
  else
-   DupString(aconf->host, yylval.text);
+   DupString(host, $3);
 };
-
 operclass: CLASS '=' QSTRING ';'
 {
aconf->conn_class = find_class(yylval.text);
c_class = find_class($3);
 };
 
-operpriv: privtype '=' yesorno ';'
+priv: privtype '=' yesorno ';'
 {
-  if ($3 == 1)
-  {
-    PrivSet(&aconf->privs_dirty, $1);
-    PrivSet(&aconf->privs, $1);
-  }
+  FlagSet(&privs_dirty, $1);
+  if (($3 == 1) ^ invert)
+    FlagSet(&privs, $1);
   else
-  {
-    PrivSet(&aconf->privs_dirty, $1);
-    PrivClr(&aconf->privs, $1);
-  }
+    FlagClr(&privs, $1);
+  invert = 0;
 };
 
 privtype: TPRIV_CHAN_LIMIT { $$ = PRIV_CHAN_LIMIT; } |
           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; }|
@@ -591,50 +586,46 @@ privtype: TPRIV_CHAN_LIMIT { $$ = PRIV_CHAN_LIMIT; } |
           TPRIV_UNLIMIT_QUERY { $$ = PRIV_UNLIMIT_QUERY; } |
           TPRIV_DISPLAY { $$ = PRIV_DISPLAY; } |
           TPRIV_SEE_OPERS { $$ = PRIV_SEE_OPERS; } |
-          TPRIV_WIDE_GLINE { $$ = PRIV_WIDE_GLINE; };
+          TPRIV_WIDE_GLINE { $$ = PRIV_WIDE_GLINE; } |
+          LOCAL { $$ = PRIV_PROPAGATE; invert = 1; } |
+          TPRIV_FORCE_OPMODE { $$ = PRIV_FORCE_OPMODE; } |
+          TPRIV_FORCE_LOCAL_OPMODE { $$ = PRIV_FORCE_LOCAL_OPMODE; };
 
 yesorno: YES { $$ = 1; } | NO { $$ = 0; };
 
 /* The port block... */
-portblock: PORT {
-  port = 0;
-  host = NULL;
-  /* Hijack these for is_server, is_hidden to cut down on globals... */
-  tconn = 0;
-  tping = 0;
-  /* and this for mask... */
-  pass = NULL;
-} '{' portitems '}' ';'
+portblock: PORT '{' portitems '}' ';'
 {
   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;
+  port = tconn = tping = 0;
 };
 portitems: portitem portitems | portitem;
 portitem: portnumber | portvhost | portmask | portserver | porthidden | error;
 portnumber: PORT '=' NUMBER ';'
 {
-  port = yylval.num;
+  port = $3;
 };
 
 portvhost: VHOST '=' QSTRING ';'
 {
   MyFree(host);
-  DupString(host, yylval.text);
+  DupString(host, $3);
 };
 
 portmask: MASK '=' QSTRING ';'
 {
   MyFree(pass);
-  DupString(pass, yylval.text);
+  DupString(pass, $3);
 };
 
 portserver: SERVER '=' YES ';'
@@ -655,61 +646,59 @@ porthidden: HIDDEN '=' YES ';'
 
 clientblock: CLIENT
 {
-  aconf = (struct ConfItem*) MyMalloc(sizeof(*aconf));
-  memset(aconf, 0, sizeof(*aconf));
-  aconf->status = CONF_CLIENT;
-} '{' clientitems '}'
-{
-  if ((aconf->host != NULL || aconf->name!=NULL))
-  {
-    if (aconf->host == NULL)
-      DupString(aconf->host, "");
-    if (aconf->name == NULL)
-      DupString(aconf->name, "");
-    if (aconf->conn_class == NULL)
-      aconf->conn_class = find_class("default");
-    aconf->next = GlobalConfList;
-    GlobalConfList = aconf;
-    aconf = NULL;
-  }
+  maxlinks = 65535;
+}
+'{' clientitems '}' ';'
+{
+  struct ConfItem *aconf = make_conf(CONF_CLIENT);
+  unsigned char addrbits;
+  aconf->username = username;
+  aconf->host = host;
+  if (ip && ipmask_parse(ip, &aconf->address.addr, &addrbits))
+    aconf->addrbits = addrbits;
   else
-  {
-   MyFree(aconf->host);
-   MyFree(aconf->passwd);
-   MyFree(aconf);
-   aconf = NULL;
-   parse_error("Bad client block");
-  }
-} ';';
+    aconf->addrbits = -1;
+  aconf->conn_class = c_class ? c_class : find_class("default");
+  aconf->maximum = maxlinks;
+  host = NULL;
+  username = NULL;
+  c_class = NULL;
+  MyFree(ip);
+};
 clientitems: clientitem clientitems | clientitem;
-clientitem: clienthost | clientclass | clientpass | clientip | error;
+clientitem: clienthost | clientip | clientusername | clientclass | clientpass | clientmaxlinks | error;
+clienthost: HOST '=' QSTRING ';'
+{
+  MyFree(host);
+  DupString(host, $3);
+};
 clientip: IP '=' QSTRING ';'
 {
-  MyFree(aconf->host);
-  DupString(aconf->host, yylval.text);
+  MyFree(ip);
+  DupString(ip, $3);
 };
-
-clienthost: HOST '=' QSTRING ';'
+clientusername: USERNAME '=' QSTRING ';'
 {
-  MyFree(aconf->name);
-  DupString(aconf->name, yylval.text);
+  MyFree(username);
+  DupString(username, $3);
 };
-
 clientclass: CLASS '=' QSTRING ';'
 {
-  aconf->conn_class = find_class(yylval.text);
+  c_class = find_class($3);
 };
-
 clientpass: PASS '=' QSTRING ';'
 {
-  MyFree(aconf->passwd);
-  DupString(aconf->passwd, yylval.text);
+  MyFree(pass);
+  DupString(pass, $3);
+};
+clientmaxlinks: MAXLINKS '=' expr ';'
+{
+  maxlinks = $3;
 };
 
 killblock: KILL
 {
-  dconf = (struct DenyConf*) MyMalloc(sizeof(*dconf));
-  memset(dconf, 0, sizeof(*dconf));
+  dconf = (struct DenyConf*) MyCalloc(1, sizeof(*dconf));
 } '{' killitems '}'
 {
   if (dconf->hostmask != NULL)
@@ -718,16 +707,15 @@ killblock: KILL
       DupString(dconf->usermask, "*");
     dconf->next = denyConfList;
     denyConfList = dconf;
-    dconf = NULL;
   }
   else
   {
     MyFree(dconf->hostmask);
     MyFree(dconf->message);
     MyFree(dconf);
-    dconf = NULL;
     parse_error("Bad kill block");
   }
+  dconf = NULL;
 } ';';
 killitems: killitem killitems | killitem;
 killitem: killuhost | killreal | killreasonfile | killreason | error;
@@ -737,37 +725,19 @@ killuhost: HOST '=' QSTRING ';'
   dconf->flags &= ~DENY_FLAGS_REALNAME;
   MyFree(dconf->hostmask);
   MyFree(dconf->usermask);
-  if ((h = strchr(yylval.text, '@')) == NULL)
+  if ((h = strchr($3, '@')) == NULL)
   {
     u = "*";
-    h = yylval.text;
+    h = $3;
   }
   else
   {
-    u = yylval.text;
+    u = $3;
     h++;
   }
   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 ';'
@@ -776,28 +746,27 @@ killreal: REAL '=' QSTRING ';'
  dconf->flags |= DENY_FLAGS_REALNAME;
  MyFree(dconf->hostmask);
  /* Leave usermask so you can specify user and real... */
- DupString(dconf->hostmask, yylval.text);
+ DupString(dconf->hostmask, $3);
 };
 
 killreason: REASON '=' QSTRING ';'
 {
  dconf->flags &= DENY_FLAGS_FILE;
  MyFree(dconf->message);
- DupString(dconf->message, yylval.text);
+ DupString(dconf->message, $3);
 };
 
 killreasonfile: TFILE '=' QSTRING ';'
 {
  dconf->flags |= DENY_FLAGS_FILE;
  MyFree(dconf->message);
- DupString(dconf->message, yylval.text);
+ DupString(dconf->message, $3);
 };
 
 cruleblock: CRULE
 {
-  host = pass = NULL;
   tconn = CRULE_AUTO;
-} '{' cruleitems '}'
+} '{' cruleitems '}' ';'
 {
   struct CRuleNode *node;
   if (host != NULL && pass != NULL && (node=crule_parse(pass)) != NULL)
@@ -816,7 +785,8 @@ cruleblock: CRULE
     MyFree(pass);
     parse_error("Bad CRule block");
   }
-} ';';
+  host = pass = NULL;
+};
 
 cruleitems: cruleitem cruleitems | cruleitem;
 cruleitem: cruleserver | crulerule | cruleall | error;
@@ -824,14 +794,14 @@ cruleitem: cruleserver | crulerule | cruleall | error;
 cruleserver: SERVER '=' QSTRING ';'
 {
   MyFree(host);
-  collapse(yylval.text);
-  DupString(host, yylval.text);
+  collapse($3);
+  DupString(host, $3);
 };
 
 crulerule: RULE '=' QSTRING ';'
 {
  MyFree(pass);
- DupString(pass, yylval.text);
+ DupString(pass, $3);
 };
 
 cruleall: ALL '=' YES ';'
@@ -842,27 +812,25 @@ cruleall: ALL '=' YES ';'
  tconn = CRULE_AUTO;
 };
 
-motdblock: MOTD {
- pass = host = NULL;
-} '{' motditems '}'
+motdblock: MOTD '{' motditems '}' ';'
 {
   if (host != NULL && pass != NULL)
     motd_add(host, pass);
   MyFree(host);
   MyFree(pass);
   host = pass = NULL;
-} ';';
+};
 
 motditems: motditem motditems | motditem;
 motditem: motdhost | motdfile | error;
 motdhost: HOST '=' QSTRING ';'
 {
-  DupString(host, yylval.text);
+  DupString(host, $3);
 };
 
 motdfile: TFILE '=' QSTRING ';'
 {
-  DupString(pass, yylval.text);
+  DupString(pass, $3);
 };
 
 featuresblock: FEATURES '{' featureitems '}' ';';
@@ -892,16 +860,7 @@ extrastring: QSTRING
 
 quarantineblock: QUARANTINE '{'
 {
-  if (qconf != NULL)
-    qconf = (struct qline*) MyMalloc(sizeof(*qconf));
-  else
-  {
-    if (qconf->chname != NULL)
-      MyFree(qconf->chname);
-    if (qconf->reason != NULL)
-      MyFree(qconf->reason);
-  }
-  memset(qconf, 0, sizeof(*qconf));
+  qconf = (struct qline*) MyCalloc(1, sizeof(*qconf));
 } quarantineitems '}' ';'
 {
   if (qconf->chname == NULL || qconf->reason == NULL)
@@ -917,8 +876,107 @@ quarantineblock: QUARANTINE '{'
 
 quarantineitems: CHANNEL NAME '=' QSTRING ';'
 {
-  DupString(qconf->chname, yylval.text);
+  DupString(qconf->chname, $4);
 } | REASON '=' QSTRING ';'
 {
-  DupString(qconf->reason, yylval.text);
+  DupString(qconf->reason, $3);
+};
+
+pseudoblock: PSEUDO QSTRING '{'
+{
+  smap = MyCalloc(1, sizeof(struct s_map));
+  DupString(smap->command, $2);
+}
+pseudoitems '}' ';'
+{
+  if (!smap->name || !smap->services)
+  {
+    log_write(LS_CONFIG, L_ERROR, 0, "pseudo commands need a service name and list of target nicks.");
+    return 0;
+  }
+  if (register_mapping(smap))
+  {
+    smap->next = GlobalServiceMapList;
+    GlobalServiceMapList = smap;
+  }
+  else
+  {
+    struct nick_host *nh, *next;
+    for (nh = smap->services; nh; nh = next)
+    {
+      next = nh->next;
+      MyFree(nh);
+    }
+    MyFree(smap->name);
+    MyFree(smap->command);
+    MyFree(smap->prepend);
+    MyFree(smap);
+  }
+  smap = NULL;
+};
+
+pseudoitems: pseudoitem pseudoitems | pseudoitem;
+pseudoitem: pseudoname | pseudoprepend | pseudonick | error;
+pseudoname: NAME '=' QSTRING ';'
+{
+  DupString(smap->name, $3);
+};
+pseudoprepend: PREPEND '=' QSTRING ';'
+{
+  DupString(smap->prepend, $3);
+};
+pseudonick: NICK '=' QSTRING ';'
+{
+  char *sep = strchr($3, '@');
+
+  if (sep != NULL) {
+    size_t slen = strlen($3);
+    struct nick_host *nh = MyMalloc(sizeof(*nh) + slen);
+    memcpy(nh->nick, $3, slen + 1);
+    nh->nicklen = sep - $3;
+    nh->next = smap->services;
+    smap->services = nh;
+  }
+};
+
+iauthblock: IAUTH '{'
+{
+  tconn = 60;
+  tping = 60;
+} iauthitems '}' ';'
+{
+  if (!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;
+  port = 0;
+};
+
+iauthitems: iauthitem iauthitems | iauthitem;
+iauthitem: iauthpass | iauthhost | iauthport | iauthconnfreq | iauthtimeout | error;
+iauthpass: PASS '=' QSTRING ';'
+{
+  MyFree(pass);
+  DupString(pass, $3);
+};
+iauthhost: HOST '=' QSTRING ';'
+{
+  MyFree(host);
+  DupString(host, $3);
+};
+iauthport: PORT '=' NUMBER ';'
+{
+  port = $3;
+};
+iauthconnfreq: CONNECTFREQ '=' timespec ';'
+{
+  tconn = $3;
+};
+iauthtimeout: TIMEOUT '=' timespec ';'
+{
+  tping = $3;
 };