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

Comparing:
ircd-hybrid/src/s_user.c (file contents), Revision 30 by adx, Sun Oct 2 20:03:27 2005 UTC vs.
ircd-hybrid-7.2/src/s_user.c (file contents), Revision 1011 by michael, Fri Sep 18 10:14:09 2009 UTC

# Line 19 | Line 19
19   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
20   *  USA
21   *
22 < *  $Id: s_user.c,v 7.385 2005/09/24 12:38:38 michael Exp $
22 > *  $Id$
23   */
24  
25   #include "stdinc.h"
26 < #include "tools.h"
26 > #include "list.h"
27   #include "s_user.h"
28   #include "s_misc.h"
29   #include "channel.h"
# Line 35 | Line 35
35   #include "irc_string.h"
36   #include "sprintf_irc.h"
37   #include "s_bsd.h"
38 #include "irc_getnameinfo.h"
38   #include "ircd.h"
40 #include "list.h"
39   #include "listener.h"
40   #include "motd.h"
41   #include "numeric.h"
42   #include "s_conf.h"
43   #include "s_log.h"
44   #include "s_serv.h"
47 #include "s_stats.h"
45   #include "send.h"
46   #include "supported.h"
47   #include "whowas.h"
48   #include "memory.h"
49   #include "packet.h"
50 + #include "rng_mt.h"
51   #include "userhost.h"
52   #include "hook.h"
53   #include "s_misc.h"
54   #include "msg.h"
55 < #include "pcre.h"
55 > #include "watch.h"
56  
57   int MaxClientCount     = 1;
58   int MaxConnectionCount = 1;
# Line 67 | Line 65 | static char umode_buffer[IRCD_BUFSIZE];
65   static void user_welcome(struct Client *);
66   static void report_and_set_user_flags(struct Client *, const struct AccessItem *);
67   static int check_xline(struct Client *);
70 static int check_regexp_xline(struct Client *);
68   static void introduce_client(struct Client *, struct Client *);
69   static void *uid_get(va_list);
70  
# Line 96 | Line 93 | unsigned int user_modes[256] =
93    0,                  /* @ */
94    0,                  /* A */
95    0,                  /* B */
96 <  0,                  /* C */
96 >  UMODE_CCONN_FULL,   /* C */
97    UMODE_DEAF,         /* D */
98    0,                  /* E */
99    0,                  /* F */
# Line 201 | Line 198 | show_lusers(struct Client *source_p)
198                 Count.invisi, dlink_list_length(&global_serv_list));
199    else
200      sendto_one(source_p, form_str(RPL_LUSERCLIENT), from, to,
201 <              (Count.total-Count.invisi), Count.invisi, 1);
201 >               (Count.total-Count.invisi), Count.invisi, 1);
202  
203    if (Count.oper > 0)
204      sendto_one(source_p, form_str(RPL_LUSEROP),
205 <               from, to, Count.oper);
205 >               from, to, Count.oper);
206  
207    if (dlink_list_length(&unknown_list) > 0)
208      sendto_one(source_p, form_str(RPL_LUSERUNKNOWN),
209 <               from, to, dlink_list_length(&unknown_list));
209 >               from, to, dlink_list_length(&unknown_list));
210  
211    if (dlink_list_length(&global_channel_list) > 0)
212      sendto_one(source_p, form_str(RPL_LUSERCHANNELS),
213 <               from, to,
217 <               dlink_list_length(&global_channel_list));
213 >               from, to, dlink_list_length(&global_channel_list));
214  
215    if (!ConfigServerHide.hide_servers || IsOper(source_p))
216    {
217      sendto_one(source_p, form_str(RPL_LUSERME),
218 <               from, to,
223 <               Count.local, Count.myserver);
218 >               from, to, Count.local, Count.myserver);
219      sendto_one(source_p, form_str(RPL_LOCALUSERS),
220 <               from, to, Count.local, Count.max_loc,
221 <               Count.local, Count.max_loc);
220 >               from, to, Count.local, Count.max_loc,
221 >               Count.local, Count.max_loc);
222    }
223    else
224    {
225      sendto_one(source_p, form_str(RPL_LUSERME),
226 <               from, to, Count.total, 0);
226 >               from, to, Count.total, 0);
227      sendto_one(source_p, form_str(RPL_LOCALUSERS),
228 <               from, to, Count.total, Count.max_tot,
228 >               from, to, Count.total, Count.max_tot,
229                 Count.total, Count.max_tot);
230    }
231  
# Line 240 | Line 235 | show_lusers(struct Client *source_p)
235  
236    if (!ConfigServerHide.hide_servers || IsOper(source_p))
237      sendto_one(source_p, form_str(RPL_STATSCONN), from, to,
238 <               MaxConnectionCount, MaxClientCount, Count.totalrestartcount);
238 >               MaxConnectionCount, MaxClientCount, Count.totalrestartcount);
239  
240    if (Count.local > MaxClientCount)
241      MaxClientCount = Count.local;
# Line 289 | Line 284 | register_local_user(struct Client *clien
284                      const char *nick, const char *username)
285   {
286    const struct AccessItem *aconf = NULL;
287 <  char ipaddr[HOSTIPLEN];
288 <  dlink_node *ptr;
294 <  dlink_node *m;
287 >  dlink_node *ptr = NULL;
288 >  dlink_node *m = NULL;
289  
290    assert(source_p != NULL);
291    assert(MyConnect(source_p));
292    assert(source_p->username != username);
293 +  assert(!source_p->localClient->registration);
294 +
295 +  ClearCap(client_p, CAP_TS6);
296  
297    if (ConfigFileEntry.ping_cookie)
298    {
299      if (!IsPingSent(source_p) &&
300         source_p->localClient->random_ping == 0)
301      {
302 <      source_p->localClient->random_ping = (unsigned long)rand();
303 <      sendto_one(source_p, "PING :%lu",
302 >      do
303 >        source_p->localClient->random_ping = genrand_int32();
304 >      while (!source_p->localClient->random_ping);
305 >
306 >      sendto_one(source_p, "PING :%u",
307                   source_p->localClient->random_ping);
308        SetPingSent(source_p);
309        return;
# Line 338 | Line 338 | register_local_user(struct Client *clien
338  
339      if (IsNeedIdentd(aconf))
340      {
341 <      ServerStats->is_ref++;
341 >      ++ServerStats.is_ref;
342        sendto_one(source_p, ":%s NOTICE %s :*** Notice -- You need to install "
343                   "identd to use this server", me.name, source_p->name);
344        exit_client(source_p, &me, "Install identd");
# Line 367 | Line 367 | register_local_user(struct Client *clien
367  
368      if (!match_conf_password(pass, aconf))
369      {
370 <      ServerStats->is_ref++;
370 >      ++ServerStats.is_ref;
371        sendto_one(source_p, form_str(ERR_PASSWDMISMATCH),
372                   me.name, source_p->name);
373        exit_client(source_p, &me, "Bad Password");
# Line 383 | Line 383 | register_local_user(struct Client *clien
383    /* report if user has &^>= etc. and set flags as needed in source_p */
384    report_and_set_user_flags(source_p, aconf);
385  
386 +  if (IsDead(client_p))
387 +    return;
388 +
389    /* Limit clients -
390     * We want to be able to have servers and F-line clients
391     * connect, so save room for "buffer" connections.
# Line 397 | Line 400 | register_local_user(struct Client *clien
400      sendto_realops_flags(UMODE_FULL, L_ALL,
401                           "Too many clients, rejecting %s[%s].",
402                           nick, source_p->host);
403 <    ServerStats->is_ref++;
403 >    ++ServerStats.is_ref;
404      exit_client(source_p, &me, "Sorry, server is full - try later");
405      return;
406    }
# Line 409 | Line 412 | register_local_user(struct Client *clien
412  
413      sendto_realops_flags(UMODE_REJ, L_ALL, "Invalid username: %s (%s@%s)",
414                           nick, source_p->username, source_p->host);
415 <    ServerStats->is_ref++;
415 >    ++ServerStats.is_ref;
416      ircsprintf(tmpstr2, "Invalid username [%s]", source_p->username);
417      exit_client(source_p, &me, tmpstr2);
418      return;
# Line 417 | Line 420 | register_local_user(struct Client *clien
420  
421    assert(source_p == client_p);
422  
423 <  /* end of valid user name check */
421 <  if (check_xline(source_p) || check_regexp_xline(source_p))
423 >  if (check_xline(source_p))
424      return;
425  
426 <  if (IsDead(client_p))
425 <    return;
426 <
427 <  if (source_p->id[0] == '\0' && me.id[0])
426 >  if (me.id[0])
427    {
428 <    char *id = (char *) execute_callback(uid_get_cb, source_p);
428 >    const char *id = execute_callback(uid_get_cb, source_p);
429 >
430      while (hash_find_id(id) != NULL)
431        id = uid_get(NULL);
432  
# Line 434 | Line 434 | register_local_user(struct Client *clien
434      hash_add_id(source_p);
435    }
436  
437  irc_getnameinfo((struct sockaddr *)&source_p->localClient->ip,
438                  source_p->localClient->ip.ss_len, ipaddr,
439                  HOSTIPLEN, NULL, 0, NI_NUMERICHOST);
440
437    sendto_realops_flags(UMODE_CCONN, L_ALL,
438                         "Client connecting: %s (%s@%s) [%s] {%s} [%s]",
439                         nick, source_p->username, source_p->host,
440                         ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ?
441 <                       "255.255.255.255" : ipaddr, get_client_class(source_p),
441 >                       "255.255.255.255" : source_p->sockhost,
442 >                       get_client_class(source_p),
443 >                       source_p->info);
444 >
445 >  sendto_realops_flags(UMODE_CCONN_FULL, L_ALL,
446 >                       "CLICONN %s %s %s %s %s %s %s 0 %s",
447 >                       nick, source_p->username, source_p->host,
448 >                       ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ?
449 >                       "255.255.255.255" : source_p->sockhost,
450 >                       get_client_class(source_p),
451 >                       ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ?
452 >                           "<hidden>" : source_p->client_host,
453 >                       ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ?
454 >                           "<hidden>" : source_p->client_server,
455                         source_p->info);
456  
448  /* If they have died in send_* don't do anything. */
449  if (IsDead(source_p))
450    return;
457  
458    if (ConfigFileEntry.invisible_on_connect)
459 +  {
460      source_p->umodes |= UMODE_INVISIBLE;
461 <  Count.invisi++;
461 >    ++Count.invisi;
462 >  }
463  
464    if ((++Count.local) > Count.max_loc)
465    {
# Line 465 | Line 473 | register_local_user(struct Client *clien
473    SetClient(source_p);
474  
475    source_p->servptr = &me;
476 <  dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->users);
476 >  dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->client_list);
477  
478    /* Increment our total user count here */
479    if (++Count.total > Count.max_tot)
480      Count.max_tot = Count.total;
481 <  Count.totalrestartcount++;
481 >  ++Count.totalrestartcount;
482  
483    source_p->localClient->allow_read = MAX_FLOOD_BURST;
484  
# Line 502 | Line 510 | register_local_user(struct Client *clien
510   */
511   void
512   register_remote_user(struct Client *client_p, struct Client *source_p,
513 <                     const char *username, const char *host, const char *server,
514 <                     const char *realname)
513 >                     const char *username, const char *host, const char *server,
514 >                     const char *realname)
515   {
516 <  struct Client *target_p;
516 >  struct Client *target_p = NULL;
517  
518    assert(source_p != NULL);
519    assert(source_p->username != username);
520  
521    strlcpy(source_p->host, host, sizeof(source_p->host));
514  strlcpy(source_p->info, realname, sizeof(source_p->info));
522    strlcpy(source_p->username, username, sizeof(source_p->username));
523  
517  /* Increment our total user count here */
518  if (++Count.total > Count.max_tot)
519    Count.max_tot = Count.total;
520
521  source_p->from->serv->dep_users++;
522
524    /*
525     * coming from another server, take the servers word for it
526     */
# Line 537 | Line 538 | register_remote_user(struct Client *clie
538                           source_p->host, source_p->from->name);
539      kill_client(client_p, source_p, "%s (Server doesn't exist)", me.name);
540  
540    /* XXX */
541      SetKilled(source_p);
542      exit_client(source_p, &me, "Ghosted Client");
543      return;
# Line 558 | Line 558 | register_remote_user(struct Client *clie
558      return;
559    }
560  
561 +  /* Increment our total user count here */
562 +  if (++Count.total > Count.max_tot)
563 +    Count.max_tot = Count.total;
564 +
565    SetClient(source_p);
566 <  dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->users);
566 >  dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->client_list);
567    add_user_host(source_p->username, source_p->host, 1);
568    SetUserHost(source_p);
569  
# Line 578 | Line 582 | register_remote_user(struct Client *clie
582   static void
583   introduce_client(struct Client *client_p, struct Client *source_p)
584   {
585 <  dlink_node *server_node;
585 >  dlink_node *server_node = NULL;
586    static char ubuf[12];
587  
588    if (MyClient(source_p))
# Line 586 | Line 590 | introduce_client(struct Client *client_p
590    else
591      send_umode(NULL, source_p, 0, SEND_UMODES, ubuf);
592  
593 +  watch_check_hash(source_p, RPL_LOGON);
594 +
595    if (*ubuf == '\0')
596    {
597      ubuf[0] = '+';
598      ubuf[1] = '\0';
599    }
600  
601 <  /* arghhh one could try not introducing new nicks to ll leafs
602 <   * but then you have to introduce them "on the fly" in SJOIN
603 <   * not fun.
598 <   * Its not going to cost much more bandwidth to simply let new
599 <   * nicks just ride on through.
600 <   */
601 >  DLINK_FOREACH(server_node, serv_list.head)
602 >  {
603 >    struct Client *server = server_node->data;
604  
605 <  /* We now introduce nicks "on the fly" in SJOIN anyway --
606 <   * you _need_ to if you aren't going to burst everyone initially.
604 <   *
605 <   * Only send to non CAP_LL servers, unless we're a lazylink leaf,
606 <   * in that case just send it to the uplink.
607 <   * -davidt
608 <   * rewritten to cope with SIDs .. eww eww eww --is
609 <   */
605 >    if (server == client_p)
606 >        continue;
607  
608 <  /* XXX THESE NEED A PREFIX!?!?!? */
609 <  if (!ServerInfo.hub && uplink && IsCapable(uplink, CAP_LL) &&
613 <      client_p != uplink)
614 <  {
615 <    if (IsCapable(uplink, CAP_TS6) && HasID(source_p))
616 <    {
617 <      sendto_one(uplink, ":%s UID %s %d %lu %s %s %s %s %s :%s",
608 >    if (IsCapable(server, CAP_TS6) && HasID(source_p))
609 >      sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s :%s",
610                   source_p->servptr->id,
611                   source_p->name, source_p->hopcount+1,
612 <                 (unsigned long)source_p->tsinfo,
612 >                 (unsigned long)source_p->tsinfo,
613                   ubuf, source_p->username, source_p->host,
614 <                 ((MyClient(source_p) && !IsIPSpoof(source_p)) ?
615 <                 source_p->sockhost : "0"),
624 <                 source_p->id, source_p->info);
625 <    }
614 >                 (MyClient(source_p) && IsIPSpoof(source_p)) ?
615 >                 "0" : source_p->sockhost, source_p->id, source_p->info);
616      else
617 <    {
628 <      sendto_one(uplink, "NICK %s %d %lu %s %s %s %s :%s",
617 >      sendto_one(server, "NICK %s %d %lu %s %s %s %s :%s",
618                   source_p->name, source_p->hopcount+1,
619 <                 (unsigned long)source_p->tsinfo,
619 >                 (unsigned long)source_p->tsinfo,
620                   ubuf, source_p->username, source_p->host,
621 <                 source_p->servptr->name,
633 <                 source_p->info);
634 <    }
635 <  }
636 <  else
637 <  {
638 <    DLINK_FOREACH(server_node, serv_list.head)
639 <    {
640 <      struct Client *server = server_node->data;
641 <
642 <      if (IsCapable(server, CAP_LL) || server == client_p)
643 <        continue;
644 <
645 <      if (IsCapable(server, CAP_TS6) && HasID(source_p))
646 <        sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s :%s",
647 <                   source_p->servptr->id,
648 <                   source_p->name, source_p->hopcount+1,
649 <                   (unsigned long)source_p->tsinfo,
650 <                   ubuf, source_p->username, source_p->host,
651 <                   ((MyClient(source_p)&&!IsIPSpoof(source_p))?source_p->sockhost:"0"),
652 <                   source_p->id, source_p->info);
653 <      else
654 <        sendto_one(server, "NICK %s %d %lu %s %s %s %s :%s",
655 <                   source_p->name, source_p->hopcount+1,
656 <                   (unsigned long)source_p->tsinfo,
657 <                   ubuf, source_p->username, source_p->host,
658 <                   source_p->servptr->name,
659 <                   source_p->info);
660 <    }
621 >                 source_p->servptr->name, source_p->info);
622    }
623   }
624  
# Line 677 | Line 638 | valid_hostname(const char *hostname)
638  
639    assert(p != NULL);
640  
641 <  if (('.' == *p) || (':' == *p))
642 <    return (0);
641 >  if ('.' == *p || ':' == *p)
642 >    return 0;
643  
644    while (*p)
645    {
646      if (!IsHostChar(*p))
647 <      return (0);
647 >      return 0;
648      p++;
649    }
650  
651 <  return (1);
651 >  return 1;
652   }
653  
654   /* valid_username()
# Line 717 | Line 678 | valid_username(const char *username)
678     * or "-hi-@somehost", "h-----@somehost" would still be accepted.
679     */
680    if (!IsAlNum(*p))
681 <    return (0);
681 >    return 0;
682  
683    while (*++p)
684    {
# Line 726 | Line 687 | valid_username(const char *username)
687        dots++;
688  
689        if (dots > ConfigFileEntry.dots_in_ident)
690 <        return (0);
690 >        return 0;
691        if (!IsUserChar(p[1]))
692 <        return (0);
692 >        return 0;
693      }
694      else if (!IsUserChar(*p))
695 <      return (0);
695 >      return 0;
696    }
697  
698 <  return (1);
698 >  return 1;
699   }
700  
701   /* report_and_set_user_flags()
# Line 833 | Line 794 | do_local_user(const char *nick, struct C
794      return;
795    }
796  
797 <  source_p->flags |= FLAGS_GOTUSER;
797 >  source_p->localClient->registration &= ~REG_NEED_USER;
798  
799    /*
800     * don't take the clients word for it, ever
# Line 842 | Line 803 | do_local_user(const char *nick, struct C
803  
804    strlcpy(source_p->info, realname, sizeof(source_p->info));
805  
806 +  /* stash for later */
807 +  strlcpy(source_p->client_host, host, sizeof(source_p->client_host));
808 +  strlcpy(source_p->client_server, server, sizeof(source_p->client_server));
809 +
810    if (!IsGotId(source_p))
811    {
812      /* save the username in the client
# Line 850 | Line 815 | do_local_user(const char *nick, struct C
815      strlcpy(source_p->username, username, sizeof(source_p->username));
816    }
817  
818 <  if (source_p->name[0])
854 <  {
818 >  if (!source_p->localClient->registration)
819      /* NICK already received, now I have USER... */
820      register_local_user(client_p, source_p, source_p->name, username);
857  }
821   }
822  
823   /* change_simple_umode()
# Line 865 | Line 828 | do_local_user(const char *nick, struct C
828   static void *
829   change_simple_umode(va_list args)
830   {
831 +  struct Client *client_p;
832    struct Client *source_p;
833    int what;
834    unsigned int flag;
835  
836 <  va_arg(args, struct Client *);
836 >  client_p = va_arg(args, struct Client *);
837    source_p = va_arg(args, struct Client *);
838    what = va_arg(args, int);
839    flag = va_arg(args, unsigned int);
# Line 897 | Line 861 | set_user_mode(struct Client *client_p, s
861    char **p, *m, buf[IRCD_BUFSIZE];
862    struct Client *target_p;
863    int what = MODE_ADD, badflag = 0, i;
864 < #if 0
865 <  /* already covered by m_mode */
866 <  if (parc < 2)
903 <  {
904 <    sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
905 <               me.name, source_p->name, "MODE");
906 <    return;
907 <  }
908 < #endif
864 >
865 >  assert(!(parc < 2));
866 >
867    if ((target_p = find_person(client_p, parv[1])) == NULL)
868    {
869      if (MyConnect(source_p))
# Line 914 | Line 872 | set_user_mode(struct Client *client_p, s
872      return;
873    }
874  
917  /* Dont know why these were commented out..
918   * put them back using new sendto() funcs
919   */
875    if (IsServer(source_p))
876    {
877       sendto_realops_flags(UMODE_ALL, L_ADMIN, "*** Mode for User %s from %s",
# Line 1017 | Line 972 | set_user_mode(struct Client *client_p, s
972                badflag = 1;
973              }
974              else
975 <              execute_callback(umode_cb, client_p, source_p, what, flag);
975 >              execute_callback(umode_cb, client_p, source_p, what, flag);
976            }
977            else
978            {
# Line 1054 | Line 1009 | set_user_mode(struct Client *client_p, s
1009    if ((setflags & UMODE_INVISIBLE) && !IsInvisible(source_p))
1010      --Count.invisi;
1011  
1012 <  /* compare new flags with old flags and send string which
1012 >  /*
1013 >   * compare new flags with old flags and send string which
1014     * will cause servers to update correctly.
1015     */
1016    send_umode_out(client_p, source_p, setflags);
# Line 1063 | Line 1019 | set_user_mode(struct Client *client_p, s
1019   /* send_umode()
1020   * send the MODE string for user (user) to connection client_p
1021   * -avalon
1022 + *
1023 + * inputs       - client_p
1024 + *              - source_p
1025 + *              - int old
1026 + *              - sendmask mask of modes to send
1027 + *              - suplied umode_buf
1028 + * output       - NONE
1029   */
1030   void
1031   send_umode(struct Client *client_p, struct Client *source_p,
# Line 1073 | Line 1036 | send_umode(struct Client *client_p, stru
1036    unsigned int flag;
1037    char *m = umode_buf;
1038  
1039 <  /* build a string in umode_buf to represent the change in the user's
1039 >  /*
1040 >   * build a string in umode_buf to represent the change in the user's
1041     * mode between the new (source_p->umodes) and 'old'.
1042     */
1043    for (i = 0; i < 128; i++)
# Line 1112 | Line 1076 | send_umode(struct Client *client_p, stru
1076    *m = '\0';
1077  
1078    if (*umode_buf && client_p)
1079 <    sendto_one(client_p, ":%s MODE %s :%s",
1080 <               source_p->name, source_p->name, umode_buf);
1079 >    sendto_one(client_p, ":%s!%s@%s MODE %s :%s",
1080 >               source_p->name, source_p->username,
1081 >               source_p->host, source_p->name, umode_buf);
1082   }
1083  
1084   /* send_umode_out()
# Line 1126 | Line 1091 | void
1091   send_umode_out(struct Client *client_p, struct Client *source_p,
1092                 unsigned int old)
1093   {
1094 <  char buf[IRCD_BUFSIZE];
1094 >  char buf[IRCD_BUFSIZE] = { '\0' };
1095    dlink_node *ptr = NULL;
1096  
1097    send_umode(NULL, source_p, old, IsOperHiddenAdmin(source_p) ?
1098               SEND_UMODES & ~UMODE_ADMIN : SEND_UMODES, buf);
1099  
1100 <  if (*buf)
1100 >  if (buf[0])
1101    {
1102      DLINK_FOREACH(ptr, serv_list.head)
1103      {
1104        struct Client *target_p = ptr->data;
1105  
1106        if ((target_p != client_p) && (target_p != source_p))
1107 <      {
1108 <        if ((!(ServerInfo.hub && IsCapable(target_p, CAP_LL))) ||
1109 <            (target_p->localClient->serverMask &
1145 <             source_p->lazyLinkClientExists))
1146 <          sendto_one(target_p, ":%s MODE %s :%s",
1147 <                     ID_or_name(source_p, target_p),
1148 <                     ID_or_name(source_p, target_p), buf);
1149 <      }
1107 >        sendto_one(target_p, ":%s MODE %s :%s",
1108 >                   ID_or_name(source_p, target_p),
1109 >                   ID_or_name(source_p, target_p), buf);
1110      }
1111    }
1112  
# Line 1179 | Line 1139 | user_welcome(struct Client *source_p)
1139    sendto_one(source_p, form_str(RPL_WELCOME), me.name, source_p->name,
1140               ServerInfo.network_name, source_p->name);
1141    sendto_one(source_p, form_str(RPL_YOURHOST), me.name, source_p->name,
1142 <             get_listener_name(source_p->localClient->listener), ircd_version);
1142 >             get_listener_name(source_p->localClient->listener), ircd_version);
1143    sendto_one(source_p, form_str(RPL_CREATED),
1144 <             me.name, source_p->name, built_date);
1144 >             me.name, source_p->name, built_date);
1145    sendto_one(source_p, form_str(RPL_MYINFO),
1146               me.name, source_p->name, me.name, ircd_version, umode_buffer);
1147    show_isupport(source_p);
# Line 1220 | Line 1180 | user_welcome(struct Client *source_p)
1180   static int
1181   check_xline(struct Client *source_p)
1182   {
1223  struct ConfItem *conf;
1224  struct MatchItem *xconf;
1225  const char *reason;
1226
1227  if ((conf = find_matching_name_conf(XLINE_TYPE, source_p->info,
1228                                      NULL, NULL, 0)) != NULL)
1229  {
1230    xconf = map_to_conf(conf);
1231    xconf->count++;
1232
1233    if (xconf->reason != NULL)
1234      reason = xconf->reason;
1235    else
1236      reason = "No Reason";
1237
1238    sendto_realops_flags(UMODE_REJ, L_ALL,
1239                         "X-line Rejecting [%s] [%s], user %s [%s]",
1240                         source_p->info, reason,
1241                         get_client_name(source_p, HIDE_IP),
1242                         source_p->sockhost);
1243
1244    ServerStats->is_ref++;      
1245    if(REJECT_HOLD_TIME > 0)
1246    {
1247      sendto_one(source_p, ":%s NOTICE %s :Bad user info",
1248                 me.name, source_p->name);
1249      source_p->localClient->reject_delay = CurrentTime + REJECT_HOLD_TIME;
1250      SetCaptured(source_p);
1251    }
1252    else
1253      exit_client(source_p, &me, "Bad user info");
1254    return 1;
1255  }
1256
1257  return 0;
1258 }
1259
1260 static int
1261 check_regexp_xline(struct Client *source_p)
1262 {
1183    struct ConfItem *conf = NULL;
1184    const char *reason = NULL;
1185  
1186 <  if ((conf = find_matching_name_conf(RXLINE_TYPE, source_p->info, NULL, NULL, 0)))
1186 >  if ((conf = find_matching_name_conf(XLINE_TYPE, source_p->info, NULL, NULL, 0)) ||
1187 >      (conf = find_matching_name_conf(RXLINE_TYPE, source_p->info, NULL, NULL, 0)))
1188    {
1189      struct MatchItem *reg = map_to_conf(conf);
1190  
# Line 1275 | Line 1196 | check_regexp_xline(struct Client *source
1196        reason = "No Reason";
1197  
1198      sendto_realops_flags(UMODE_REJ, L_ALL,
1199 <                         "X-line (REGEX) Rejecting [%s] [%s], user %s [%s]",
1199 >                         "X-line Rejecting [%s] [%s], user %s [%s]",
1200                           source_p->info, reason,
1201                           get_client_name(source_p, HIDE_IP),
1202                           source_p->sockhost);
1203  
1204 <    ServerStats->is_ref++;
1205 <    exit_client(source_p, &me, "Bad user info");
1204 >    ++ServerStats.is_ref;
1205 >    if (REJECT_HOLD_TIME > 0)
1206 >    {
1207 >      sendto_one(source_p, ":%s NOTICE %s :Bad user info",
1208 >                 me.name, source_p->name);
1209 >      source_p->localClient->reject_delay = CurrentTime + REJECT_HOLD_TIME;
1210 >      SetCaptured(source_p);
1211 >    }
1212 >    else
1213 >      exit_client(source_p, &me, "Bad user info");
1214      return 1;
1215    }
1216  
# Line 1301 | Line 1230 | oper_up(struct Client *source_p)
1230   {
1231    unsigned int old = source_p->umodes;
1232    const char *operprivs = "";
1233 <  struct AccessItem *oconf;
1233 >  const struct AccessItem *oconf = NULL;
1234 >
1235 >  assert(source_p->localClient->confs.head);
1236 >  oconf = map_to_conf((source_p->localClient->confs.head)->data);
1237  
1238 +  ++Count.oper;
1239    SetOper(source_p);
1240  
1241 <  if (ConfigFileEntry.oper_umodes)
1241 >  if (oconf->modes)
1242 >    source_p->umodes |= oconf->modes;
1243 >  else if (ConfigFileEntry.oper_umodes)
1244      source_p->umodes |= ConfigFileEntry.oper_umodes;
1245    else
1246      source_p->umodes |= (UMODE_SERVNOTICE|UMODE_OPERWALL|
1247 <                         UMODE_WALLOP|UMODE_LOCOPS);
1247 >                         UMODE_WALLOP|UMODE_LOCOPS);
1248  
1249 <  Count.oper++;
1249 >  if (!(old & UMODE_INVISIBLE) && IsInvisible(source_p))
1250 >    ++Count.invisi;
1251 >  if ((old & UMODE_INVISIBLE) && !IsInvisible(source_p))
1252 >    --Count.invisi;
1253  
1254    assert(dlinkFind(&oper_list, source_p) == NULL);
1255    dlinkAdd(source_p, make_dlink_node(), &oper_list);
1256  
1319  assert(source_p->localClient->confs.head);
1320  oconf = map_to_conf((source_p->localClient->confs.head)->data);
1257    operprivs = oper_privs_as_string(oconf->port);
1258  
1259    SetOFlag(source_p, oconf->port);
# Line 1336 | Line 1272 | oper_up(struct Client *source_p)
1272    send_message_file(source_p, &ConfigFileEntry.opermotd);
1273   }
1274  
1275 < /*
1340 < * Quick and dirty UID code for new proposed SID on EFnet
1341 < *
1342 < */
1275 > static char new_uid[TOTALSIDUID + 1];     /* allow for \0 */
1276  
1277 < static char new_uid[TOTALSIDUID+1];     /* allow for \0 */
1278 < static void add_one_to_uid(int i);
1277 > int
1278 > valid_sid(const char *sid)
1279 > {
1280 >
1281 >  if (strlen(sid) == IRC_MAXSID)
1282 >    if (IsDigit(*sid))
1283 >      if (IsAlNum(*(sid + 1)) && IsAlNum(*(sid + 2)))
1284 >        return 1;
1285 >
1286 >  return 0;
1287 > }
1288  
1289   /*
1290   * init_uid()
# Line 1362 | Line 1304 | init_uid(void)
1304  
1305    if (ServerInfo.sid != NULL)
1306    {
1307 <    memcpy(new_uid, ServerInfo.sid, IRCD_MIN(strlen(ServerInfo.sid),
1308 <                                             IRC_MAXSID));
1309 <    memcpy(&me.id, ServerInfo.sid, IRCD_MIN(strlen(ServerInfo.sid),
1368 <                                             IRC_MAXSID));
1307 >    strlcpy(new_uid, ServerInfo.sid, sizeof(new_uid));
1308 >    strlcpy(me.id, ServerInfo.sid, sizeof(me.id));
1309 >
1310      hash_add_id(&me);
1311    }
1312  
# Line 1373 | Line 1314 | init_uid(void)
1314      if (new_uid[i] == '\0')
1315        new_uid[i] = 'A';
1316  
1317 <  /* XXX if IRC_MAXUID != 6, this will have to be rewritten */
1317 >  /* NOTE: if IRC_MAXUID != 6, this will have to be rewritten */
1318    /* Yes nenolod, I have known it was off by one ever since I wrote it
1319     * But *JUST* for you, though, it really doesn't look as *pretty*
1320     * -Dianora
1321     */
1322 <  memcpy(new_uid+IRC_MAXSID, "AAAAA@", IRC_MAXUID);
1322 >  memcpy(new_uid + IRC_MAXSID, "AAAAA@", IRC_MAXUID);
1323  
1324    entering_umode_cb = register_callback("entering_umode", NULL);
1325    umode_cb = register_callback("changing_umode", change_simple_umode);
# Line 1386 | Line 1327 | init_uid(void)
1327   }
1328  
1329   /*
1389 * uid_get
1390 *
1391 * inputs       - struct Client *
1392 * output       - new UID is returned to caller
1393 * side effects - new_uid is incremented by one.
1394 */
1395 static void *
1396 uid_get(va_list args)
1397 {
1398  add_one_to_uid(TOTALSIDUID-1);        /* index from 0 */
1399  return ((void *) new_uid);
1400 }
1401
1402 /*
1330   * add_one_to_uid
1331   *
1332   * inputs       - index number into new_uid
# Line 1410 | Line 1337 | uid_get(va_list args)
1337   static void
1338   add_one_to_uid(int i)
1339   {
1340 <  if (i != IRC_MAXSID)          /* Not reached server SID portion yet? */
1340 >  if (i != IRC_MAXSID)    /* Not reached server SID portion yet? */
1341    {
1342      if (new_uid[i] == 'Z')
1343        new_uid[i] = '0';
# Line 1419 | Line 1346 | add_one_to_uid(int i)
1346        new_uid[i] = 'A';
1347        add_one_to_uid(i-1);
1348      }
1349 <    else new_uid[i] = new_uid[i] + 1;
1349 >    else
1350 >      ++new_uid[i];
1351    }
1352    else
1353    {
1354 <    /* XXX if IRC_MAXUID != 6, this will have to be rewritten */
1354 >    /* NOTE: if IRC_MAXUID != 6, this will have to be rewritten */
1355      if (new_uid[i] == 'Z')
1356 <      memcpy(new_uid+IRC_MAXSID, "AAAAAA", IRC_MAXUID);
1356 >      memcpy(new_uid + IRC_MAXSID, "AAAAAA", IRC_MAXUID);
1357      else
1358 <      new_uid[i] = new_uid[i] + 1;
1358 >      ++new_uid[i];
1359    }
1360   }
1361  
1362   /*
1363 + * uid_get
1364 + *
1365 + * inputs       - struct Client *
1366 + * output       - new UID is returned to caller
1367 + * side effects - new_uid is incremented by one.
1368 + */
1369 + static void *
1370 + uid_get(va_list args)
1371 + {
1372 +  add_one_to_uid(TOTALSIDUID - 1);    /* index from 0 */
1373 +  return new_uid;
1374 + }
1375 +
1376 + /*
1377   * init_isupport()
1378   *
1379   * input        - NONE
# Line 1445 | Line 1387 | init_isupport(void)
1387  
1388    add_isupport("CALLERID", NULL, -1);
1389    add_isupport("CASEMAPPING", CASEMAP, -1);
1390 +  add_isupport("DEAF", "D", -1);
1391    add_isupport("KICKLEN", NULL, KICKLEN);
1392    add_isupport("MODES", NULL, MAXMODEPARAMS);
1393    add_isupport("NICKLEN", NULL, NICKLEN-1);
# Line 1573 | Line 1516 | rebuild_isupport_message_line(void)
1516      if (++tokens == (MAXPARA-2) || len >= (sizeof(isupportbuffer)-reserve))
1517      { /* arbritrary for now */
1518        if (*--p == ' ')
1519 <        *p = '\0';
1519 >        *p = '\0';
1520  
1521        addto_MessageLine(isupportFile, isupportbuffer);
1522        p = isupportbuffer;

Comparing:
ircd-hybrid/src/s_user.c (property svn:keywords), Revision 30 by adx, Sun Oct 2 20:03:27 2005 UTC vs.
ircd-hybrid-7.2/src/s_user.c (property svn:keywords), Revision 1011 by michael, Fri Sep 18 10:14:09 2009 UTC

# Line 1 | Line 1
1 < "Id Revision"
1 > Id Revision

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)