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-7.3/src/s_user.c (file contents), Revision 1126 by michael, Sun Feb 20 14:30:12 2011 UTC vs.
ircd-hybrid-8/src/s_user.c (file contents), Revision 1219 by michael, Sun Sep 18 09:02:38 2011 UTC

# Line 54 | Line 54
54   #include "msg.h"
55   #include "watch.h"
56  
57 < unsigned int MaxClientCount     = 1;
58 < unsigned int MaxConnectionCount = 1;
57 >
58   struct Callback *entering_umode_cb = NULL;
59   struct Callback *umode_cb = NULL;
60  
# Line 107 | Line 106 | unsigned int user_modes[256] =
106    0,                  /* O */
107    0,                  /* P */
108    0,                  /* Q */
109 <  0,                  /* R */
109 >  UMODE_REGONLY,      /* R */
110    0,                  /* S */
111    0,                  /* T */
112    0,                  /* U */
# Line 127 | Line 126 | unsigned int user_modes[256] =
126    UMODE_CALLERID,     /* g */
127    0,                  /* h */
128    UMODE_INVISIBLE,    /* i */
129 <  0,                  /* j */
129 >  UMODE_REJ,          /* j */
130    UMODE_SKILL,        /* k */
131    UMODE_LOCOPS,       /* l */
132    0,                  /* m */
# Line 135 | Line 134 | unsigned int user_modes[256] =
134    UMODE_OPER,         /* o */
135    0,                  /* p */
136    0,                  /* q */
137 <  UMODE_REJ,          /* r */
137 >  UMODE_REGISTERED,   /* r */
138    UMODE_SERVNOTICE,   /* s */
139    0,                  /* t */
140    UMODE_UNAUTH,       /* u */
# Line 191 | Line 190 | show_lusers(struct Client *source_p)
190      to = source_p->name;
191    }
192  
193 <  if (!ConfigServerHide.hide_servers || IsOper(source_p))
193 >  if (!ConfigServerHide.hide_servers || HasUMode(source_p, UMODE_OPER))
194      sendto_one(source_p, form_str(RPL_LUSERCLIENT),
195                 from, to, (Count.total-Count.invisi),
196                 Count.invisi, dlink_list_length(&global_serv_list));
# Line 211 | Line 210 | show_lusers(struct Client *source_p)
210      sendto_one(source_p, form_str(RPL_LUSERCHANNELS),
211                 from, to, dlink_list_length(&global_channel_list));
212  
213 <  if (!ConfigServerHide.hide_servers || IsOper(source_p))
213 >  if (!ConfigServerHide.hide_servers || HasUMode(source_p, UMODE_OPER))
214    {
215      sendto_one(source_p, form_str(RPL_LUSERME),
216                 from, to, Count.local, Count.myserver);
# Line 232 | Line 231 | show_lusers(struct Client *source_p)
231               from, to, Count.total, Count.max_tot,
232               Count.total, Count.max_tot);
233  
234 <  if (!ConfigServerHide.hide_servers || IsOper(source_p))
234 >  if (!ConfigServerHide.hide_servers || HasUMode(source_p, UMODE_OPER))
235      sendto_one(source_p, form_str(RPL_STATSCONN), from, to,
236 <               MaxConnectionCount, MaxClientCount, Count.totalrestartcount);
236 >               Count.max_loc_con, Count.max_loc_cli, Count.totalrestartcount);
237  
238 <  if (Count.local > MaxClientCount)
239 <    MaxClientCount = Count.local;
238 >  if (Count.local > Count.max_loc_cli)
239 >    Count.max_loc_cli = Count.local;
240  
241 <  if ((Count.local + Count.myserver) > MaxConnectionCount)
242 <    MaxConnectionCount = Count.local + Count.myserver;
241 >  if ((Count.local + Count.myserver) > Count.max_loc_con)
242 >    Count.max_loc_con = Count.local + Count.myserver;
243   }
244  
245   /* show_isupport()
# Line 310 | Line 309 | register_local_user(struct Client *sourc
309        return;
310    }
311  
312 <  source_p->localClient->last = CurrentTime;
312 >  source_p->localClient->last_privmsg = CurrentTime;
313    /* Straight up the maximum rate of flooding... */
314    source_p->localClient->allow_read = MAX_FLOOD_BURST;
315  
# Line 424 | Line 423 | register_local_user(struct Client *sourc
423    hash_add_id(source_p);
424  
425    sendto_realops_flags(UMODE_CCONN, L_ALL,
426 <                       "Client connecting: %s (%s@%s) [%s] {%s} [%s]",
426 >                       "Client connecting: %s (%s@%s) [%s] {%s} [%s] <%s>",
427                         source_p->name, source_p->username, source_p->host,
428                         ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ?
429                         "255.255.255.255" : source_p->sockhost,
430                         get_client_class(source_p),
431 <                       source_p->info);
431 >                       source_p->info, source_p->id);
432  
433    sendto_realops_flags(UMODE_CCONN_FULL, L_ALL,
434                         "CLICONN %s %s %s %s %s %s %s 0 %s",
# Line 446 | Line 445 | register_local_user(struct Client *sourc
445  
446    if (ConfigFileEntry.invisible_on_connect)
447    {
448 <    source_p->umodes |= UMODE_INVISIBLE;
448 >    AddUMode(source_p, UMODE_INVISIBLE);
449      ++Count.invisi;
450    }
451  
# Line 509 | Line 508 | register_remote_user(struct Client *sour
508    /*
509     * coming from another server, take the servers word for it
510     */
511 <  source_p->servptr = find_server(server);
511 >  source_p->servptr = hash_find_server(server);
512  
513    /* Super GhostDetect:
514     * If we can't find the server the user is supposed to be on,
# Line 523 | Line 522 | register_remote_user(struct Client *sour
522                           source_p->host, source_p->from->name);
523      kill_client(source_p->from, source_p, "%s (Server doesn't exist)", me.name);
524  
525 <    SetKilled(source_p);
525 >    AddFlag(source_p, FLAGS_KILLED);
526      exit_client(source_p, &me, "Ghosted Client");
527      return;
528    }
# Line 538 | Line 537 | register_remote_user(struct Client *sour
537      kill_client(source_p->from, source_p,
538                  "%s (NICK from wrong direction (%s != %s))",
539                  me.name, source_p->servptr->name, target_p->from->name);
540 <    SetKilled(source_p);
540 >    AddFlag(source_p, FLAGS_KILLED);
541      exit_client(source_p, &me, "USER server wrong direction");
542      return;
543    }
544  
545 +  /*
546 +   * If the nick has been introduced by a services server,
547 +   * make it a service as well.
548 +   */
549 +  if (HasFlag(source_p->servptr, FLAGS_SERVICE))
550 +    AddFlag(source_p, FLAGS_SERVICE);
551 +
552    /* Increment our total user count here */
553    if (++Count.total > Count.max_tot)
554      Count.max_tot = Count.total;
# Line 589 | Line 595 | introduce_client(struct Client *source_p
595      if (server == source_p->from)
596          continue;
597  
598 <    if (IsCapable(server, CAP_TS6) && HasID(source_p))
599 <      sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s :%s",
600 <                 source_p->servptr->id,
601 <                 source_p->name, source_p->hopcount+1,
602 <                 (unsigned long)source_p->tsinfo,
603 <                 ubuf, source_p->username, source_p->host,
604 <                 (MyClient(source_p) && IsIPSpoof(source_p)) ?
605 <                 "0" : source_p->sockhost, source_p->id, source_p->info);
598 >    if (IsCapable(server, CAP_SVS))
599 >    {
600 >      if (IsCapable(server, CAP_TS6) && HasID(source_p))
601 >        sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s %lu :%s",
602 >                   source_p->servptr->id,
603 >                   source_p->name, source_p->hopcount+1,
604 >                   (unsigned long)source_p->tsinfo,
605 >                   ubuf, source_p->username, source_p->host,
606 >                   (MyClient(source_p) && IsIPSpoof(source_p)) ?
607 >                   "0" : source_p->sockhost, source_p->id,
608 >                   (unsigned long)source_p->servicestamp,
609 >                   source_p->info);
610 >      else
611 >        sendto_one(server, "NICK %s %d %lu %s %s %s %s %lu :%s",
612 >                   source_p->name, source_p->hopcount+1,
613 >                   (unsigned long)source_p->tsinfo,
614 >                   ubuf, source_p->username, source_p->host,
615 >                   source_p->servptr->name, (unsigned long)source_p->servicestamp,
616 >                   source_p->info);
617 >
618 >    }
619      else
620 <      sendto_one(server, "NICK %s %d %lu %s %s %s %s :%s",
621 <                 source_p->name, source_p->hopcount+1,
622 <                 (unsigned long)source_p->tsinfo,
623 <                 ubuf, source_p->username, source_p->host,
624 <                 source_p->servptr->name, source_p->info);
620 >    {
621 >      if (IsCapable(server, CAP_TS6) && HasID(source_p))
622 >        sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s :%s",
623 >                   source_p->servptr->id,
624 >                   source_p->name, source_p->hopcount+1,
625 >                   (unsigned long)source_p->tsinfo,
626 >                   ubuf, source_p->username, source_p->host,
627 >                   (MyClient(source_p) && IsIPSpoof(source_p)) ?
628 >                   "0" : source_p->sockhost, source_p->id, source_p->info);
629 >      else
630 >        sendto_one(server, "NICK %s %d %lu %s %s %s %s :%s",
631 >                   source_p->name, source_p->hopcount+1,
632 >                   (unsigned long)source_p->tsinfo,
633 >                   ubuf, source_p->username, source_p->host,
634 >                   source_p->servptr->name, source_p->info);
635 >    }
636    }
637   }
638  
# Line 677 | Line 707 | valid_username(const char *username)
707    return 1;
708   }
709  
710 + /* clean_nick_name()
711 + *
712 + * input        - nickname
713 + *              - whether it's a local nick (1) or remote (0)
714 + * output       - none
715 + * side effects - walks through the nickname, returning 0 if erroneous
716 + */
717 + int
718 + valid_nickname(const char *nickname, const int local)
719 + {
720 +  const char *p = nickname;
721 +  assert(nickname && *nickname);
722 +
723 +  /* nicks can't start with a digit or - or be 0 length */
724 +  /* This closer duplicates behaviour of hybrid-6 */
725 +  if (*p == '-' || (IsDigit(*p) && local) || *p == '\0')
726 +    return 0;
727 +
728 +  for (; *p; ++p)
729 +    if (!IsNickChar(*p))
730 +      return 0;
731 +
732 +  return p - nickname <= (NICKLEN - 1);
733 + }
734 +
735   /* report_and_set_user_flags()
736   *
737   * inputs       - pointer to source_p
# Line 731 | Line 786 | report_and_set_user_flags(struct Client
786                 me.name,source_p->name);
787    }
788  
734  /* If this user is exempt from idle time outs */
735  if (IsConfIdlelined(aconf))
736  {
737    SetIdlelined(source_p);
738    sendto_one(source_p,
739               ":%s NOTICE %s :*** You are exempt from idle limits. congrats.",
740               me.name, source_p->name);
741  }
742
789    if (IsConfCanFlood(aconf))
790    {
791      SetCanFlood(source_p);
# Line 768 | Line 814 | change_simple_umode(va_list args)
814    flag = va_arg(args, unsigned int);
815  
816    if (what == MODE_ADD)
817 <    source_p->umodes |= flag;
817 >    AddUMode(source_p, flag);
818    else
819 <    source_p->umodes &= ~flag;
819 >    DelUMode(source_p, flag);
820  
821    return NULL;
822   }
# Line 821 | Line 867 | set_user_mode(struct Client *client_p, s
867      *m++ = '+';
868  
869      for (i = 0; i < 128; i++)
870 <      if (source_p->umodes & user_modes[i])
870 >      if (HasUMode(source_p, user_modes[i]))
871          *m++ = (char)i;
872      *m = '\0';
873  
# Line 851 | Line 897 | set_user_mode(struct Client *client_p, s
897          case 'o':
898            if (what == MODE_ADD)
899            {
900 <            if (IsServer(client_p) && !IsOper(source_p))
900 >            if (IsServer(client_p) && !HasUMode(source_p, UMODE_OPER))
901              {
902                ++Count.oper;
903                SetOper(source_p);
# Line 862 | Line 908 | set_user_mode(struct Client *client_p, s
908              /* Only decrement the oper counts if an oper to begin with
909               * found by Pat Szuta, Perly , perly@xnet.com
910               */
911 <            if (!IsOper(source_p))
911 >            if (!HasUMode(source_p, UMODE_OPER))
912                break;
913  
914              ClearOper(source_p);
# Line 873 | Line 919 | set_user_mode(struct Client *client_p, s
919                dlink_node *dm;
920  
921                detach_conf(source_p, OPER_TYPE);
922 <              ClearOperFlags(source_p);
923 <              source_p->umodes &= ~ConfigFileEntry.oper_only_umodes;
922 >              ClrOFlag(source_p);
923 >              DelUMode(source_p, ConfigFileEntry.oper_only_umodes);
924  
925                if ((dm = dlinkFindDelete(&oper_list, source_p)) != NULL)
926                  free_dlink_node(dm);
# Line 886 | Line 932 | set_user_mode(struct Client *client_p, s
932          /* we may not get these,
933           * but they shouldnt be in default
934           */
935 +        case 'r':
936          case ' ' :
937          case '\n':
938          case '\r':
# Line 895 | Line 942 | set_user_mode(struct Client *client_p, s
942          default:
943            if ((flag = user_modes[(unsigned char)*m]))
944            {
945 <            if (MyConnect(source_p) && !IsOper(source_p) &&
945 >            if (MyConnect(source_p) && !HasUMode(source_p, UMODE_OPER) &&
946                  (ConfigFileEntry.oper_only_umodes & flag))
947              {
948                badflag = 1;
# Line 918 | Line 965 | set_user_mode(struct Client *client_p, s
965      sendto_one(source_p, form_str(ERR_UMODEUNKNOWNFLAG),
966                 me.name, source_p->name);
967  
968 <  if ((source_p->umodes & UMODE_NCHANGE) && !IsOperN(source_p))
968 >  if (HasUMode(source_p, UMODE_NCHANGE) && !HasOFlag(source_p, OPER_FLAG_N))
969    {
970 <    sendto_one(source_p, ":%s NOTICE %s :*** You have no admin flag;",
970 >    sendto_one(source_p, ":%s NOTICE %s :*** You have no nchange flag;",
971                 me.name, source_p->name);
972 <    source_p->umodes &= ~UMODE_NCHANGE; /* only tcm's really need this */
972 >    DelUMode(source_p, UMODE_NCHANGE);
973    }
974  
975 <  if (MyConnect(source_p) && (source_p->umodes & UMODE_ADMIN) &&
976 <      !IsOperAdmin(source_p) && !IsOperHiddenAdmin(source_p))
975 >  if (MyConnect(source_p) && HasUMode(source_p, UMODE_ADMIN) &&
976 >      !HasOFlag(source_p, OPER_FLAG_HIDDEN_ADMIN|OPER_FLAG_ADMIN))
977    {
978      sendto_one(source_p, ":%s NOTICE %s :*** You have no admin flag;",
979                 me.name, source_p->name);
980 <    source_p->umodes &= ~UMODE_ADMIN;
980 >    DelUMode(source_p, UMODE_ADMIN);
981    }
982  
983 <  if (!(setflags & UMODE_INVISIBLE) && IsInvisible(source_p))
983 >  if (!(setflags & UMODE_INVISIBLE) && HasUMode(source_p, UMODE_INVISIBLE))
984      ++Count.invisi;
985 <  if ((setflags & UMODE_INVISIBLE) && !IsInvisible(source_p))
985 >  if ((setflags & UMODE_INVISIBLE) && !HasUMode(source_p, UMODE_INVISIBLE))
986      --Count.invisi;
987  
988    /*
# Line 978 | Line 1025 | send_umode(struct Client *client_p, stru
1025      if (MyClient(source_p) && !(flag & sendmask))
1026        continue;
1027  
1028 <    if ((flag & old) && !(source_p->umodes & flag))
1028 >    if ((flag & old) && !HasUMode(source_p, flag))
1029      {
1030        if (what == MODE_DEL)
1031          *m++ = (char)i;
# Line 989 | Line 1036 | send_umode(struct Client *client_p, stru
1036          *m++ = (char)i;
1037        }
1038      }
1039 <    else if (!(flag & old) && (source_p->umodes & flag))
1039 >    else if (!(flag & old) && HasUMode(source_p, flag))
1040      {
1041        if (what == MODE_ADD)
1042          *m++ = (char)i;
# Line 1023 | Line 1070 | send_umode_out(struct Client *client_p,
1070    char buf[IRCD_BUFSIZE] = { '\0' };
1071    dlink_node *ptr = NULL;
1072  
1073 <  send_umode(NULL, source_p, old, IsOperHiddenAdmin(source_p) ?
1073 >  send_umode(NULL, source_p, old, HasOFlag(source_p, OPER_FLAG_HIDDEN_ADMIN) ?
1074               SEND_UMODES & ~UMODE_ADMIN : SEND_UMODES, buf);
1075  
1076    if (buf[0])
# Line 1168 | Line 1215 | oper_up(struct Client *source_p)
1215    SetOper(source_p);
1216  
1217    if (oconf->modes)
1218 <    source_p->umodes |= oconf->modes;
1218 >    AddUMode(source_p, oconf->modes);
1219    else if (ConfigFileEntry.oper_umodes)
1220 <    source_p->umodes |= ConfigFileEntry.oper_umodes;
1220 >    AddUMode(source_p, ConfigFileEntry.oper_umodes);
1221    else
1222 <    source_p->umodes |= (UMODE_SERVNOTICE|UMODE_OPERWALL|
1223 <                         UMODE_WALLOP|UMODE_LOCOPS);
1222 >    AddUMode(source_p, UMODE_SERVNOTICE|UMODE_OPERWALL|
1223 >                       UMODE_WALLOP|UMODE_LOCOPS);
1224  
1225 <  if (!(old & UMODE_INVISIBLE) && IsInvisible(source_p))
1225 >  if (!(old & UMODE_INVISIBLE) && HasUMode(source_p, UMODE_INVISIBLE))
1226      ++Count.invisi;
1227 <  if ((old & UMODE_INVISIBLE) && !IsInvisible(source_p))
1227 >  if ((old & UMODE_INVISIBLE) && !HasUMode(source_p, UMODE_INVISIBLE))
1228      --Count.invisi;
1229  
1230    assert(dlinkFind(&oper_list, source_p) == NULL);
# Line 1185 | Line 1232 | oper_up(struct Client *source_p)
1232  
1233    operprivs = oper_privs_as_string(oconf->port);
1234  
1235 <  SetOFlag(source_p, oconf->port);
1235 >  AddOFlag(source_p, oconf->port);
1236  
1237 <  if (IsOperAdmin(source_p) || IsOperHiddenAdmin(source_p))
1238 <    source_p->umodes |= UMODE_ADMIN;
1239 <  if (!IsOperN(source_p))
1240 <    source_p->umodes &= ~UMODE_NCHANGE;
1237 >  if (HasOFlag(source_p, OPER_FLAG_HIDDEN_ADMIN|OPER_FLAG_ADMIN))
1238 >    AddUMode(source_p, UMODE_ADMIN);
1239 >  if (!HasOFlag(source_p, OPER_FLAG_N))
1240 >    DelUMode(source_p, UMODE_NCHANGE);
1241  
1242    sendto_realops_flags(UMODE_ALL, L_ALL, "%s (%s@%s) is now an operator",
1243                         source_p->name, source_p->username, source_p->host);

Diff Legend

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