/[svn]/ircd-hybrid/trunk/src/conf_parser.y
ViewVC logotype

Diff of /ircd-hybrid/trunk/src/conf_parser.y

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1646 by michael, Wed Nov 7 21:02:43 2012 UTC revision 1647 by michael, Fri Nov 9 20:11:58 2012 UTC
# Line 58  Line 58 
58    
59  int yylex(void);  int yylex(void);
60    
 static char *class_name = NULL;  
 static struct MaskItem *yy_conf = NULL;  
 static struct ClassItem *yy_class = NULL;  
 static char *yy_class_name = NULL;  
   
 static dlink_list col_conf_list  = { NULL, NULL, 0 };  
 static unsigned int listener_flags = 0;  
 static unsigned int regex_ban = 0;  
 static char userbuf[IRCD_BUFSIZE];  
 static char hostbuf[IRCD_BUFSIZE];  
 static char reasonbuf[REASONLEN + 1];  
 static char gecos_name[REALLEN * 4];  
 static char lfile[IRCD_BUFSIZE];  
 static unsigned int ltype = 0;  
 static unsigned int lsize = 0;  
 static char *resv_reason = NULL;  
 static char *listener_address = NULL;  
   
61  static struct  static struct
62  {  {
63    struct {    struct {
# Line 90  static struct Line 72  static struct
72      user,      user,
73      host,      host,
74      addr,      addr,
75      pass,      bind,
76      file,      file,
77        ciph,
78        rpass,
79        spass,
80      class;      class;
81    
82    struct {    struct {
83      unsigned int value;      unsigned int value;
84    } flags,    } flags,
85      modes,      modes,
86        size,
87        type,
88      port,      port,
89        aftype,
90      ping_freq,      ping_freq,
91      max_perip,      max_perip,
92      con_freq,      con_freq,
# Line 832  logging_use_logging: USE_LOGGING '=' TBO Line 820  logging_use_logging: USE_LOGGING '=' TBO
820    
821  logging_file_entry:  logging_file_entry:
822  {  {
823    lfile[0] = '\0';    if (conf_parser_ctx.pass == 2)
824    ltype = 0;      reset_block_state();
   lsize = 0;  
825  } T_FILE  '{' logging_file_items '}' ';'  } T_FILE  '{' logging_file_items '}' ';'
826  {  {
827    if (conf_parser_ctx.pass == 2 && ltype > 0)    if (conf_parser_ctx.pass != 2)
828      log_add_file(ltype, lsize, lfile);      break;
829    
830      if (block_state.type.value && block_state.file.buf[0])
831        log_add_file(block_state.type.value, block_state.size.value,
832                     block_state.file.buf);
833  };  };
834    
835  logging_file_items: logging_file_items logging_file_item |  logging_file_items: logging_file_items logging_file_item |
# Line 849  logging_file_item:  logging_file_name | Line 840  logging_file_item:  logging_file_name |
840    
841  logging_file_name: NAME '=' QSTRING ';'  logging_file_name: NAME '=' QSTRING ';'
842  {  {
843    strlcpy(lfile, yylval.string, sizeof(lfile));    if (conf_parser_ctx.pass != 2)
844        break;
845    
846      strlcpy(block_state.file.buf, yylval.string, sizeof(block_state.file.buf));
847  }  }
848    
849  logging_file_size: T_SIZE '=' sizespec ';'  logging_file_size: T_SIZE '=' sizespec ';'
850  {  {
851    lsize = $3;    block_state.size.value = $3;
852  } | T_SIZE '=' T_UNLIMITED ';'  } | T_SIZE '=' T_UNLIMITED ';'
853  {  {
854    lsize = 0;    block_state.size.value = 0;
855  };  };
856    
857  logging_file_type: TYPE  logging_file_type: TYPE
858  {  {
859    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
860      ltype = 0;      block_state.type.value = 0;
861  } '='  logging_file_type_items ';' ;  } '='  logging_file_type_items ';' ;
862    
863  logging_file_type_items: logging_file_type_items ',' logging_file_type_item | logging_file_type_item;  logging_file_type_items: logging_file_type_items ',' logging_file_type_item | logging_file_type_item;
864  logging_file_type_item:  USER  logging_file_type_item:  USER
865  {  {
866    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
867      ltype = LOG_TYPE_USER;      block_state.type.value = LOG_TYPE_USER;
868  } | OPERATOR  } | OPERATOR
869  {  {
870    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
871      ltype = LOG_TYPE_OPER;      block_state.type.value = LOG_TYPE_OPER;
872  } | GLINE  } | GLINE
873  {  {
874    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
875      ltype = LOG_TYPE_GLINE;      block_state.type.value = LOG_TYPE_GLINE;
876  } | T_DLINE  } | T_DLINE
877  {  {
878    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
879      ltype = LOG_TYPE_DLINE;      block_state.type.value = LOG_TYPE_DLINE;
880  } | KLINE  } | KLINE
881  {  {
882    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
883      ltype = LOG_TYPE_KLINE;      block_state.type.value = LOG_TYPE_KLINE;
884  } | KILL  } | KILL
885  {  {
886    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
887      ltype = LOG_TYPE_KILL;      block_state.type.value = LOG_TYPE_KILL;
888  } | T_DEBUG  } | T_DEBUG
889  {  {
890    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
891      ltype = LOG_TYPE_DEBUG;      block_state.type.value = LOG_TYPE_DEBUG;
892  };  };
893    
894    
# Line 919  oper_entry: OPERATOR Line 913  oper_entry: OPERATOR
913      break;      break;
914  #ifdef HAVE_LIBCRYPTO  #ifdef HAVE_LIBCRYPTO
915    if (!(block_state.file.buf[0] ||    if (!(block_state.file.buf[0] ||
916          block_state.pass.buf[0]))          block_state.rpass.buf[0]))
917      break;      break;
918  #else  #else
919    if (!block_state.pass.buf[0])    if (!block_state.rpass.buf[0])
920      break;      break;
921  #endif  #endif
922    
# Line 933  oper_entry: OPERATOR Line 927  oper_entry: OPERATOR
927    
928      nuh.nuhmask  = ptr->data;      nuh.nuhmask  = ptr->data;
929      nuh.nickptr  = NULL;      nuh.nickptr  = NULL;
930      nuh.userptr  = userbuf;      nuh.userptr  = block_state.user.buf;
931      nuh.hostptr  = hostbuf;      nuh.hostptr  = block_state.host.buf;
932      nuh.nicksize = 0;      nuh.nicksize = 0;
933      nuh.usersize = sizeof(userbuf);      nuh.usersize = sizeof(block_state.user.buf);
934      nuh.hostsize = sizeof(hostbuf);      nuh.hostsize = sizeof(block_state.host.buf);
935      split_nuh(&nuh);      split_nuh(&nuh);
936    
937      conf        = conf_make(CONF_OPER);      conf        = conf_make(CONF_OPER);
938      conf->user  = xstrdup(userbuf);      conf->user  = xstrdup(block_state.user.buf);
939      conf->host  = xstrdup(hostbuf);      conf->host  = xstrdup(block_state.host.buf);
940    
941      if (block_state.pass.buf[0])      if (block_state.rpass.buf[0])
942        conf->passwd = xstrdup(block_state.pass.buf);        conf->passwd = xstrdup(block_state.rpass.buf);
943    
944      conf->flags = block_state.flags.value;      conf->flags = block_state.flags.value;
945      conf->modes = block_state.modes.value;      conf->modes = block_state.modes.value;
# Line 1000  oper_user: USER '=' QSTRING ';' Line 994  oper_user: USER '=' QSTRING ';'
994  oper_password: PASSWORD '=' QSTRING ';'  oper_password: PASSWORD '=' QSTRING ';'
995  {  {
996    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
997      strlcpy(block_state.pass.buf, yylval.string, sizeof(block_state.pass.buf));      strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
998  };  };
999    
1000  oper_encrypted: ENCRYPTED '=' TBOOL ';'  oper_encrypted: ENCRYPTED '=' TBOOL ';'
# Line 1207  oper_flags_item: GLOBAL_KILL Line 1201  oper_flags_item: GLOBAL_KILL
1201  class_entry: CLASS  class_entry: CLASS
1202  {  {
1203    if (conf_parser_ctx.pass == 1)    if (conf_parser_ctx.pass == 1)
1204    {      reset_block_state();
     yy_class = class_make();  
   }  
1205  } '{' class_items '}' ';'  } '{' class_items '}' ';'
1206  {  {
1207    if (conf_parser_ctx.pass == 1)    struct ClassItem *class = NULL;
   {  
     struct ClassItem *class = NULL;  
1208    
1209      if (yy_class_name == NULL)    if (conf_parser_ctx.pass != 1)
1210        class_free(yy_class);      break;
     else  
     {  
       class = class_find(yy_class_name, 0);  
   
       if (class != NULL)                /* The class existed already */  
       {  
         int user_count = 0;  
   
         rebuild_cidr_class(class, yy_class);  
   
         user_count = class->ref_count;  
         memcpy(class, yy_class, sizeof(*class));  
         class->ref_count = user_count;  
         class->active = 1;  
1211    
1212          class_free(yy_class);    if (!block_state.class.buf[0])
1213        break;
1214    
1215          MyFree(class->name);            /* Allows case change of class name */    if (!(class = class_find(block_state.class.buf, 0)))
1216          class->name = yy_class_name;      class = class_make();
       }  
       else      /* Brand new class */  
       {  
         MyFree(yy_class->name);          /* just in case it was allocated */  
         yy_class->name = yy_class_name;  
         yy_class->active = 1;  
       }  
     }  
1217    
1218      yy_class_name = NULL;    class->active = 1;
1219    }    MyFree(class->name);
1220      class->name = xstrdup(block_state.class.buf);
1221      class->ping_freq = block_state.ping_freq.value;
1222      class->max_perip = block_state.max_perip.value;
1223      class->con_freq = block_state.con_freq.value;
1224      class->max_total = block_state.max_total.value;
1225      class->max_global = block_state.max_global.value;
1226      class->max_local = block_state.max_local.value;
1227      class->max_ident = block_state.max_ident.value;
1228      class->max_sendq = block_state.max_sendq.value;
1229      class->max_recvq = block_state.max_recvq.value;
1230    
1231      if (class->number_per_cidr && block_state.number_per_cidr.value)
1232        if ((class->cidr_bitlen_ipv4 && block_state.cidr_bitlen_ipv4.value) ||
1233            (class->cidr_bitlen_ipv6 && block_state.cidr_bitlen_ipv6.value))
1234          if ((class->cidr_bitlen_ipv4 != block_state.cidr_bitlen_ipv4.value) ||
1235              (class->cidr_bitlen_ipv6 != block_state.cidr_bitlen_ipv6.value))
1236            rebuild_cidr_list(class);
1237    
1238      class->cidr_bitlen_ipv4 = block_state.cidr_bitlen_ipv4.value;
1239      class->cidr_bitlen_ipv6 = block_state.cidr_bitlen_ipv6.value;
1240      class->number_per_cidr = block_state.number_per_cidr.value;
1241  };  };
1242    
1243  class_items:    class_items class_item | class_item;  class_items:    class_items class_item | class_item;
# Line 1267  class_item:     class_name | Line 1257  class_item:     class_name |
1257  class_name: NAME '=' QSTRING ';'  class_name: NAME '=' QSTRING ';'
1258  {  {
1259    if (conf_parser_ctx.pass == 1)    if (conf_parser_ctx.pass == 1)
1260    {      strlcpy(block_state.class.buf, yylval.string, sizeof(block_state.class.buf));
     MyFree(yy_class_name);  
     yy_class_name = xstrdup(yylval.string);  
   }  
1261  };  };
1262    
1263  class_ping_time: PING_TIME '=' timespec ';'  class_ping_time: PING_TIME '=' timespec ';'
1264  {  {
1265    if (conf_parser_ctx.pass == 1)    if (conf_parser_ctx.pass == 1)
1266      yy_class->ping_freq = $3;      block_state.ping_freq.value = $3;
1267  };  };
1268    
1269  class_number_per_ip: NUMBER_PER_IP '=' NUMBER ';'  class_number_per_ip: NUMBER_PER_IP '=' NUMBER ';'
1270  {  {
1271    if (conf_parser_ctx.pass == 1)    if (conf_parser_ctx.pass == 1)
1272      yy_class->max_perip = $3;      block_state.max_perip.value = $3;
1273  };  };
1274    
1275  class_connectfreq: CONNECTFREQ '=' timespec ';'  class_connectfreq: CONNECTFREQ '=' timespec ';'
1276  {  {
1277    if (conf_parser_ctx.pass == 1)    if (conf_parser_ctx.pass == 1)
1278      yy_class->con_freq = $3;      block_state.con_freq.value = $3;
1279  };  };
1280    
1281  class_max_number: MAX_NUMBER '=' NUMBER ';'  class_max_number: MAX_NUMBER '=' NUMBER ';'
1282  {  {
1283    if (conf_parser_ctx.pass == 1)    if (conf_parser_ctx.pass == 1)
1284      yy_class->max_total = $3;      block_state.max_total.value = $3;
1285  };  };
1286    
1287  class_max_global: MAX_GLOBAL '=' NUMBER ';'  class_max_global: MAX_GLOBAL '=' NUMBER ';'
1288  {  {
1289    if (conf_parser_ctx.pass == 1)    if (conf_parser_ctx.pass == 1)
1290      yy_class->max_global = $3;      block_state.max_global.value = $3;
1291  };  };
1292    
1293  class_max_local: MAX_LOCAL '=' NUMBER ';'  class_max_local: MAX_LOCAL '=' NUMBER ';'
1294  {  {
1295    if (conf_parser_ctx.pass == 1)    if (conf_parser_ctx.pass == 1)
1296      yy_class->max_local = $3;      block_state.max_local.value = $3;
1297  };  };
1298    
1299  class_max_ident: MAX_IDENT '=' NUMBER ';'  class_max_ident: MAX_IDENT '=' NUMBER ';'
1300  {  {
1301    if (conf_parser_ctx.pass == 1)    if (conf_parser_ctx.pass == 1)
1302      yy_class->max_ident = $3;      block_state.max_ident.value = $3;
1303  };  };
1304    
1305  class_sendq: SENDQ '=' sizespec ';'  class_sendq: SENDQ '=' sizespec ';'
1306  {  {
1307    if (conf_parser_ctx.pass == 1)    if (conf_parser_ctx.pass == 1)
1308      yy_class->max_sendq = $3;      block_state.max_sendq.value = $3;
1309  };  };
1310    
1311  class_recvq: T_RECVQ '=' sizespec ';'  class_recvq: T_RECVQ '=' sizespec ';'
1312  {  {
1313    if (conf_parser_ctx.pass == 1)    if (conf_parser_ctx.pass == 1)
1314      if ($3 >= CLIENT_FLOOD_MIN && $3 <= CLIENT_FLOOD_MAX)      if ($3 >= CLIENT_FLOOD_MIN && $3 <= CLIENT_FLOOD_MAX)
1315        yy_class->max_recvq = $3;        block_state.max_recvq.value = $3;
1316  };  };
1317    
1318  class_cidr_bitlen_ipv4: CIDR_BITLEN_IPV4 '=' NUMBER ';'  class_cidr_bitlen_ipv4: CIDR_BITLEN_IPV4 '=' NUMBER ';'
1319  {  {
1320    if (conf_parser_ctx.pass == 1)    if (conf_parser_ctx.pass == 1)
1321      yy_class->cidr_bitlen_ipv4 = $3 > 32 ? 32 : $3;      block_state.cidr_bitlen_ipv4.value = $3 > 32 ? 32 : $3;
1322  };  };
1323    
1324  class_cidr_bitlen_ipv6: CIDR_BITLEN_IPV6 '=' NUMBER ';'  class_cidr_bitlen_ipv6: CIDR_BITLEN_IPV6 '=' NUMBER ';'
1325  {  {
1326    if (conf_parser_ctx.pass == 1)    if (conf_parser_ctx.pass == 1)
1327      yy_class->cidr_bitlen_ipv6 = $3 > 128 ? 128 : $3;      block_state.cidr_bitlen_ipv6.value = $3 > 128 ? 128 : $3;
1328  };  };
1329    
1330  class_number_per_cidr: NUMBER_PER_CIDR '=' NUMBER ';'  class_number_per_cidr: NUMBER_PER_CIDR '=' NUMBER ';'
1331  {  {
1332    if (conf_parser_ctx.pass == 1)    if (conf_parser_ctx.pass == 1)
1333      yy_class->number_per_cidr = $3;      block_state.number_per_cidr.value = $3;
1334  };  };
1335    
1336  /***************************************************************************  /***************************************************************************
# Line 1368  listen_flags_item: T_SSL Line 1355  listen_flags_item: T_SSL
1355  } | HIDDEN  } | HIDDEN
1356  {  {
1357    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1358      block_state.flags.value |=LISTENER_HIDDEN;      block_state.flags.value |= LISTENER_HIDDEN;
1359  } | T_SERVER  } | T_SERVER
1360  {  {
1361    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1362     block_state.flags.value |=LISTENER_SERVER;     block_state.flags.value |= LISTENER_SERVER;
1363  };  };
1364    
1365  listen_items:   listen_items listen_item | listen_item;  listen_items:   listen_items listen_item | listen_item;
# Line 1449  auth_entry: IRCD_AUTH Line 1436  auth_entry: IRCD_AUTH
1436    
1437      nuh.nuhmask  = ptr->data;      nuh.nuhmask  = ptr->data;
1438      nuh.nickptr  = NULL;      nuh.nickptr  = NULL;
1439      nuh.userptr  = userbuf;      nuh.userptr  = block_state.user.buf;
1440      nuh.hostptr  = hostbuf;      nuh.hostptr  = block_state.host.buf;
1441      nuh.nicksize = 0;      nuh.nicksize = 0;
1442      nuh.usersize = sizeof(userbuf);      nuh.usersize = sizeof(block_state.user.buf);
1443      nuh.hostsize = sizeof(hostbuf);      nuh.hostsize = sizeof(block_state.host.buf);
1444      split_nuh(&nuh);      split_nuh(&nuh);
1445    
1446      conf        = conf_make(CONF_CLIENT);      conf        = conf_make(CONF_CLIENT);
1447      conf->user  = xstrdup(collapse(userbuf));      conf->user  = xstrdup(collapse(block_state.user.buf));
1448      conf->host  = xstrdup(collapse(hostbuf));      conf->host  = xstrdup(collapse(block_state.host.buf));
1449    
1450      if (block_state.pass.buf[0])      if (block_state.rpass.buf[0])
1451        conf->passwd = xstrdup(block_state.pass.buf);        conf->passwd = xstrdup(block_state.rpass.buf);
1452      if (block_state.name.buf[0])      if (block_state.name.buf[0])
1453        conf->passwd = xstrdup(block_state.name.buf);        conf->passwd = xstrdup(block_state.name.buf);
1454    
# Line 1487  auth_user: USER '=' QSTRING ';' Line 1474  auth_user: USER '=' QSTRING ';'
1474  auth_passwd: PASSWORD '=' QSTRING ';'  auth_passwd: PASSWORD '=' QSTRING ';'
1475  {  {
1476    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1477      strlcpy(block_state.pass.buf, yylval.string, sizeof(block_state.pass.buf));      strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
1478  };  };
1479    
1480  auth_class: CLASS '=' QSTRING ';'  auth_class: CLASS '=' QSTRING ';'
# Line 1579  auth_redir_port: REDIRPORT '=' NUMBER '; Line 1566  auth_redir_port: REDIRPORT '=' NUMBER ';
1566  {  {
1567    if (conf_parser_ctx.pass != 2)    if (conf_parser_ctx.pass != 2)
1568      break;      break;
1569    
1570    block_state.flags.value |= CONF_FLAGS_REDIR;    block_state.flags.value |= CONF_FLAGS_REDIR;
1571    block_state.port.value = $3;    block_state.port.value = $3;
1572  };  };
# Line 1589  auth_redir_port: REDIRPORT '=' NUMBER '; Line 1577  auth_redir_port: REDIRPORT '=' NUMBER ';
1577   ***************************************************************************/   ***************************************************************************/
1578  resv_entry: RESV  resv_entry: RESV
1579  {  {
1580    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass != 2)
1581    {      break;
1582      MyFree(resv_reason);  
1583      resv_reason = NULL;    reset_block_state();
1584    }    strlcpy(block_state.rpass.buf, CONF_NOREASON, sizeof(block_state.rpass.buf));
1585  } '{' resv_items '}' ';'  } '{' resv_items '}' ';';
 {  
   if (conf_parser_ctx.pass == 2)  
   {  
     MyFree(resv_reason);  
     resv_reason = NULL;  
   }  
 };  
1586    
1587  resv_items:     resv_items resv_item | resv_item;  resv_items:     resv_items resv_item | resv_item;
1588  resv_item:      resv_creason | resv_channel | resv_nick | error ';' ;  resv_item:      resv_creason | resv_channel | resv_nick | error ';' ;
# Line 1609  resv_item:     resv_creason | resv_channel | Line 1590  resv_item:     resv_creason | resv_channel |
1590  resv_creason: REASON '=' QSTRING ';'  resv_creason: REASON '=' QSTRING ';'
1591  {  {
1592    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1593    {      strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
     MyFree(resv_reason);  
     resv_reason = xstrdup(yylval.string);  
   }  
1594  };  };
1595    
1596  resv_channel: CHANNEL '=' QSTRING ';'  resv_channel: CHANNEL '=' QSTRING ';'
1597  {  {
1598    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass != 2)
1599    {      break;
     if (IsChanPrefix(*yylval.string))  
     {  
       char def_reason[] = "No reason";  
1600    
1601        create_channel_resv(yylval.string, resv_reason != NULL ? resv_reason : def_reason, 1);    if (IsChanPrefix(*yylval.string))
1602      }      create_channel_resv(yylval.string, block_state.rpass.buf, 1);
   }  
   /* ignore it for now.. but we really should make a warning if  
    * its an erroneous name --fl_ */  
1603  };  };
1604    
1605  resv_nick: NICK '=' QSTRING ';'  resv_nick: NICK '=' QSTRING ';'
1606  {  {
1607    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1608    {      create_nick_resv(yylval.string, block_state.rpass.buf, 1);
     char def_reason[] = "No reason";  
   
     create_nick_resv(yylval.string, resv_reason != NULL ? resv_reason : def_reason, 1);  
   }  
1609  };  };
1610    
1611  /***************************************************************************  /***************************************************************************
# Line 1654  service_name: NAME '=' QSTRING ';' Line 1622  service_name: NAME '=' QSTRING ';'
1622    {    {
1623      if (valid_servname(yylval.string))      if (valid_servname(yylval.string))
1624      {      {
1625        yy_conf = conf_make(CONF_SERVICE);        struct MaskItem *conf = conf_make(CONF_SERVICE);
1626        yy_conf->name = xstrdup(yylval.string);        conf->name = xstrdup(yylval.string);
1627      }      }
1628    }    }
1629  };  };
# Line 1665  service_name: NAME '=' QSTRING ';' Line 1633  service_name: NAME '=' QSTRING ';'
1633   ***************************************************************************/   ***************************************************************************/
1634  shared_entry: T_SHARED  shared_entry: T_SHARED
1635  {  {
1636    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass != 2)
1637    {      break;
1638      yy_conf = conf_make(CONF_ULINE);  
1639      yy_conf->flags = SHARED_ALL;    reset_block_state();
1640    }  
1641      strlcpy(block_state.name.buf, "*", sizeof(block_state.name.buf));
1642      strlcpy(block_state.user.buf, "*", sizeof(block_state.user.buf));
1643      strlcpy(block_state.host.buf, "*", sizeof(block_state.host.buf));
1644      block_state.flags.value = SHARED_ALL;
1645  } '{' shared_items '}' ';'  } '{' shared_items '}' ';'
1646  {  {
1647    if (conf_parser_ctx.pass == 2)    struct MaskItem *conf = NULL;
1648    {  
1649      yy_conf = NULL;    if (conf_parser_ctx.pass != 2)
1650    }      break;
1651    
1652      conf = conf_make(CONF_ULINE);
1653      conf->flags = block_state.flags.value;
1654      conf->name = xstrdup(block_state.name.buf);
1655      conf->user = xstrdup(block_state.user.buf);
1656      conf->user = xstrdup(block_state.host.buf);
1657  };  };
1658    
1659  shared_items: shared_items shared_item | shared_item;  shared_items: shared_items shared_item | shared_item;
# Line 1684  shared_item:  shared_name | shared_user Line 1662  shared_item:  shared_name | shared_user
1662  shared_name: NAME '=' QSTRING ';'  shared_name: NAME '=' QSTRING ';'
1663  {  {
1664    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1665    {      strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
     MyFree(yy_conf->name);  
     DupString(yy_conf->name, yylval.string);  
   }  
1666  };  };
1667    
1668  shared_user: USER '=' QSTRING ';'  shared_user: USER '=' QSTRING ';'
# Line 1698  shared_user: USER '=' QSTRING ';' Line 1673  shared_user: USER '=' QSTRING ';'
1673    
1674      nuh.nuhmask  = yylval.string;      nuh.nuhmask  = yylval.string;
1675      nuh.nickptr  = NULL;      nuh.nickptr  = NULL;
1676      nuh.userptr  = userbuf;      nuh.userptr  = block_state.user.buf;
1677      nuh.hostptr  = hostbuf;      nuh.hostptr  = block_state.host.buf;
1678    
1679      nuh.nicksize = 0;      nuh.nicksize = 0;
1680      nuh.usersize = sizeof(userbuf);      nuh.usersize = sizeof(block_state.user.buf);
1681      nuh.hostsize = sizeof(hostbuf);      nuh.hostsize = sizeof(block_state.host.buf);
1682    
1683      split_nuh(&nuh);      split_nuh(&nuh);
   
     DupString(yy_conf->user, userbuf);  
     DupString(yy_conf->host, hostbuf);  
1684    }    }
1685  };  };
1686    
1687  shared_type: TYPE  shared_type: TYPE
1688  {  {
1689    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1690      yy_conf->flags = 0;      block_state.flags.value = 0;
1691  } '=' shared_types ';' ;  } '=' shared_types ';' ;
1692    
1693  shared_types: shared_types ',' shared_type_item | shared_type_item;  shared_types: shared_types ',' shared_type_item | shared_type_item;
1694  shared_type_item: KLINE  shared_type_item: KLINE
1695  {  {
1696    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1697      yy_conf->flags |= SHARED_KLINE;      block_state.flags.value |= SHARED_KLINE;
1698  } | UNKLINE  } | UNKLINE
1699  {  {
1700    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1701      yy_conf->flags |= SHARED_UNKLINE;      block_state.flags.value |= SHARED_UNKLINE;
1702  } | T_DLINE  } | T_DLINE
1703  {  {
1704    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1705      yy_conf->flags |= SHARED_DLINE;      block_state.flags.value |= SHARED_DLINE;
1706  } | T_UNDLINE  } | T_UNDLINE
1707  {  {
1708    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1709      yy_conf->flags |= SHARED_UNDLINE;      block_state.flags.value |= SHARED_UNDLINE;
1710  } | XLINE  } | XLINE
1711  {  {
1712    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1713      yy_conf->flags |= SHARED_XLINE;      block_state.flags.value |= SHARED_XLINE;
1714  } | T_UNXLINE  } | T_UNXLINE
1715  {  {
1716    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1717      yy_conf->flags |= SHARED_UNXLINE;      block_state.flags.value |= SHARED_UNXLINE;
1718  } | RESV  } | RESV
1719  {  {
1720    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1721      yy_conf->flags |= SHARED_RESV;      block_state.flags.value |= SHARED_RESV;
1722  } | T_UNRESV  } | T_UNRESV
1723  {  {
1724    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1725      yy_conf->flags |= SHARED_UNRESV;      block_state.flags.value |= SHARED_UNRESV;
1726  } | T_LOCOPS  } | T_LOCOPS
1727  {  {
1728    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1729      yy_conf->flags |= SHARED_LOCOPS;      block_state.flags.value |= SHARED_LOCOPS;
1730  } | T_ALL  } | T_ALL
1731  {  {
1732    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1733      yy_conf->flags = SHARED_ALL;      block_state.flags.value = SHARED_ALL;
1734  };  };
1735    
1736  /***************************************************************************  /***************************************************************************
# Line 1766  shared_type_item: KLINE Line 1738  shared_type_item: KLINE
1738   ***************************************************************************/   ***************************************************************************/
1739  cluster_entry: T_CLUSTER  cluster_entry: T_CLUSTER
1740  {  {
1741    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass != 2)
1742    {      break;
1743      yy_conf = conf_make(CONF_CLUSTER);  
1744    }    reset_block_state();
1745    
1746      strlcpy(block_state.name.buf, "*", sizeof(block_state.name.buf));
1747      block_state.flags.value = SHARED_ALL;
1748  } '{' cluster_items '}' ';'  } '{' cluster_items '}' ';'
1749  {  {
1750    if (conf_parser_ctx.pass == 2)    struct MaskItem *conf = NULL;
1751    {  
1752      if (yy_conf->name == NULL)    if (conf_parser_ctx.pass != 2)
1753        DupString(yy_conf->name, "*");      break;
1754      yy_conf = NULL;  
1755    }    conf = conf_make(CONF_CLUSTER);
1756      conf->flags = block_state.flags.value;
1757      conf->name = xstrdup(block_state.name.buf);
1758  };  };
1759    
1760  cluster_items:  cluster_items cluster_item | cluster_item;  cluster_items:  cluster_items cluster_item | cluster_item;
# Line 1786  cluster_item:  cluster_name | cluster_typ Line 1763  cluster_item:  cluster_name | cluster_typ
1763  cluster_name: NAME '=' QSTRING ';'  cluster_name: NAME '=' QSTRING ';'
1764  {  {
1765    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1766      DupString(yy_conf->name, yylval.string);      strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1767  };  };
1768    
1769  cluster_type: TYPE  cluster_type: TYPE
1770  {  {
1771    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1772      yy_conf->flags = 0;      block_state.flags.value = 0;
1773  } '=' cluster_types ';' ;  } '=' cluster_types ';' ;
1774    
1775  cluster_types:  cluster_types ',' cluster_type_item | cluster_type_item;  cluster_types:  cluster_types ',' cluster_type_item | cluster_type_item;
1776  cluster_type_item: KLINE  cluster_type_item: KLINE
1777  {  {
1778    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1779      yy_conf->flags |= SHARED_KLINE;      block_state.flags.value |= SHARED_KLINE;
1780  } | UNKLINE  } | UNKLINE
1781  {  {
1782    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1783      yy_conf->flags |= SHARED_UNKLINE;      block_state.flags.value |= SHARED_UNKLINE;
1784  } | T_DLINE  } | T_DLINE
1785  {  {
1786    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1787      yy_conf->flags |= SHARED_DLINE;      block_state.flags.value |= SHARED_DLINE;
1788  } | T_UNDLINE  } | T_UNDLINE
1789  {  {
1790    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1791      yy_conf->flags |= SHARED_UNDLINE;      block_state.flags.value |= SHARED_UNDLINE;
1792  } | XLINE  } | XLINE
1793  {  {
1794    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1795      yy_conf->flags |= SHARED_XLINE;      block_state.flags.value |= SHARED_XLINE;
1796  } | T_UNXLINE  } | T_UNXLINE
1797  {  {
1798    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1799      yy_conf->flags |= SHARED_UNXLINE;      block_state.flags.value |= SHARED_UNXLINE;
1800  } | RESV  } | RESV
1801  {  {
1802    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1803      yy_conf->flags |= SHARED_RESV;      block_state.flags.value |= SHARED_RESV;
1804  } | T_UNRESV  } | T_UNRESV
1805  {  {
1806    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1807      yy_conf->flags |= SHARED_UNRESV;      block_state.flags.value |= SHARED_UNRESV;
1808  } | T_LOCOPS  } | T_LOCOPS
1809  {  {
1810    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1811      yy_conf->flags |= SHARED_LOCOPS;      block_state.flags.value |= SHARED_LOCOPS;
1812  } | T_ALL  } | T_ALL
1813  {  {
1814    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1815      yy_conf->flags = SHARED_ALL;      block_state.flags.value = SHARED_ALL;
1816  };  };
1817    
1818  /***************************************************************************  /***************************************************************************
# Line 1843  cluster_type_item: KLINE Line 1820  cluster_type_item: KLINE
1820   ***************************************************************************/   ***************************************************************************/
1821  connect_entry: CONNECT    connect_entry: CONNECT  
1822  {  {
   if (conf_parser_ctx.pass == 2)  
   {  
     yy_conf = conf_make(CONF_SERVER);  
1823    
1824      /* defaults */    if (conf_parser_ctx.pass != 2)
1825      yy_conf->port = PORTNUM;      break;
1826    }  
1827    else    reset_block_state();
1828    {    block_state.port.value = PORTNUM;
     MyFree(class_name);  
     class_name = NULL;  
   }  
1829  } '{' connect_items '}' ';'  } '{' connect_items '}' ';'
1830  {  {
1831    if (conf_parser_ctx.pass == 2)    struct MaskItem *conf = NULL;
1832      struct addrinfo hints, *res;
1833    
1834      if (conf_parser_ctx.pass != 2)
1835        break;
1836    
1837      if (!(block_state.name.buf[0] ||
1838            block_state.host.buf[0]))
1839        break;
1840    
1841      if (!(block_state.rpass.buf[0] ||
1842            block_state.spass.buf[0]))
1843        break;
1844    
1845      if (has_wildcards(block_state.name.buf) ||
1846          has_wildcards(block_state.host.buf))
1847        break;
1848    
1849      conf = conf_make(CONF_SERVER);
1850      conf->port = block_state.port.value;
1851      conf->flags = block_state.flags.value;
1852      conf->aftype = block_state.aftype.value;
1853      conf->host = xstrdup(block_state.host.buf);
1854      conf->name = xstrdup(block_state.name.buf);
1855      conf->passwd = xstrdup(block_state.rpass.buf);
1856      conf->spasswd = xstrdup(block_state.spass.buf);
1857      conf->cipher_list = xstrdup(block_state.ciph.buf);
1858    
1859      dlinkMoveList(&block_state.leaf.list, &conf->leaf_list);
1860      dlinkMoveList(&block_state.hub.list, &conf->hub_list);
1861    
1862      if (block_state.bind.buf[0])
1863    {    {
1864      if (yy_conf->host && yy_conf->passwd && yy_conf->spasswd)      memset(&hints, 0, sizeof(hints));
1865      {  
1866        if (conf_add_server(yy_conf, class_name) == -1)      hints.ai_family   = AF_UNSPEC;
1867          conf_free(yy_conf);      hints.ai_socktype = SOCK_STREAM;
1868      }      hints.ai_flags    = AI_PASSIVE | AI_NUMERICHOST;
1869    
1870        if (getaddrinfo(block_state.bind.buf, NULL, &hints, &res))
1871          ilog(LOG_TYPE_IRCD, "Invalid netmask for server vhost(%s)", block_state.bind.buf);
1872      else      else
1873      {      {
1874        if (yy_conf->name != NULL)        assert(res != NULL);
       {  
         if (yy_conf->host == NULL)  
           yyerror("Ignoring connect block -- missing host");  
         else if (!yy_conf->passwd || !yy_conf->spasswd)  
           yyerror("Ignoring connect block -- missing password");  
       }  
1875    
1876        /* XXX        memcpy(&conf->bind, res->ai_addr, res->ai_addrlen);
1877         * This fixes a try_connections() core (caused by invalid class_ptr        conf->bind.ss.ss_family = res->ai_family;
1878         * pointers) reported by metalrock. That's an ugly fix, but there        conf->bind.ss_len = res->ai_addrlen;
1879         * is currently no better way. The entire config subsystem needs an        freeaddrinfo(res);
        * rewrite ASAP. make_conf_item() shouldn't really add things onto  
        * a doubly linked list immediately without any sanity checks!  -Michael  
        */  
       conf_free(yy_conf);  
1880      }      }
   
     MyFree(class_name);  
     class_name = NULL;  
     yy_conf = NULL;  
1881    }    }
1882    
1883      conf_add_class_to_conf(conf, block_state.class.buf);
1884      lookup_confhost(conf);
1885  };  };
1886    
1887  connect_items:  connect_items connect_item | connect_item;  connect_items:  connect_items connect_item | connect_item;
# Line 1901  connect_item:   connect_name | connect_h Line 1895  connect_item:   connect_name | connect_h
1895  connect_name: NAME '=' QSTRING ';'  connect_name: NAME '=' QSTRING ';'
1896  {  {
1897    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1898    {      strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
     MyFree(yy_conf->name);  
     DupString(yy_conf->name, yylval.string);  
   }  
1899  };  };
1900    
1901  connect_host: HOST '=' QSTRING ';'  connect_host: HOST '=' QSTRING ';'
1902  {  {
1903    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1904    {      strlcpy(block_state.host.buf, yylval.string, sizeof(block_state.host.buf));
     MyFree(yy_conf->host);  
     DupString(yy_conf->host, yylval.string);  
   }  
1905  };  };
1906    
1907  connect_vhost: VHOST '=' QSTRING ';'  connect_vhost: VHOST '=' QSTRING ';'
1908  {  {
1909    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1910    {      strlcpy(block_state.bind.buf, yylval.string, sizeof(block_state.bind.buf));
     struct addrinfo hints, *res;  
   
     memset(&hints, 0, sizeof(hints));  
   
     hints.ai_family   = AF_UNSPEC;  
     hints.ai_socktype = SOCK_STREAM;  
     hints.ai_flags    = AI_PASSIVE | AI_NUMERICHOST;  
   
     if (getaddrinfo(yylval.string, NULL, &hints, &res))  
       ilog(LOG_TYPE_IRCD, "Invalid netmask for server vhost(%s)", yylval.string);  
     else  
     {  
       assert(res != NULL);  
   
       memcpy(&yy_conf->bind, res->ai_addr, res->ai_addrlen);  
       yy_conf->bind.ss.ss_family = res->ai_family;  
       yy_conf->bind.ss_len = res->ai_addrlen;  
       freeaddrinfo(res);  
     }  
   }  
1911  };  };
1912    
1913  connect_send_password: SEND_PASSWORD '=' QSTRING ';'  connect_send_password: SEND_PASSWORD '=' QSTRING ';'
1914  {  {
1915    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass != 2)
1916    {      break;
     if ($3[0] == ':')  
       yyerror("Server passwords cannot begin with a colon");  
     else if (strchr($3, ' ') != NULL)  
       yyerror("Server passwords cannot contain spaces");  
     else {  
       if (yy_conf->spasswd != NULL)  
         memset(yy_conf->spasswd, 0, strlen(yy_conf->spasswd));  
1917    
1918        MyFree(yy_conf->spasswd);    if ($3[0] == ':')
1919        DupString(yy_conf->spasswd, yylval.string);      yyerror("Server passwords cannot begin with a colon");
1920      }    else if (strchr($3, ' ') != NULL)
1921    }      yyerror("Server passwords cannot contain spaces");
1922      else
1923        strlcpy(block_state.spass.buf, yylval.string, sizeof(block_state.spass.buf));
1924  };  };
1925    
1926  connect_accept_password: ACCEPT_PASSWORD '=' QSTRING ';'  connect_accept_password: ACCEPT_PASSWORD '=' QSTRING ';'
1927  {  {
1928    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass != 2)
1929    {      break;
     if ($3[0] == ':')  
       yyerror("Server passwords cannot begin with a colon");  
     else if (strchr($3, ' ') != NULL)  
       yyerror("Server passwords cannot contain spaces");  
     else {  
       if (yy_conf->passwd != NULL)  
         memset(yy_conf->passwd, 0, strlen(yy_conf->passwd));  
1930    
1931        MyFree(yy_conf->passwd);    if ($3[0] == ':')
1932        DupString(yy_conf->passwd, yylval.string);      yyerror("Server passwords cannot begin with a colon");
1933      }    else if (strchr($3, ' ') != NULL)
1934    }      yyerror("Server passwords cannot contain spaces");
1935      else
1936        strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
1937  };  };
1938    
1939  connect_port: PORT '=' NUMBER ';'  connect_port: PORT '=' NUMBER ';'
1940  {  {
1941    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1942      yy_conf->port = $3;      block_state.port.value = $3;
1943  };  };
1944    
1945  connect_aftype: AFTYPE '=' T_IPV4 ';'  connect_aftype: AFTYPE '=' T_IPV4 ';'
1946  {  {
1947    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1948      yy_conf->aftype = AF_INET;      block_state.aftype.value = AF_INET;
1949  } | AFTYPE '=' T_IPV6 ';'  } | AFTYPE '=' T_IPV6 ';'
1950  {  {
1951  #ifdef IPV6  #ifdef IPV6
1952    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1953      yy_conf->aftype = AF_INET6;      block_state.aftype.value = AF_INET6;
1954  #endif  #endif
1955  };  };
1956    
1957  connect_flags: IRCD_FLAGS  connect_flags: IRCD_FLAGS
1958  {  {
1959    /* XXX */
1960  } '='  connect_flags_items ';';  } '='  connect_flags_items ';';
1961    
1962  connect_flags_items: connect_flags_items ',' connect_flags_item | connect_flags_item;  connect_flags_items: connect_flags_items ',' connect_flags_item | connect_flags_item;
1963  connect_flags_item: AUTOCONN  connect_flags_item: AUTOCONN
1964  {  {
1965    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1966      SetConfAllowAutoConn(yy_conf);      block_state.flags.value |= CONF_FLAGS_ALLOW_AUTO_CONN;
1967  } | T_SSL  } | T_SSL
1968  {  {
1969    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1970      SetConfSSL(yy_conf);      block_state.flags.value |= CONF_FLAGS_SSL;
1971  };  };
1972    
1973  connect_encrypted: ENCRYPTED '=' TBOOL ';'  connect_encrypted: ENCRYPTED '=' TBOOL ';'
# Line 2016  connect_encrypted: ENCRYPTED '=' TBOOL ' Line 1975  connect_encrypted: ENCRYPTED '=' TBOOL '
1975    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1976    {    {
1977      if (yylval.number)      if (yylval.number)
1978        yy_conf->flags |= CONF_FLAGS_ENCRYPTED;        block_state.flags.value |= CONF_FLAGS_ENCRYPTED;
1979      else      else
1980        yy_conf->flags &= ~CONF_FLAGS_ENCRYPTED;        block_state.flags.value &= ~CONF_FLAGS_ENCRYPTED;
1981    }    }
1982  };  };
1983    
1984  connect_hub_mask: HUB_MASK '=' QSTRING ';'  connect_hub_mask: HUB_MASK '=' QSTRING ';'
1985  {  {
1986    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1987    {      dlinkAdd(xstrdup(yylval.string), make_dlink_node(), &block_state.hub.list);
     char *mask = xstrdup(yylval.string);  
   
     dlinkAdd(mask, make_dlink_node(), &yy_conf->hub_list);  
   }  
1988  };  };
1989    
1990  connect_leaf_mask: LEAF_MASK '=' QSTRING ';'  connect_leaf_mask: LEAF_MASK '=' QSTRING ';'
1991  {  {
1992    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1993    {      dlinkAdd(xstrdup(yylval.string), make_dlink_node(), &block_state.leaf.list);
     char *mask;  
   
     DupString(mask, yylval.string);  
     dlinkAdd(mask, make_dlink_node(), &yy_conf->leaf_list);  
   }  
1994  };  };
1995    
1996  connect_class: CLASS '=' QSTRING ';'  connect_class: CLASS '=' QSTRING ';'
1997  {  {
1998    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
1999    {      strlcpy(block_state.class.buf, yylval.string, sizeof(block_state.class.buf));
     MyFree(class_name);  
     DupString(class_name, yylval.string);  
   }  
2000  };  };
2001    
2002  connect_ssl_cipher_list: T_SSL_CIPHER_LIST '=' QSTRING ';'  connect_ssl_cipher_list: T_SSL_CIPHER_LIST '=' QSTRING ';'
2003  {  {
2004  #ifdef HAVE_LIBCRYPTO  #ifdef HAVE_LIBCRYPTO
2005    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
2006    {      strlcpy(block_state.ciph.buf, yylval.string, sizeof(block_state.ciph.buf));
     MyFree(yy_conf->cipher_list);  
     DupString(yy_conf->cipher_list, yylval.string);  
   }  
2007  #else  #else
2008    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
2009      yyerror("Ignoring connect::ciphers -- no OpenSSL support");      yyerror("Ignoring connect::ciphers -- no OpenSSL support");
# Line 2073  connect_ssl_cipher_list: T_SSL_CIPHER_LI Line 2017  connect_ssl_cipher_list: T_SSL_CIPHER_LI
2017  kill_entry: KILL  kill_entry: KILL
2018  {  {
2019    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
2020    {      reset_block_state();
     userbuf[0] = hostbuf[0] = reasonbuf[0] = '\0';  
     regex_ban = 0;  
   }  
2021  } '{' kill_items '}' ';'  } '{' kill_items '}' ';'
2022  {  {
2023    if (conf_parser_ctx.pass == 2)    struct MaskItem *conf = NULL;
   {  
     struct MaskItem *conf = NULL;  
2024    
2025      if (userbuf[0] && hostbuf[0])    if (conf_parser_ctx.pass != 2)
2026      {      break;
2027        if (regex_ban)  
2028        {    if (!block_state.user.buf[0] ||
2029          !block_state.host.buf[0])
2030        break;
2031    
2032    
2033      if (block_state.port.value == 1)
2034      {
2035  #ifdef HAVE_LIBPCRE  #ifdef HAVE_LIBPCRE
2036          void *exp_user = NULL;      void *exp_user = NULL;
2037          void *exp_host = NULL;      void *exp_host = NULL;
2038          const char *errptr = NULL;      const char *errptr = NULL;
2039    
2040          if (!(exp_user = ircd_pcre_compile(userbuf, &errptr)) ||      if (!(exp_user = ircd_pcre_compile(block_state.user.buf, &errptr)) ||
2041              !(exp_host = ircd_pcre_compile(hostbuf, &errptr)))          !(exp_host = ircd_pcre_compile(block_state.host.buf, &errptr)))
2042          {      {
2043            ilog(LOG_TYPE_IRCD, "Failed to add regular expression based K-Line: %s",        ilog(LOG_TYPE_IRCD, "Failed to add regular expression based K-Line: %s",
2044                 errptr);             errptr);
2045            break;        break;
2046          }      }
   
         conf = conf_make(CONF_RKLINE);  
         conf->regexuser = exp_user;  
         conf->regexhost = exp_host;  
2047    
2048          conf->user = xstrdup(userbuf);      conf = conf_make(CONF_RKLINE);
2049          conf->host = xstrdup(hostbuf);      conf->regexuser = exp_user;
2050        conf->regexhost = exp_host;
2051    
2052          if (reasonbuf[0])      conf->user = xstrdup(block_state.user.buf);
2053            conf->reason = xstrdup(reasonbuf);      conf->host = xstrdup(block_state.host.buf);
2054          else  
2055            conf->reason = xstrdup(CONF_NOREASON);      if (block_state.rpass.buf[0])
2056          conf->reason = xstrdup(block_state.rpass.buf);
2057        else
2058          conf->reason = xstrdup(CONF_NOREASON);
2059  #else  #else
2060          ilog(LOG_TYPE_IRCD, "Failed to add regular expression based K-Line: no PCRE support");      ilog(LOG_TYPE_IRCD, "Failed to add regular expression based K-Line: no PCRE support");
2061          break;      break;
2062  #endif  #endif
2063        }    }
2064        else    else
2065        {    {
2066          conf = conf_make(CONF_KLINE);      conf = conf_make(CONF_KLINE);
2067    
2068          conf->user = xstrdup(userbuf);      conf->user = xstrdup(block_state.user.buf);
2069          conf->host = xstrdup(hostbuf);      conf->host = xstrdup(block_state.host.buf);
2070    
2071          if (reasonbuf[0])      if (block_state.rpass.buf[0])
2072            conf->reason = xstrdup(reasonbuf);        conf->reason = xstrdup(block_state.rpass.buf);
2073          else      else
2074            conf->reason = xstrdup(CONF_NOREASON);        conf->reason = xstrdup(CONF_NOREASON);
2075          add_conf_by_address(CONF_KLINE, conf);      add_conf_by_address(CONF_KLINE, conf);
       }  
     }  
2076    }    }
2077  };  };
2078    
2079  kill_type: TYPE  kill_type: TYPE
2080  {  {
2081      if (conf_parser_ctx.pass == 2)
2082        block_state.port.value = 0;
2083  } '='  kill_type_items ';';  } '='  kill_type_items ';';
2084    
2085  kill_type_items: kill_type_items ',' kill_type_item | kill_type_item;  kill_type_items: kill_type_items ',' kill_type_item | kill_type_item;
2086  kill_type_item: REGEX_T  kill_type_item: REGEX_T
2087  {  {
2088    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
2089      regex_ban = 1;      block_state.port.value = 1;
2090  };  };
2091    
2092  kill_items:     kill_items kill_item | kill_item;  kill_items:     kill_items kill_item | kill_item;
# Line 2149  kill_item:      kill_user | kill_reason Line 2094  kill_item:      kill_user | kill_reason
2094    
2095  kill_user: USER '=' QSTRING ';'  kill_user: USER '=' QSTRING ';'
2096  {  {
2097    
2098    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
2099    {    {
2100      struct split_nuh_item nuh;      struct split_nuh_item nuh;
2101    
2102      nuh.nuhmask  = yylval.string;      nuh.nuhmask  = yylval.string;
2103      nuh.nickptr  = NULL;      nuh.nickptr  = NULL;
2104      nuh.userptr  = userbuf;      nuh.userptr  = block_state.user.buf;
2105      nuh.hostptr  = hostbuf;      nuh.hostptr  = block_state.host.buf;
2106    
2107      nuh.nicksize = 0;      nuh.nicksize = 0;
2108      nuh.usersize = sizeof(userbuf);      nuh.usersize = sizeof(block_state.user.buf);
2109      nuh.hostsize = sizeof(hostbuf);      nuh.hostsize = sizeof(block_state.host.buf);
2110    
2111      split_nuh(&nuh);      split_nuh(&nuh);
2112    }    }
# Line 2169  kill_user: USER '=' QSTRING ';' Line 2115  kill_user: USER '=' QSTRING ';'
2115  kill_reason: REASON '=' QSTRING ';'  kill_reason: REASON '=' QSTRING ';'
2116  {  {
2117    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
2118      strlcpy(reasonbuf, yylval.string, sizeof(reasonbuf));      strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
2119  };  };
2120    
2121  /***************************************************************************  /***************************************************************************
# Line 2194  deny_entry: DENY Line 2140  deny_entry: DENY
2140      conf = conf_make(CONF_DLINE);      conf = conf_make(CONF_DLINE);
2141      conf->host = xstrdup(block_state.addr.buf);      conf->host = xstrdup(block_state.addr.buf);
2142    
2143      if (block_state.pass.buf[0])      if (block_state.rpass.buf[0])
2144        conf->reason = xstrdup(block_state.pass.buf);        conf->reason = xstrdup(block_state.rpass.buf);
2145      else      else
2146        conf->reason = xstrdup(CONF_NOREASON);        conf->reason = xstrdup(CONF_NOREASON);
2147      add_conf_by_address(CONF_DLINE, conf);      add_conf_by_address(CONF_DLINE, conf);
# Line 2214  deny_ip: IP '=' QSTRING ';' Line 2160  deny_ip: IP '=' QSTRING ';'
2160  deny_reason: REASON '=' QSTRING ';'  deny_reason: REASON '=' QSTRING ';'
2161  {  {
2162    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
2163      strlcpy(block_state.pass.buf, yylval.string, sizeof(block_state.pass.buf));      strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
2164  };  };
2165    
2166  /***************************************************************************  /***************************************************************************
# Line 2281  gecos_entry: GECOS Line 2227  gecos_entry: GECOS
2227    
2228    conf->name = xstrdup(block_state.name.buf);    conf->name = xstrdup(block_state.name.buf);
2229    
2230    if (block_state.pass.buf[0])    if (block_state.rpass.buf[0])
2231      conf->reason = xstrdup(block_state.pass.buf);      conf->reason = xstrdup(block_state.rpass.buf);
2232    else    else
2233      conf->reason = xstrdup(CONF_NOREASON);      conf->reason = xstrdup(CONF_NOREASON);
2234  };  };
# Line 2312  gecos_name: NAME '=' QSTRING ';' Line 2258  gecos_name: NAME '=' QSTRING ';'
2258  gecos_reason: REASON '=' QSTRING ';'  gecos_reason: REASON '=' QSTRING ';'
2259  {  {
2260    if (conf_parser_ctx.pass == 2)    if (conf_parser_ctx.pass == 2)
2261      strlcpy(block_state.pass.buf, yylval.string, sizeof(block_state.pass.buf));      strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
2262  };  };
2263    
2264  /***************************************************************************  /***************************************************************************

Legend:
Removed from v.1646  
changed lines
  Added in v.1647

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28