ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-8/src/s_conf.c
(Generate patch)

Comparing ircd-hybrid-7.2/src/s_conf.c (file contents):
Revision 575 by michael, Mon May 1 11:41:09 2006 UTC vs.
Revision 593 by michael, Fri May 12 05:47:32 2006 UTC

# Line 87 | Line 87 | extern char linebuf[];
87   extern char conffilebuf[IRCD_BUFSIZE];
88   extern char yytext[];
89   extern int yyparse(); /* defined in y.tab.c */
90 < unsigned int scount = 0; /* used by yyparse(), etc */
91 < int ypass  = 1; /* used by yyparse()      */
90 > int ypass = 1; /* used by yyparse()      */
91  
92   /* internally defined functions */
93   static void lookup_confhost(struct ConfItem *);
# Line 1965 | Line 1964 | set_default_conf(void)
1964   static void
1965   read_conf(FBFILE *file)
1966   {
1967 <  scount = lineno = 0;
1967 >  lineno = 0;
1968  
1969    set_default_conf(); /* Set default values prior to conf parsing */
1970    ypass = 1;
# Line 3061 | Line 3060 | conf_add_class_to_conf(struct ConfItem *
3060   * side effects - Add a connect block
3061   */
3062   int
3063 < conf_add_server(struct ConfItem *conf, unsigned int lcount, const char *class_name)
3063 > conf_add_server(struct ConfItem *conf, const char *class_name)
3064   {
3065    struct AccessItem *aconf;
3066 <  char *orig_host;
3066 >  struct split_nuh_item nuh;
3067 >  char conf_user[USERLEN + 1];
3068 >  char conf_host[HOSTLEN + 1];
3069  
3070    aconf = map_to_conf(conf);
3071  
3072    conf_add_class_to_conf(conf, class_name);
3073  
3074 <  if (lcount > MAXCONFLINKS || !aconf->host || !conf->name)
3074 >  if (!aconf->host || !conf->name)
3075    {
3076      sendto_realops_flags(UMODE_ALL, L_ALL, "Bad connect block");
3077      ilog(L_WARN, "Bad connect block");
# Line 3085 | Line 3086 | conf_add_server(struct ConfItem *conf, u
3086      return -1;
3087    }
3088  
3089 <  orig_host = aconf->host;
3090 <  split_nuh(orig_host, NULL, &aconf->user, &aconf->host);
3091 <  MyFree(orig_host);
3089 >  nuh.nuhmask  = aconf->host;
3090 >  nuh.nickptr  = NULL;
3091 >  nuh.userptr  = conf_user;
3092 >  nuh.hostptr  = conf_host;
3093 >
3094 >  nuh.nicksize = 0;
3095 >  nuh.usersize = sizeof(conf_user);
3096 >  nuh.hostsize = sizeof(conf_host);
3097 >
3098 >  split_nuh(&nuh);
3099 >
3100 >  MyFree(aconf->host);
3101 >  aconf->host = NULL;
3102 >
3103 >  DupString(aconf->user, conf_user); /* somehow username checking for servers
3104 >                                 got lost in H6/7, will have to be re-added */
3105 >  DupString(aconf->host, conf_host);
3106 >
3107    lookup_confhost(conf);
3108  
3109    return 0;
# Line 3447 | Line 3463 | find_user_host(struct Client *source_p,
3463    {
3464      /* Explicit user@host mask given */
3465  
3466 <    if(hostp != NULL)                            /* I'm a little user@host */
3466 >    if (hostp != NULL)                            /* I'm a little user@host */
3467      {
3468        *(hostp++) = '\0';                       /* short and squat */
3469        if (*user_host_or_nick)
# Line 3578 | Line 3594 | match_conf_password(const char *password
3594   */
3595   void
3596   cluster_a_line(struct Client *source_p, const char *command,
3597 <               int capab, int cluster_type, const char *pattern, ...)
3597 >               int capab, int cluster_type, const char *pattern, ...)
3598   {
3599    va_list args;
3600    char buffer[IRCD_BUFSIZE];
3601 <  struct ConfItem *conf;
3586 <  dlink_node *ptr;
3601 >  const dlink_node *ptr = NULL;
3602  
3603    va_start(args, pattern);
3604    vsnprintf(buffer, sizeof(buffer), pattern, args);
# Line 3591 | Line 3606 | cluster_a_line(struct Client *source_p,
3606  
3607    DLINK_FOREACH(ptr, cluster_items.head)
3608    {
3609 <    conf = ptr->data;
3609 >    const struct ConfItem *conf = ptr->data;
3610  
3611      if (conf->flags & cluster_type)
3597    {
3612        sendto_match_servs(source_p, conf->name, CAP_CLUSTER|capab,
3613                           "%s %s %s", command, conf->name, buffer);
3600    }
3614    }
3615   }
3616  
# Line 3629 | Line 3642 | cluster_a_line(struct Client *source_p,
3642   * @                            *       *       *
3643   * !                            *       *       *
3644   */
3632
3645   void
3646 < split_nuh(char *mask, char **nick, char **user, char **host)
3646 > split_nuh(struct split_nuh_item *const iptr)
3647   {
3648    char *p = NULL, *q = NULL;
3649  
3650 <  if ((p = strchr(mask, '!')) != NULL)
3650 >  if (iptr->nickptr)
3651 >    strlcpy(iptr->nickptr, "*", iptr->nicksize);
3652 >  if (iptr->userptr)
3653 >    strlcpy(iptr->userptr, "*", iptr->usersize);
3654 >  if (iptr->hostptr)
3655 >    strlcpy(iptr->hostptr, "*", iptr->hostsize);
3656 >
3657 >  if ((p = strchr(iptr->nuhmask, '!')))
3658    {
3659      *p = '\0';
3641    if (nick != NULL)
3642    {
3643      if (*mask != '\0')
3644        *nick = xstrldup(mask, NICKLEN);
3645      else
3646        DupString(*nick, "*");
3647    }
3660  
3661 <    if ((q = strchr(++p, '@')) != NULL)
3662 <    {
3663 <      *q = '\0';
3661 >    if (iptr->nickptr && *iptr->nuhmask != '\0')
3662 >      strlcpy(iptr->nickptr, iptr->nuhmask, iptr->nicksize);
3663 >
3664 >    if ((q = strchr(++p, '@'))) {
3665 >      *q++ = '\0';
3666  
3667        if (*p != '\0')
3668 <        *user = xstrldup(p, USERLEN+1);
3655 <      else
3656 <        DupString(*user, "*");
3668 >        strlcpy(iptr->userptr, p, iptr->usersize);
3669  
3670 <      if (*++q != '\0')
3671 <        *host = xstrldup(q, HOSTLEN+1);
3660 <      else
3661 <        DupString(*host, "*");
3670 >      if (*q != '\0')
3671 >        strlcpy(iptr->hostptr, q, iptr->hostsize);
3672      }
3673      else
3674      {
3675        if (*p != '\0')
3676 <        *user = xstrldup(p, USERLEN+1);
3667 <      else
3668 <        DupString(*user, "*");
3669 <
3670 <      DupString(*host, "*");
3676 >        strlcpy(iptr->userptr, p, iptr->usersize);
3677      }
3678    }
3679 <  else  /* No ! found so lets look for a user@host */
3679 >  else
3680    {
3681 <    if ((p = strchr(mask, '@')) != NULL)        /* if found a @ */
3681 >    /* No ! found so lets look for a user@host */
3682 >    if ((p = strchr(iptr->nuhmask, '@')))
3683      {
3684 <      if (nick != NULL)
3685 <        DupString(*nick, "*");
3679 <      *p = '\0';
3684 >      /* if found a @ */
3685 >      *p++ = '\0';
3686  
3687 <      if (*mask != '\0')
3688 <        *user = xstrldup(mask, USERLEN+1);
3683 <      else
3684 <        DupString(*user, "*");
3687 >      if (*iptr->nuhmask != '\0')
3688 >        strlcpy(iptr->userptr, iptr->nuhmask, iptr->usersize);
3689  
3690 <      if (*++p != '\0')
3691 <        *host = xstrldup(p, HOSTLEN+1);
3688 <      else
3689 <        DupString(*host, "*");
3690 >      if (*p != '\0')
3691 >        strlcpy(iptr->hostptr, p, iptr->hostsize);
3692      }
3693 <    else                                        /* no @ found */
3693 >    else
3694      {
3695 <      if (nick != NULL)
3696 <      {
3697 <        if (strpbrk(mask, ".:"))
3696 <        {
3697 <          DupString(*nick, "*");
3698 <          *host = xstrldup(mask, HOSTLEN+1);
3699 <        }
3700 <        else
3701 <        {
3702 <          *nick = xstrldup(mask, NICKLEN);
3703 <          DupString(*host, "*");
3704 <        }
3705 <
3706 <        DupString(*user, "*");
3707 <      }
3695 >      /* no @ found */
3696 >      if (!iptr->nickptr || strpbrk(iptr->nuhmask, ".:"))
3697 >        strlcpy(iptr->hostptr, iptr->nuhmask, iptr->hostsize);
3698        else
3699 <      {
3710 <        DupString(*user, "*");
3711 <        *host = xstrldup(mask, HOSTLEN+1);
3712 <      }
3699 >        strlcpy(iptr->nickptr, iptr->nuhmask, iptr->nicksize);
3700      }
3701    }
3702   }
# Line 3736 | Line 3723 | flags_to_ascii(unsigned int flags, const
3723    {
3724      if (flags & mask)
3725        *p++ = bit_table[i];
3726 <    else if(lowerit)
3726 >    else if (lowerit)
3727        *p++ = ToLower(bit_table[i]);
3728    }
3729    *p = '\0';

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines