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.2/src/s_user.c (file contents):
Revision 573 by michael, Mon May 1 09:40:37 2006 UTC vs.
Revision 980 by michael, Sun Aug 9 12:51:45 2009 UTC

# 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"
39   #include "list.h"
40   #include "listener.h"
# Line 44 | Line 43
43   #include "s_conf.h"
44   #include "s_log.h"
45   #include "s_serv.h"
47 #include "s_stats.h"
46   #include "send.h"
47   #include "supported.h"
48   #include "whowas.h"
# Line 55 | Line 53
53   #include "s_misc.h"
54   #include "msg.h"
55   #include "pcre.h"
56 + #include "watch.h"
57  
58   int MaxClientCount     = 1;
59   int MaxConnectionCount = 1;
# Line 67 | Line 66 | static char umode_buffer[IRCD_BUFSIZE];
66   static void user_welcome(struct Client *);
67   static void report_and_set_user_flags(struct Client *, const struct AccessItem *);
68   static int check_xline(struct Client *);
70 static int check_regexp_xline(struct Client *);
69   static void introduce_client(struct Client *, struct Client *);
70   static void *uid_get(va_list);
71  
# Line 96 | Line 94 | unsigned int user_modes[256] =
94    0,                  /* @ */
95    0,                  /* A */
96    0,                  /* B */
97 <  0,                  /* C */
97 >  UMODE_CCONN_FULL,   /* C */
98    UMODE_DEAF,         /* D */
99    0,                  /* E */
100    0,                  /* F */
# Line 287 | Line 285 | register_local_user(struct Client *clien
285                      const char *nick, const char *username)
286   {
287    const struct AccessItem *aconf = NULL;
290  char ipaddr[HOSTIPLEN];
288    dlink_node *ptr = NULL;
289    dlink_node *m = NULL;
290  
# Line 296 | Line 293 | register_local_user(struct Client *clien
293    assert(source_p->username != username);
294    assert(!source_p->localClient->registration);
295  
296 +  ClearCap(client_p, CAP_TS6);
297 +
298    if (ConfigFileEntry.ping_cookie)
299    {
300      if (!IsPingSent(source_p) &&
# Line 337 | Line 336 | register_local_user(struct Client *clien
336  
337      if (IsNeedIdentd(aconf))
338      {
339 <      ServerStats->is_ref++;
339 >      ++ServerStats.is_ref;
340        sendto_one(source_p, ":%s NOTICE %s :*** Notice -- You need to install "
341                   "identd to use this server", me.name, source_p->name);
342        exit_client(source_p, &me, "Install identd");
# Line 366 | Line 365 | register_local_user(struct Client *clien
365  
366      if (!match_conf_password(pass, aconf))
367      {
368 <      ServerStats->is_ref++;
368 >      ++ServerStats.is_ref;
369        sendto_one(source_p, form_str(ERR_PASSWDMISMATCH),
370                   me.name, source_p->name);
371        exit_client(source_p, &me, "Bad Password");
# Line 382 | Line 381 | register_local_user(struct Client *clien
381    /* report if user has &^>= etc. and set flags as needed in source_p */
382    report_and_set_user_flags(source_p, aconf);
383  
384 +  if (IsDead(client_p))
385 +    return;
386 +
387    /* Limit clients -
388     * We want to be able to have servers and F-line clients
389     * connect, so save room for "buffer" connections.
# Line 396 | Line 398 | register_local_user(struct Client *clien
398      sendto_realops_flags(UMODE_FULL, L_ALL,
399                           "Too many clients, rejecting %s[%s].",
400                           nick, source_p->host);
401 <    ServerStats->is_ref++;
401 >    ++ServerStats.is_ref;
402      exit_client(source_p, &me, "Sorry, server is full - try later");
403      return;
404    }
# Line 408 | Line 410 | register_local_user(struct Client *clien
410  
411      sendto_realops_flags(UMODE_REJ, L_ALL, "Invalid username: %s (%s@%s)",
412                           nick, source_p->username, source_p->host);
413 <    ServerStats->is_ref++;
413 >    ++ServerStats.is_ref;
414      ircsprintf(tmpstr2, "Invalid username [%s]", source_p->username);
415      exit_client(source_p, &me, tmpstr2);
416      return;
# Line 416 | Line 418 | register_local_user(struct Client *clien
418  
419    assert(source_p == client_p);
420  
421 <  /* end of valid user name check */
420 <  if (check_xline(source_p) || check_regexp_xline(source_p))
421 <    return;
422 <
423 <  if (IsDead(client_p))
421 >  if (check_xline(source_p))
422      return;
423  
424    if (me.id[0])
# Line 434 | Line 432 | register_local_user(struct Client *clien
432      hash_add_id(source_p);
433    }
434  
437  irc_getnameinfo((struct sockaddr *)&source_p->localClient->ip,
438                  source_p->localClient->ip.ss_len, ipaddr,
439                  HOSTIPLEN, NULL, 0, NI_NUMERICHOST);
440
435    sendto_realops_flags(UMODE_CCONN, L_ALL,
436                         "Client connecting: %s (%s@%s) [%s] {%s} [%s]",
437                         nick, source_p->username, source_p->host,
438                         ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ?
439 <                       "255.255.255.255" : ipaddr, get_client_class(source_p),
439 >                       "255.255.255.255" : source_p->sockhost,
440 >                       get_client_class(source_p),
441 >                       source_p->info);
442 >
443 >  sendto_realops_flags(UMODE_CCONN_FULL, L_ALL,
444 >                       "CLICONN %s %s %s %s %s %s %s 0 %s",
445 >                       nick, source_p->username, source_p->host,
446 >                       ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ?
447 >                       "255.255.255.255" : source_p->sockhost,
448 >                       get_client_class(source_p),
449 >                       ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ?
450 >                           "<hidden>" : source_p->client_host,
451 >                       ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ?
452 >                           "<hidden>" : source_p->client_server,
453                         source_p->info);
454  
448  /* If they have died in send_* don't do anything. */
449  if (IsDead(source_p))
450    return;
455  
456    if (ConfigFileEntry.invisible_on_connect)
457    {
458      source_p->umodes |= UMODE_INVISIBLE;
459 <    Count.invisi++;
459 >    ++Count.invisi;
460    }
461  
462    if ((++Count.local) > Count.max_loc)
# Line 467 | Line 471 | register_local_user(struct Client *clien
471    SetClient(source_p);
472  
473    source_p->servptr = &me;
474 <  dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->users);
474 >  dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->client_list);
475  
476    /* Increment our total user count here */
477    if (++Count.total > Count.max_tot)
478      Count.max_tot = Count.total;
479 <  Count.totalrestartcount++;
479 >  ++Count.totalrestartcount;
480  
481    source_p->localClient->allow_read = MAX_FLOOD_BURST;
482  
# Line 557 | Line 561 | register_remote_user(struct Client *clie
561    if (++Count.total > Count.max_tot)
562      Count.max_tot = Count.total;
563  
560  ++source_p->from->serv->dep_users;
561
564    SetClient(source_p);
565 <  dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->users);
565 >  dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->client_list);
566    add_user_host(source_p->username, source_p->host, 1);
567    SetUserHost(source_p);
568  
# Line 587 | Line 589 | introduce_client(struct Client *client_p
589    else
590      send_umode(NULL, source_p, 0, SEND_UMODES, ubuf);
591  
592 +  watch_check_hash(source_p, RPL_LOGON);
593 +
594    if (*ubuf == '\0')
595    {
596      ubuf[0] = '+';
597      ubuf[1] = '\0';
598    }
599  
600 <  /* arghhh one could try not introducing new nicks to ll leafs
597 <   * but then you have to introduce them "on the fly" in SJOIN
598 <   * not fun.
599 <   * Its not going to cost much more bandwidth to simply let new
600 <   * nicks just ride on through.
601 <   */
602 <
603 <  /* We now introduce nicks "on the fly" in SJOIN anyway --
604 <   * you _need_ to if you aren't going to burst everyone initially.
605 <   *
606 <   * Only send to non CAP_LL servers, unless we're a lazylink leaf,
607 <   * in that case just send it to the uplink.
608 <   * -davidt
609 <   * rewritten to cope with SIDs .. eww eww eww --is
610 <   */
611 <  if (!ServerInfo.hub && uplink && IsCapable(uplink, CAP_LL) &&
612 <      client_p != uplink)
600 >  DLINK_FOREACH(server_node, serv_list.head)
601    {
602 <    if (IsCapable(uplink, CAP_TS6) && HasID(source_p))
603 <    {
604 <      sendto_one(uplink, ":%s UID %s %d %lu %s %s %s %s %s :%s",
602 >    struct Client *server = server_node->data;
603 >
604 >    if (server == client_p)
605 >        continue;
606 >
607 >    if (IsCapable(server, CAP_TS6) && HasID(source_p))
608 >      sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s :%s",
609                   source_p->servptr->id,
610                   source_p->name, source_p->hopcount+1,
611                   (unsigned long)source_p->tsinfo,
612                   ubuf, source_p->username, source_p->host,
613                   (MyClient(source_p) && IsIPSpoof(source_p)) ?
614                   "0" : source_p->sockhost, source_p->id, source_p->info);
623    }
615      else
616 <    {
626 <      sendto_one(uplink, "NICK %s %d %lu %s %s %s %s :%s",
616 >      sendto_one(server, "NICK %s %d %lu %s %s %s %s :%s",
617                   source_p->name, source_p->hopcount+1,
618                   (unsigned long)source_p->tsinfo,
619                   ubuf, source_p->username, source_p->host,
620                   source_p->servptr->name, source_p->info);
631    }
632  }
633  else
634  {
635    DLINK_FOREACH(server_node, serv_list.head)
636    {
637      struct Client *server = server_node->data;
638
639      if (IsCapable(server, CAP_LL) || server == client_p)
640        continue;
641
642      if (IsCapable(server, CAP_TS6) && HasID(source_p))
643        sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s :%s",
644                   source_p->servptr->id,
645                   source_p->name, source_p->hopcount+1,
646                   (unsigned long)source_p->tsinfo,
647                   ubuf, source_p->username, source_p->host,
648                   (MyClient(source_p) && IsIPSpoof(source_p)) ?
649                   "0" : source_p->sockhost, source_p->id, source_p->info);
650      else
651        sendto_one(server, "NICK %s %d %lu %s %s %s %s :%s",
652                   source_p->name, source_p->hopcount+1,
653                   (unsigned long)source_p->tsinfo,
654                   ubuf, source_p->username, source_p->host,
655                   source_p->servptr->name, source_p->info);
656    }
621    }
622   }
623  
# Line 838 | Line 802 | do_local_user(const char *nick, struct C
802  
803    strlcpy(source_p->info, realname, sizeof(source_p->info));
804  
805 +  /* stash for later */
806 +  strlcpy(source_p->client_host, host, sizeof(source_p->client_host));
807 +  strlcpy(source_p->client_server, server, sizeof(source_p->client_server));
808 +
809    if (!IsGotId(source_p))
810    {
811      /* save the username in the client
# Line 859 | Line 827 | do_local_user(const char *nick, struct C
827   static void *
828   change_simple_umode(va_list args)
829   {
830 +  struct Client *client_p;
831    struct Client *source_p;
832    int what;
833    unsigned int flag;
834  
835 <  va_arg(args, struct Client *);
835 >  client_p = va_arg(args, struct Client *);
836    source_p = va_arg(args, struct Client *);
837    what = va_arg(args, int);
838    flag = va_arg(args, unsigned int);
# Line 1049 | Line 1018 | set_user_mode(struct Client *client_p, s
1018   /* send_umode()
1019   * send the MODE string for user (user) to connection client_p
1020   * -avalon
1021 + *
1022 + * inputs       - client_p
1023 + *              - source_p
1024 + *              - int old
1025 + *              - sendmask mask of modes to send
1026 + *              - suplied umode_buf
1027 + * output       - NONE
1028   */
1029   void
1030   send_umode(struct Client *client_p, struct Client *source_p,
# Line 1127 | Line 1103 | send_umode_out(struct Client *client_p,
1103        struct Client *target_p = ptr->data;
1104  
1105        if ((target_p != client_p) && (target_p != source_p))
1106 <      {
1107 <        if ((!(ServerInfo.hub && IsCapable(target_p, CAP_LL))) ||
1108 <            (target_p->localClient->serverMask &
1133 <             source_p->lazyLinkClientExists))
1134 <          sendto_one(target_p, ":%s MODE %s :%s",
1135 <                     ID_or_name(source_p, target_p),
1136 <                     ID_or_name(source_p, target_p), buf);
1137 <      }
1106 >        sendto_one(target_p, ":%s MODE %s :%s",
1107 >                   ID_or_name(source_p, target_p),
1108 >                   ID_or_name(source_p, target_p), buf);
1109      }
1110    }
1111  
# Line 1208 | Line 1179 | user_welcome(struct Client *source_p)
1179   static int
1180   check_xline(struct Client *source_p)
1181   {
1182 <  struct ConfItem *conf;
1183 <  struct MatchItem *xconf;
1213 <  const char *reason;
1182 >  struct ConfItem *conf = NULL;
1183 >  const char *reason = NULL;
1184  
1185 <  if ((conf = find_matching_name_conf(XLINE_TYPE, source_p->info,
1186 <                                      NULL, NULL, 0)) != NULL)
1185 >  if ((conf = find_matching_name_conf(XLINE_TYPE, source_p->info, NULL, NULL, 0)) ||
1186 >      (conf = find_matching_name_conf(RXLINE_TYPE, source_p->info, NULL, NULL, 0)))
1187    {
1188 <    xconf = map_to_conf(conf);
1219 <    xconf->count++;
1188 >    struct MatchItem *reg = map_to_conf(conf);
1189  
1190 <    if (xconf->reason != NULL)
1191 <      reason = xconf->reason;
1190 >    ++reg->count;
1191 >
1192 >    if (reg->reason != NULL)
1193 >      reason = reg->reason;
1194      else
1195        reason = "No Reason";
1196  
# Line 1229 | Line 1200 | check_xline(struct Client *source_p)
1200                           get_client_name(source_p, HIDE_IP),
1201                           source_p->sockhost);
1202  
1203 <    ServerStats->is_ref++;      
1203 >    ++ServerStats.is_ref;
1204      if (REJECT_HOLD_TIME > 0)
1205      {
1206        sendto_one(source_p, ":%s NOTICE %s :Bad user info",
# Line 1245 | Line 1216 | check_xline(struct Client *source_p)
1216    return 0;
1217   }
1218  
1248 static int
1249 check_regexp_xline(struct Client *source_p)
1250 {
1251  struct ConfItem *conf = NULL;
1252  const char *reason = NULL;
1253
1254  if ((conf = find_matching_name_conf(RXLINE_TYPE, source_p->info, NULL, NULL, 0)))
1255  {
1256    struct MatchItem *reg = map_to_conf(conf);
1257
1258    ++reg->count;
1259
1260    if (reg->reason != NULL)
1261      reason = reg->reason;
1262    else
1263      reason = "No Reason";
1264
1265    sendto_realops_flags(UMODE_REJ, L_ALL,
1266                         "X-line (REGEX) Rejecting [%s] [%s], user %s [%s]",
1267                         source_p->info, reason,
1268                         get_client_name(source_p, HIDE_IP),
1269                         source_p->sockhost);
1270
1271    ServerStats->is_ref++;
1272    exit_client(source_p, &me, "Bad user info");
1273    return 1;
1274  }
1275
1276  return 0;
1277 }
1278
1219   /* oper_up()
1220   *
1221   * inputs       - pointer to given client to oper
# Line 1305 | Line 1245 | oper_up(struct Client *source_p)
1245      source_p->umodes |= (UMODE_SERVNOTICE|UMODE_OPERWALL|
1246                           UMODE_WALLOP|UMODE_LOCOPS);
1247  
1248 +  if (!(old & UMODE_INVISIBLE) && IsInvisible(source_p))
1249 +    ++Count.invisi;
1250 +  if ((old & UMODE_INVISIBLE) && !IsInvisible(source_p))
1251 +    --Count.invisi;
1252 +
1253    assert(dlinkFind(&oper_list, source_p) == NULL);
1254    dlinkAdd(source_p, make_dlink_node(), &oper_list);
1255  
# Line 1334 | Line 1279 | valid_sid(const char *sid)
1279  
1280    if (strlen(sid) == IRC_MAXSID)
1281      if (IsDigit(*sid))
1282 <      if (IsUpper(*(sid + 1)) && IsUpper(*(sid + 2)))
1282 >      if (IsAlNum(*(sid + 1)) && IsAlNum(*(sid + 2)))
1283          return 1;
1284  
1285    return 0;
# Line 1441 | Line 1386 | init_isupport(void)
1386  
1387    add_isupport("CALLERID", NULL, -1);
1388    add_isupport("CASEMAPPING", CASEMAP, -1);
1389 +  add_isupport("DEAF", "D", -1);
1390    add_isupport("KICKLEN", NULL, KICKLEN);
1391    add_isupport("MODES", NULL, MAXMODEPARAMS);
1392    add_isupport("NICKLEN", NULL, NICKLEN-1);

Diff Legend

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