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 159 by michael, Wed Oct 19 09:39:13 2005 UTC vs.
Revision 849 by db, Mon Feb 19 19:41:59 2007 UTC

# Line 67 | Line 67 | static char umode_buffer[IRCD_BUFSIZE];
67   static void user_welcome(struct Client *);
68   static void report_and_set_user_flags(struct Client *, const struct AccessItem *);
69   static int check_xline(struct Client *);
70 static int check_regexp_xline(struct Client *);
70   static void introduce_client(struct Client *, struct Client *);
71   static void *uid_get(va_list);
72  
# Line 96 | Line 95 | unsigned int user_modes[256] =
95    0,                  /* @ */
96    0,                  /* A */
97    0,                  /* B */
98 <  0,                  /* C */
98 >  UMODE_CCONN_FULL,   /* C */
99    UMODE_DEAF,         /* D */
100    0,                  /* E */
101    0,                  /* F */
# Line 294 | Line 293 | register_local_user(struct Client *clien
293    assert(source_p != NULL);
294    assert(MyConnect(source_p));
295    assert(source_p->username != username);
296 +  assert(!source_p->localClient->registration);
297 +
298 +  ClearCap(client_p, CAP_TS6);
299  
300    if (ConfigFileEntry.ping_cookie)
301    {
# Line 415 | Line 417 | register_local_user(struct Client *clien
417  
418    assert(source_p == client_p);
419  
420 <  /* end of valid user name check */
419 <  if (check_xline(source_p) || check_regexp_xline(source_p))
420 >  if (check_xline(source_p))
421      return;
422  
423    if (IsDead(client_p))
424      return;
425  
426 <  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 443 | Line 445 | register_local_user(struct Client *clien
445                         "255.255.255.255" : ipaddr, get_client_class(source_p),
446                         source_p->info);
447  
448 +  sendto_realops_flags(UMODE_CCONN_FULL, L_ALL,
449 +                       "CLICONN %s %s %s %s %s %s %s 0 %s",
450 +                       nick, source_p->username, source_p->host,
451 +                       ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ?
452 +                       "255.255.255.255" : ipaddr,
453 +                       get_client_class(source_p),
454 +                       ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ?
455 +                           "<hidden>" : source_p->client_host,
456 +                       ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ?
457 +                           "<hidden>" : source_p->client_server,
458 +                       source_p->info);
459 +
460 +
461    /* If they have died in send_* don't do anything. */
462    if (IsDead(source_p))
463      return;
# Line 514 | Line 529 | register_remote_user(struct Client *clie
529    strlcpy(source_p->info, realname, sizeof(source_p->info));
530    strlcpy(source_p->username, username, sizeof(source_p->username));
531  
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
532    /*
533     * coming from another server, take the servers word for it
534     */
# Line 537 | Line 546 | register_remote_user(struct Client *clie
546                           source_p->host, source_p->from->name);
547      kill_client(client_p, source_p, "%s (Server doesn't exist)", me.name);
548  
540    /* XXX */
549      SetKilled(source_p);
550      exit_client(source_p, &me, "Ghosted Client");
551      return;
# Line 558 | Line 566 | register_remote_user(struct Client *clie
566      return;
567    }
568  
569 +  /* Increment our total user count here */
570 +  if (++Count.total > Count.max_tot)
571 +    Count.max_tot = Count.total;
572 +
573 +  ++source_p->from->serv->dep_users;
574 +
575    SetClient(source_p);
576    dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->users);
577    add_user_host(source_p->username, source_p->host, 1);
# Line 607 | Line 621 | introduce_client(struct Client *client_p
621     * -davidt
622     * rewritten to cope with SIDs .. eww eww eww --is
623     */
610
611  /* XXX THESE NEED A PREFIX!?!?!? */
624    if (!ServerInfo.hub && uplink && IsCapable(uplink, CAP_LL) &&
625        client_p != uplink)
626    {
# Line 617 | Line 629 | introduce_client(struct Client *client_p
629        sendto_one(uplink, ":%s UID %s %d %lu %s %s %s %s %s :%s",
630                   source_p->servptr->id,
631                   source_p->name, source_p->hopcount+1,
632 <                 (unsigned long)source_p->tsinfo,
632 >                 (unsigned long)source_p->tsinfo,
633                   ubuf, source_p->username, source_p->host,
634 <                 ((MyClient(source_p) && !IsIPSpoof(source_p)) ?
635 <                 source_p->sockhost : "0"),
624 <                 source_p->id, source_p->info);
634 >                 (MyClient(source_p) && IsIPSpoof(source_p)) ?
635 >                 "0" : source_p->sockhost, source_p->id, source_p->info);
636      }
637      else
638      {
639        sendto_one(uplink, "NICK %s %d %lu %s %s %s %s :%s",
640                   source_p->name, source_p->hopcount+1,
641 <                 (unsigned long)source_p->tsinfo,
641 >                 (unsigned long)source_p->tsinfo,
642                   ubuf, source_p->username, source_p->host,
643 <                 source_p->servptr->name,
633 <                 source_p->info);
643 >                 source_p->servptr->name, source_p->info);
644      }
645    }
646    else
# Line 646 | Line 656 | introduce_client(struct Client *client_p
656          sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s :%s",
657                     source_p->servptr->id,
658                     source_p->name, source_p->hopcount+1,
659 <                   (unsigned long)source_p->tsinfo,
659 >                   (unsigned long)source_p->tsinfo,
660                     ubuf, source_p->username, source_p->host,
661 <                   ((MyClient(source_p)&&!IsIPSpoof(source_p))?source_p->sockhost:"0"),
662 <                   source_p->id, source_p->info);
661 >                   (MyClient(source_p) && IsIPSpoof(source_p)) ?
662 >                   "0" : source_p->sockhost, source_p->id, source_p->info);
663        else
664          sendto_one(server, "NICK %s %d %lu %s %s %s %s :%s",
665                     source_p->name, source_p->hopcount+1,
666 <                   (unsigned long)source_p->tsinfo,
666 >                   (unsigned long)source_p->tsinfo,
667                     ubuf, source_p->username, source_p->host,
668 <                   source_p->servptr->name,
659 <                   source_p->info);
668 >                   source_p->servptr->name, source_p->info);
669      }
670    }
671   }
# Line 833 | Line 842 | do_local_user(const char *nick, struct C
842      return;
843    }
844  
845 <  source_p->flags |= FLAGS_GOTUSER;
845 >  source_p->localClient->registration &= ~REG_NEED_USER;
846  
847    /*
848     * don't take the clients word for it, ever
# Line 842 | Line 851 | do_local_user(const char *nick, struct C
851  
852    strlcpy(source_p->info, realname, sizeof(source_p->info));
853  
854 +  /* stash for later */
855 +  strlcpy(source_p->client_host, host, sizeof(source_p->client_host));
856 +  strlcpy(source_p->client_server, server, sizeof(source_p->client_server));
857 +
858    if (!IsGotId(source_p))
859    {
860      /* save the username in the client
# Line 850 | Line 863 | do_local_user(const char *nick, struct C
863      strlcpy(source_p->username, username, sizeof(source_p->username));
864    }
865  
866 <  if (source_p->name[0])
854 <  {
866 >  if (!source_p->localClient->registration)
867      /* NICK already received, now I have USER... */
868      register_local_user(client_p, source_p, source_p->name, username);
857  }
869   }
870  
871   /* change_simple_umode()
# Line 865 | Line 876 | do_local_user(const char *nick, struct C
876   static void *
877   change_simple_umode(va_list args)
878   {
879 +  struct Client *client_p;
880    struct Client *source_p;
881    int what;
882    unsigned int flag;
883  
884 <  va_arg(args, struct Client *);
884 >  client_p = va_arg(args, struct Client *);
885    source_p = va_arg(args, struct Client *);
886    what = va_arg(args, int);
887    flag = va_arg(args, unsigned int);
# Line 1055 | Line 1067 | set_user_mode(struct Client *client_p, s
1067   /* send_umode()
1068   * send the MODE string for user (user) to connection client_p
1069   * -avalon
1070 + *
1071 + * inputs       - client_p
1072 + *              - source_p
1073 + *              - int old
1074 + *              - sendmask mask of modes to send
1075 + *              - suplied umode_buf
1076 + * output       - NONE
1077   */
1078   void
1079   send_umode(struct Client *client_p, struct Client *source_p,
# Line 1105 | Line 1124 | send_umode(struct Client *client_p, stru
1124    *m = '\0';
1125  
1126    if (*umode_buf && client_p)
1127 <    sendto_one(client_p, ":%s MODE %s :%s",
1128 <               source_p->name, source_p->name, umode_buf);
1127 >    sendto_one(client_p, ":%s!%s@%s MODE %s :%s",
1128 >               source_p->name, source_p->username,
1129 >               source_p->host, source_p->name, umode_buf);
1130   }
1131  
1132   /* send_umode_out()
# Line 1119 | Line 1139 | void
1139   send_umode_out(struct Client *client_p, struct Client *source_p,
1140                 unsigned int old)
1141   {
1142 <  char buf[IRCD_BUFSIZE];
1142 >  char buf[IRCD_BUFSIZE] = { '\0' };
1143    dlink_node *ptr = NULL;
1144  
1145    send_umode(NULL, source_p, old, IsOperHiddenAdmin(source_p) ?
1146               SEND_UMODES & ~UMODE_ADMIN : SEND_UMODES, buf);
1147  
1148 <  if (*buf)
1148 >  if (buf[0])
1149    {
1150      DLINK_FOREACH(ptr, serv_list.head)
1151      {
# Line 1213 | Line 1233 | user_welcome(struct Client *source_p)
1233   static int
1234   check_xline(struct Client *source_p)
1235   {
1236 <  struct ConfItem *conf;
1237 <  struct MatchItem *xconf;
1218 <  const char *reason;
1236 >  struct ConfItem *conf = NULL;
1237 >  const char *reason = NULL;
1238  
1239 <  if ((conf = find_matching_name_conf(XLINE_TYPE, source_p->info,
1240 <                                      NULL, NULL, 0)) != NULL)
1239 >  if ((conf = find_matching_name_conf(XLINE_TYPE, source_p->info, NULL, NULL, 0)) ||
1240 >      (conf = find_matching_name_conf(RXLINE_TYPE, source_p->info, NULL, NULL, 0)))
1241    {
1242 <    xconf = map_to_conf(conf);
1224 <    xconf->count++;
1242 >    struct MatchItem *reg = map_to_conf(conf);
1243  
1244 <    if (xconf->reason != NULL)
1245 <      reason = xconf->reason;
1244 >    ++reg->count;
1245 >
1246 >    if (reg->reason != NULL)
1247 >      reason = reg->reason;
1248      else
1249        reason = "No Reason";
1250  
# Line 1234 | Line 1254 | check_xline(struct Client *source_p)
1254                           get_client_name(source_p, HIDE_IP),
1255                           source_p->sockhost);
1256  
1257 <    ServerStats->is_ref++;      
1257 >    ServerStats->is_ref++;
1258      if (REJECT_HOLD_TIME > 0)
1259      {
1260        sendto_one(source_p, ":%s NOTICE %s :Bad user info",
# Line 1250 | Line 1270 | check_xline(struct Client *source_p)
1270    return 0;
1271   }
1272  
1253 static int
1254 check_regexp_xline(struct Client *source_p)
1255 {
1256  struct ConfItem *conf = NULL;
1257  const char *reason = NULL;
1258
1259  if ((conf = find_matching_name_conf(RXLINE_TYPE, source_p->info, NULL, NULL, 0)))
1260  {
1261    struct MatchItem *reg = map_to_conf(conf);
1262
1263    ++reg->count;
1264
1265    if (reg->reason != NULL)
1266      reason = reg->reason;
1267    else
1268      reason = "No Reason";
1269
1270    sendto_realops_flags(UMODE_REJ, L_ALL,
1271                         "X-line (REGEX) Rejecting [%s] [%s], user %s [%s]",
1272                         source_p->info, reason,
1273                         get_client_name(source_p, HIDE_IP),
1274                         source_p->sockhost);
1275
1276    ServerStats->is_ref++;
1277    exit_client(source_p, &me, "Bad user info");
1278    return 1;
1279  }
1280
1281  return 0;
1282 }
1283
1273   /* oper_up()
1274   *
1275   * inputs       - pointer to given client to oper
# Line 1331 | Line 1320 | oper_up(struct Client *source_p)
1320    send_message_file(source_p, &ConfigFileEntry.opermotd);
1321   }
1322  
1323 < /*
1324 < * Quick and dirty UID code for new proposed SID on EFnet
1325 < *
1326 < */
1323 > static char new_uid[TOTALSIDUID + 1];     /* allow for \0 */
1324 >
1325 > int
1326 > valid_sid(const char *sid)
1327 > {
1328 >
1329 >  if (strlen(sid) == IRC_MAXSID)
1330 >    if (IsDigit(*sid))
1331 >      if (IsAlNum(*(sid + 1)) && IsAlNum(*(sid + 2)))
1332 >        return 1;
1333  
1334 < static char new_uid[TOTALSIDUID+1];     /* allow for \0 */
1335 < static void add_one_to_uid(int i);
1334 >  return 0;
1335 > }
1336  
1337   /*
1338   * init_uid()
# Line 1357 | Line 1352 | init_uid(void)
1352  
1353    if (ServerInfo.sid != NULL)
1354    {
1355 <    memcpy(new_uid, ServerInfo.sid, IRCD_MIN(strlen(ServerInfo.sid),
1356 <                                             IRC_MAXSID));
1357 <    memcpy(&me.id, ServerInfo.sid, IRCD_MIN(strlen(ServerInfo.sid),
1363 <                                            IRC_MAXSID));
1355 >    strlcpy(new_uid, ServerInfo.sid, sizeof(new_uid));
1356 >    strlcpy(me.id, ServerInfo.sid, sizeof(me.id));
1357 >
1358      hash_add_id(&me);
1359    }
1360  
# Line 1368 | Line 1362 | init_uid(void)
1362      if (new_uid[i] == '\0')
1363        new_uid[i] = 'A';
1364  
1365 <  /* XXX if IRC_MAXUID != 6, this will have to be rewritten */
1365 >  /* NOTE: if IRC_MAXUID != 6, this will have to be rewritten */
1366    /* Yes nenolod, I have known it was off by one ever since I wrote it
1367     * But *JUST* for you, though, it really doesn't look as *pretty*
1368     * -Dianora
1369     */
1370 <  memcpy(new_uid+IRC_MAXSID, "AAAAA@", IRC_MAXUID);
1370 >  memcpy(new_uid + IRC_MAXSID, "AAAAA@", IRC_MAXUID);
1371  
1372    entering_umode_cb = register_callback("entering_umode", NULL);
1373    umode_cb = register_callback("changing_umode", change_simple_umode);
# Line 1381 | Line 1375 | init_uid(void)
1375   }
1376  
1377   /*
1384 * uid_get
1385 *
1386 * inputs       - struct Client *
1387 * output       - new UID is returned to caller
1388 * side effects - new_uid is incremented by one.
1389 */
1390 static void *
1391 uid_get(va_list args)
1392 {
1393  add_one_to_uid(TOTALSIDUID-1);    /* index from 0 */
1394  return ((void *) new_uid);
1395 }
1396
1397 /*
1378   * add_one_to_uid
1379   *
1380   * inputs       - index number into new_uid
# Line 1414 | Line 1394 | add_one_to_uid(int i)
1394        new_uid[i] = 'A';
1395        add_one_to_uid(i-1);
1396      }
1397 <    else new_uid[i] = new_uid[i] + 1;
1397 >    else
1398 >      ++new_uid[i];
1399    }
1400    else
1401    {
1402 <    /* XXX if IRC_MAXUID != 6, this will have to be rewritten */
1402 >    /* NOTE: if IRC_MAXUID != 6, this will have to be rewritten */
1403      if (new_uid[i] == 'Z')
1404 <      memcpy(new_uid+IRC_MAXSID, "AAAAAA", IRC_MAXUID);
1404 >      memcpy(new_uid + IRC_MAXSID, "AAAAAA", IRC_MAXUID);
1405      else
1406 <      new_uid[i] = new_uid[i] + 1;
1406 >      ++new_uid[i];
1407    }
1408   }
1409  
1410   /*
1411 + * uid_get
1412 + *
1413 + * inputs       - struct Client *
1414 + * output       - new UID is returned to caller
1415 + * side effects - new_uid is incremented by one.
1416 + */
1417 + static void *
1418 + uid_get(va_list args)
1419 + {
1420 +  add_one_to_uid(TOTALSIDUID - 1);    /* index from 0 */
1421 +  return new_uid;
1422 + }
1423 +
1424 + /*
1425   * init_isupport()
1426   *
1427   * input        - NONE
# Line 1440 | Line 1435 | init_isupport(void)
1435  
1436    add_isupport("CALLERID", NULL, -1);
1437    add_isupport("CASEMAPPING", CASEMAP, -1);
1438 +  add_isupport("DEAF", "D", -1);
1439    add_isupport("KICKLEN", NULL, KICKLEN);
1440    add_isupport("MODES", NULL, MAXMODEPARAMS);
1441    add_isupport("NICKLEN", NULL, NICKLEN-1);

Diff Legend

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