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 33 by knight, Sun Oct 2 20:50:00 2005 UTC vs.
ircd-hybrid-7.2/src/s_user.c (file contents), Revision 582 by michael, Tue May 2 20:47:11 2006 UTC

# Line 201 | Line 201 | show_lusers(struct Client *source_p)
201                 Count.invisi, dlink_list_length(&global_serv_list));
202    else
203      sendto_one(source_p, form_str(RPL_LUSERCLIENT), from, to,
204 <              (Count.total-Count.invisi), Count.invisi, 1);
204 >               (Count.total-Count.invisi), Count.invisi, 1);
205  
206    if (Count.oper > 0)
207      sendto_one(source_p, form_str(RPL_LUSEROP),
208 <               from, to, Count.oper);
208 >               from, to, Count.oper);
209  
210    if (dlink_list_length(&unknown_list) > 0)
211      sendto_one(source_p, form_str(RPL_LUSERUNKNOWN),
212 <               from, to, dlink_list_length(&unknown_list));
212 >               from, to, dlink_list_length(&unknown_list));
213  
214    if (dlink_list_length(&global_channel_list) > 0)
215      sendto_one(source_p, form_str(RPL_LUSERCHANNELS),
216 <               from, to,
217 <               dlink_list_length(&global_channel_list));
216 >               from, to, dlink_list_length(&global_channel_list));
217  
218    if (!ConfigServerHide.hide_servers || IsOper(source_p))
219    {
220      sendto_one(source_p, form_str(RPL_LUSERME),
221 <               from, to,
223 <               Count.local, Count.myserver);
221 >               from, to, Count.local, Count.myserver);
222      sendto_one(source_p, form_str(RPL_LOCALUSERS),
223 <               from, to, Count.local, Count.max_loc,
224 <               Count.local, Count.max_loc);
223 >               from, to, Count.local, Count.max_loc,
224 >               Count.local, Count.max_loc);
225    }
226    else
227    {
228      sendto_one(source_p, form_str(RPL_LUSERME),
229 <               from, to, Count.total, 0);
229 >               from, to, Count.total, 0);
230      sendto_one(source_p, form_str(RPL_LOCALUSERS),
231 <               from, to, Count.total, Count.max_tot,
231 >               from, to, Count.total, Count.max_tot,
232                 Count.total, Count.max_tot);
233    }
234  
# Line 240 | Line 238 | show_lusers(struct Client *source_p)
238  
239    if (!ConfigServerHide.hide_servers || IsOper(source_p))
240      sendto_one(source_p, form_str(RPL_STATSCONN), from, to,
241 <               MaxConnectionCount, MaxClientCount, Count.totalrestartcount);
241 >               MaxConnectionCount, MaxClientCount, Count.totalrestartcount);
242  
243    if (Count.local > MaxClientCount)
244      MaxClientCount = Count.local;
# Line 290 | Line 288 | register_local_user(struct Client *clien
288   {
289    const struct AccessItem *aconf = NULL;
290    char ipaddr[HOSTIPLEN];
291 <  dlink_node *ptr;
292 <  dlink_node *m;
291 >  dlink_node *ptr = NULL;
292 >  dlink_node *m = NULL;
293  
294    assert(source_p != NULL);
295    assert(MyConnect(source_p));
296    assert(source_p->username != username);
297 +  assert(!source_p->localClient->registration);
298  
299    if (ConfigFileEntry.ping_cookie)
300    {
# Line 424 | Line 423 | register_local_user(struct Client *clien
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 450 | Line 450 | register_local_user(struct Client *clien
450      return;
451  
452    if (ConfigFileEntry.invisible_on_connect)
453 +  {
454      source_p->umodes |= UMODE_INVISIBLE;
455 <  Count.invisi++;
455 >    Count.invisi++;
456 >  }
457  
458    if ((++Count.local) > Count.max_loc)
459    {
# Line 502 | Line 504 | register_local_user(struct Client *clien
504   */
505   void
506   register_remote_user(struct Client *client_p, struct Client *source_p,
507 <                     const char *username, const char *host, const char *server,
508 <                     const char *realname)
507 >                     const char *username, const char *host, const char *server,
508 >                     const char *realname)
509   {
510 <  struct Client *target_p;
510 >  struct Client *target_p = NULL;
511  
512    assert(source_p != NULL);
513    assert(source_p->username != username);
# Line 514 | Line 516 | register_remote_user(struct Client *clie
516    strlcpy(source_p->info, realname, sizeof(source_p->info));
517    strlcpy(source_p->username, username, sizeof(source_p->username));
518  
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 –
519    /*
520     * coming from another server, take the servers word for it
521     */
# Line 537 | Line 533 | register_remote_user(struct Client *clie
533                           source_p->host, source_p->from->name);
534      kill_client(client_p, source_p, "%s (Server doesn't exist)", me.name);
535  
540 –    /* XXX */
536      SetKilled(source_p);
537      exit_client(source_p, &me, "Ghosted Client");
538      return;
# Line 558 | Line 553 | register_remote_user(struct Client *clie
553      return;
554    }
555  
556 +  /* Increment our total user count here */
557 +  if (++Count.total > Count.max_tot)
558 +    Count.max_tot = Count.total;
559 +
560 +  ++source_p->from->serv->dep_users;
561 +
562    SetClient(source_p);
563    dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->users);
564    add_user_host(source_p->username, source_p->host, 1);
# Line 578 | Line 579 | register_remote_user(struct Client *clie
579   static void
580   introduce_client(struct Client *client_p, struct Client *source_p)
581   {
582 <  dlink_node *server_node;
582 >  dlink_node *server_node = NULL;
583    static char ubuf[12];
584  
585    if (MyClient(source_p))
# Line 607 | Line 608 | introduce_client(struct Client *client_p
608     * -davidt
609     * rewritten to cope with SIDs .. eww eww eww --is
610     */
610 –
611 –  /* XXX THESE NEED A PREFIX!?!?!? */
611    if (!ServerInfo.hub && uplink && IsCapable(uplink, CAP_LL) &&
612        client_p != uplink)
613    {
# Line 617 | Line 616 | introduce_client(struct Client *client_p
616        sendto_one(uplink, ":%s UID %s %d %lu %s %s %s %s %s :%s",
617                   source_p->servptr->id,
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 <                 ((MyClient(source_p) && !IsIPSpoof(source_p)) ?
622 <                 source_p->sockhost : "0"),
624 <                 source_p->id, source_p->info);
621 >                 (MyClient(source_p) && IsIPSpoof(source_p)) ?
622 >                 "0" : source_p->sockhost, source_p->id, source_p->info);
623      }
624      else
625      {
626        sendto_one(uplink, "NICK %s %d %lu %s %s %s %s :%s",
627                   source_p->name, source_p->hopcount+1,
628 <                 (unsigned long)source_p->tsinfo,
628 >                 (unsigned long)source_p->tsinfo,
629                   ubuf, source_p->username, source_p->host,
630 <                 source_p->servptr->name,
633 <                 source_p->info);
630 >                 source_p->servptr->name, source_p->info);
631      }
632    }
633    else
# Line 646 | Line 643 | introduce_client(struct Client *client_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,
646 >                   (unsigned long)source_p->tsinfo,
647                     ubuf, source_p->username, source_p->host,
648 <                   ((MyClient(source_p)&&!IsIPSpoof(source_p))?source_p->sockhost:"0"),
649 <                   source_p->id, source_p->info);
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,
653 >                   (unsigned long)source_p->tsinfo,
654                     ubuf, source_p->username, source_p->host,
655 <                   source_p->servptr->name,
659 <                   source_p->info);
655 >                   source_p->servptr->name, source_p->info);
656      }
657    }
658   }
# Line 677 | Line 673 | valid_hostname(const char *hostname)
673  
674    assert(p != NULL);
675  
676 <  if (('.' == *p) || (':' == *p))
677 <    return (0);
676 >  if ('.' == *p || ':' == *p)
677 >    return 0;
678  
679    while (*p)
680    {
681      if (!IsHostChar(*p))
682 <      return (0);
682 >      return 0;
683      p++;
684    }
685  
686 <  return (1);
686 >  return 1;
687   }
688  
689   /* valid_username()
# Line 717 | Line 713 | valid_username(const char *username)
713     * or "-hi-@somehost", "h-----@somehost" would still be accepted.
714     */
715    if (!IsAlNum(*p))
716 <    return (0);
716 >    return 0;
717  
718    while (*++p)
719    {
# Line 726 | Line 722 | valid_username(const char *username)
722        dots++;
723  
724        if (dots > ConfigFileEntry.dots_in_ident)
725 <        return (0);
725 >        return 0;
726        if (!IsUserChar(p[1]))
727 <        return (0);
727 >        return 0;
728      }
729      else if (!IsUserChar(*p))
730 <      return (0);
730 >      return 0;
731    }
732  
733 <  return (1);
733 >  return 1;
734   }
735  
736   /* report_and_set_user_flags()
# Line 833 | Line 829 | do_local_user(const char *nick, struct C
829      return;
830    }
831  
832 <  source_p->flags |= FLAGS_GOTUSER;
832 >  source_p->localClient->registration &= ~REG_NEED_USER;
833  
834    /*
835     * don't take the clients word for it, ever
# Line 850 | Line 846 | do_local_user(const char *nick, struct C
846      strlcpy(source_p->username, username, sizeof(source_p->username));
847    }
848  
849 <  if (source_p->name[0])
854 <  {
849 >  if (!source_p->localClient->registration)
850      /* NICK already received, now I have USER... */
851      register_local_user(client_p, source_p, source_p->name, username);
857 –  }
852   }
853  
854   /* change_simple_umode()
# Line 897 | Line 891 | set_user_mode(struct Client *client_p, s
891    char **p, *m, buf[IRCD_BUFSIZE];
892    struct Client *target_p;
893    int what = MODE_ADD, badflag = 0, i;
894 < #if 0
895 <  /* already covered by m_mode */
896 <  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
894 >
895 >  assert(!(parc < 2));
896 >
897    if ((target_p = find_person(client_p, parv[1])) == NULL)
898    {
899      if (MyConnect(source_p))
# Line 914 | Line 902 | set_user_mode(struct Client *client_p, s
902      return;
903    }
904  
917 –  /* Dont know why these were commented out..
918 –   * put them back using new sendto() funcs
919 –   */
905    if (IsServer(source_p))
906    {
907       sendto_realops_flags(UMODE_ALL, L_ADMIN, "*** Mode for User %s from %s",
# Line 1017 | Line 1002 | set_user_mode(struct Client *client_p, s
1002                badflag = 1;
1003              }
1004              else
1005 <              execute_callback(umode_cb, client_p, source_p, what, flag);
1005 >              execute_callback(umode_cb, client_p, source_p, what, flag);
1006            }
1007            else
1008            {
# Line 1054 | Line 1039 | set_user_mode(struct Client *client_p, s
1039    if ((setflags & UMODE_INVISIBLE) && !IsInvisible(source_p))
1040      --Count.invisi;
1041  
1042 <  /* compare new flags with old flags and send string which
1042 >  /*
1043 >   * compare new flags with old flags and send string which
1044     * will cause servers to update correctly.
1045     */
1046    send_umode_out(client_p, source_p, setflags);
# Line 1073 | Line 1059 | send_umode(struct Client *client_p, stru
1059    unsigned int flag;
1060    char *m = umode_buf;
1061  
1062 <  /* build a string in umode_buf to represent the change in the user's
1062 >  /*
1063 >   * build a string in umode_buf to represent the change in the user's
1064     * mode between the new (source_p->umodes) and 'old'.
1065     */
1066    for (i = 0; i < 128; i++)
# Line 1112 | Line 1099 | send_umode(struct Client *client_p, stru
1099    *m = '\0';
1100  
1101    if (*umode_buf && client_p)
1102 <    sendto_one(client_p, ":%s MODE %s :%s",
1103 <               source_p->name, source_p->name, umode_buf);
1102 >    sendto_one(client_p, ":%s!%s@%s MODE %s :%s",
1103 >               source_p->name, source_p->username,
1104 >               source_p->host, source_p->name, umode_buf);
1105   }
1106  
1107   /* send_umode_out()
# Line 1126 | Line 1114 | void
1114   send_umode_out(struct Client *client_p, struct Client *source_p,
1115                 unsigned int old)
1116   {
1117 <  char buf[IRCD_BUFSIZE];
1117 >  char buf[IRCD_BUFSIZE] = { '\0' };
1118    dlink_node *ptr = NULL;
1119  
1120    send_umode(NULL, source_p, old, IsOperHiddenAdmin(source_p) ?
1121               SEND_UMODES & ~UMODE_ADMIN : SEND_UMODES, buf);
1122  
1123 <  if (*buf)
1123 >  if (buf[0])
1124    {
1125      DLINK_FOREACH(ptr, serv_list.head)
1126      {
# Line 1179 | Line 1167 | user_welcome(struct Client *source_p)
1167    sendto_one(source_p, form_str(RPL_WELCOME), me.name, source_p->name,
1168               ServerInfo.network_name, source_p->name);
1169    sendto_one(source_p, form_str(RPL_YOURHOST), me.name, source_p->name,
1170 <             get_listener_name(source_p->localClient->listener), ircd_version);
1170 >             get_listener_name(source_p->localClient->listener), ircd_version);
1171    sendto_one(source_p, form_str(RPL_CREATED),
1172 <             me.name, source_p->name, built_date);
1172 >             me.name, source_p->name, built_date);
1173    sendto_one(source_p, form_str(RPL_MYINFO),
1174               me.name, source_p->name, me.name, ircd_version, umode_buffer);
1175    show_isupport(source_p);
# Line 1236 | Line 1224 | check_xline(struct Client *source_p)
1224        reason = "No Reason";
1225  
1226      sendto_realops_flags(UMODE_REJ, L_ALL,
1227 <                         "X-line Rejecting [%s] [%s], user %s [%s]",
1228 <                         source_p->info, reason,
1229 <                         get_client_name(source_p, HIDE_IP),
1230 <                         source_p->sockhost);
1227 >                         "X-line Rejecting [%s] [%s], user %s [%s]",
1228 >                         source_p->info, reason,
1229 >                         get_client_name(source_p, HIDE_IP),
1230 >                         source_p->sockhost);
1231  
1232      ServerStats->is_ref++;      
1233 <    if(REJECT_HOLD_TIME > 0)
1233 >    if (REJECT_HOLD_TIME > 0)
1234      {
1235        sendto_one(source_p, ":%s NOTICE %s :Bad user info",
1236 <                 me.name, source_p->name);
1236 >                 me.name, source_p->name);
1237        source_p->localClient->reject_delay = CurrentTime + REJECT_HOLD_TIME;
1238        SetCaptured(source_p);
1239      }
# Line 1301 | Line 1289 | oper_up(struct Client *source_p)
1289   {
1290    unsigned int old = source_p->umodes;
1291    const char *operprivs = "";
1292 <  struct AccessItem *oconf;
1292 >  const struct AccessItem *oconf = NULL;
1293  
1294 +  assert(source_p->localClient->confs.head);
1295 +  oconf = map_to_conf((source_p->localClient->confs.head)->data);
1296 +
1297 +  ++Count.oper;
1298    SetOper(source_p);
1299  
1300 <  if (ConfigFileEntry.oper_umodes)
1300 >  if (oconf->modes)
1301 >    source_p->umodes |= oconf->modes;
1302 >  else if (ConfigFileEntry.oper_umodes)
1303      source_p->umodes |= ConfigFileEntry.oper_umodes;
1304    else
1305      source_p->umodes |= (UMODE_SERVNOTICE|UMODE_OPERWALL|
1306 <                         UMODE_WALLOP|UMODE_LOCOPS);
1313 <
1314 <  Count.oper++;
1306 >                         UMODE_WALLOP|UMODE_LOCOPS);
1307  
1308    assert(dlinkFind(&oper_list, source_p) == NULL);
1309    dlinkAdd(source_p, make_dlink_node(), &oper_list);
1310  
1319 –  assert(source_p->localClient->confs.head);
1320 –  oconf = map_to_conf((source_p->localClient->confs.head)->data);
1311    operprivs = oper_privs_as_string(oconf->port);
1312  
1313    SetOFlag(source_p, oconf->port);
# Line 1336 | Line 1326 | oper_up(struct Client *source_p)
1326    send_message_file(source_p, &ConfigFileEntry.opermotd);
1327   }
1328  
1329 < /*
1340 < * Quick and dirty UID code for new proposed SID on EFnet
1341 < *
1342 < */
1329 > static char new_uid[TOTALSIDUID + 1];     /* allow for \0 */
1330  
1331 < static char new_uid[TOTALSIDUID+1];     /* allow for \0 */
1332 < static void add_one_to_uid(int i);
1331 > int
1332 > valid_sid(const char *sid)
1333 > {
1334 >
1335 >  if (strlen(sid) == IRC_MAXSID)
1336 >    if (IsDigit(*sid))
1337 >      if (IsAlNum(*(sid + 1)) && IsAlNum(*(sid + 2)))
1338 >        return 1;
1339 >
1340 >  return 0;
1341 > }
1342  
1343   /*
1344   * init_uid()
# Line 1362 | Line 1358 | init_uid(void)
1358  
1359    if (ServerInfo.sid != NULL)
1360    {
1361 <    memcpy(new_uid, ServerInfo.sid, IRCD_MIN(strlen(ServerInfo.sid),
1362 <                                             IRC_MAXSID));
1363 <    memcpy(&me.id, ServerInfo.sid, IRCD_MIN(strlen(ServerInfo.sid),
1368 <                                             IRC_MAXSID));
1361 >    strlcpy(new_uid, ServerInfo.sid, sizeof(new_uid));
1362 >    strlcpy(me.id, ServerInfo.sid, sizeof(me.id));
1363 >
1364      hash_add_id(&me);
1365    }
1366  
# Line 1373 | Line 1368 | init_uid(void)
1368      if (new_uid[i] == '\0')
1369        new_uid[i] = 'A';
1370  
1371 <  /* XXX if IRC_MAXUID != 6, this will have to be rewritten */
1371 >  /* NOTE: if IRC_MAXUID != 6, this will have to be rewritten */
1372    /* Yes nenolod, I have known it was off by one ever since I wrote it
1373     * But *JUST* for you, though, it really doesn't look as *pretty*
1374     * -Dianora
1375     */
1376 <  memcpy(new_uid+IRC_MAXSID, "AAAAA@", IRC_MAXUID);
1376 >  memcpy(new_uid + IRC_MAXSID, "AAAAA@", IRC_MAXUID);
1377  
1378    entering_umode_cb = register_callback("entering_umode", NULL);
1379    umode_cb = register_callback("changing_umode", change_simple_umode);
# Line 1386 | Line 1381 | init_uid(void)
1381   }
1382  
1383   /*
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 – /*
1384   * add_one_to_uid
1385   *
1386   * inputs       - index number into new_uid
# Line 1410 | Line 1391 | uid_get(va_list args)
1391   static void
1392   add_one_to_uid(int i)
1393   {
1394 <  if (i != IRC_MAXSID)          /* Not reached server SID portion yet? */
1394 >  if (i != IRC_MAXSID)    /* Not reached server SID portion yet? */
1395    {
1396      if (new_uid[i] == 'Z')
1397        new_uid[i] = '0';
# Line 1419 | Line 1400 | add_one_to_uid(int i)
1400        new_uid[i] = 'A';
1401        add_one_to_uid(i-1);
1402      }
1403 <    else new_uid[i] = new_uid[i] + 1;
1403 >    else
1404 >      ++new_uid[i];
1405    }
1406    else
1407    {
1408 <    /* XXX if IRC_MAXUID != 6, this will have to be rewritten */
1408 >    /* NOTE: if IRC_MAXUID != 6, this will have to be rewritten */
1409      if (new_uid[i] == 'Z')
1410 <      memcpy(new_uid+IRC_MAXSID, "AAAAAA", IRC_MAXUID);
1410 >      memcpy(new_uid + IRC_MAXSID, "AAAAAA", IRC_MAXUID);
1411      else
1412 <      new_uid[i] = new_uid[i] + 1;
1412 >      ++new_uid[i];
1413    }
1414   }
1415  
1416   /*
1417 + * uid_get
1418 + *
1419 + * inputs       - struct Client *
1420 + * output       - new UID is returned to caller
1421 + * side effects - new_uid is incremented by one.
1422 + */
1423 + static void *
1424 + uid_get(va_list args)
1425 + {
1426 +  add_one_to_uid(TOTALSIDUID - 1);    /* index from 0 */
1427 +  return new_uid;
1428 + }
1429 +
1430 + /*
1431   * init_isupport()
1432   *
1433   * input        - NONE
# Line 1573 | Line 1569 | rebuild_isupport_message_line(void)
1569      if (++tokens == (MAXPARA-2) || len >= (sizeof(isupportbuffer)-reserve))
1570      { /* arbritrary for now */
1571        if (*--p == ' ')
1572 <        *p = '\0';
1572 >        *p = '\0';
1573  
1574        addto_MessageLine(isupportFile, isupportbuffer);
1575        p = isupportbuffer;

Diff Legend

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