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

Comparing:
ircd-hybrid-8/src/s_user.c (file contents), Revision 1559 by michael, Sun Oct 14 01:38:28 2012 UTC vs.
ircd-hybrid/trunk/src/s_user.c (file contents), Revision 1819 by michael, Fri Apr 12 11:57:26 2013 UTC

# Line 32 | Line 32
32   #include "fdlist.h"
33   #include "hash.h"
34   #include "irc_string.h"
35 #include "sprintf_irc.h"
35   #include "s_bsd.h"
36   #include "ircd.h"
37   #include "listener.h"
# Line 60 | Line 59 | struct Callback *umode_cb = NULL;
59   static char umode_buffer[IRCD_BUFSIZE];
60  
61   static void user_welcome(struct Client *);
62 < static void report_and_set_user_flags(struct Client *, const struct AccessItem *);
62 > static void report_and_set_user_flags(struct Client *, const struct MaskItem *);
63   static int check_xline(struct Client *);
64   static void introduce_client(struct Client *);
65   static const char *uid_get(void);
# Line 120 | Line 119 | unsigned int user_modes[256] =
119    UMODE_BOTS,         /* b */
120    UMODE_CCONN,        /* c */
121    UMODE_DEBUG,        /* d */
122 <  0,                  /* e */
122 >  UMODE_EXTERNAL,     /* e */
123    UMODE_FULL,         /* f */
124    UMODE_CALLERID,     /* g */
125    0,                  /* h */
# Line 139 | Line 138 | unsigned int user_modes[256] =
138    UMODE_UNAUTH,       /* u */
139    0,                  /* v */
140    UMODE_WALLOP,       /* w */
141 <  UMODE_EXTERNAL,     /* x */
141 >  0,                  /* x */
142    UMODE_SPY,          /* y */
143    UMODE_OPERWALL,     /* z      0x7A */
144    0,0,0,0,0,          /* 0x7B - 0x7F */
# Line 280 | Line 279 | void
279   register_local_user(struct Client *source_p)
280   {
281    const char *id = NULL;
282 <  const struct AccessItem *aconf = NULL;
284 <  dlink_node *ptr = NULL;
282 >  const struct MaskItem *conf = NULL;
283  
284    assert(source_p != NULL);
285    assert(source_p == source_p->from);
# Line 312 | Line 310 | register_local_user(struct Client *sourc
310    /* Straight up the maximum rate of flooding... */
311    source_p->localClient->allow_read = MAX_FLOOD_BURST;
312  
313 <  if (!execute_callback(client_check_cb, source_p, source_p->username))
313 >  if (!check_client(source_p))
314      return;
315  
316    if (valid_hostname(source_p->host) == 0)
# Line 323 | Line 321 | register_local_user(struct Client *sourc
321              sizeof(source_p->host));
322    }
323  
324 <  ptr   = source_p->localClient->confs.head;
327 <  aconf = map_to_conf(ptr->data);
324 >  conf = source_p->localClient->confs.head->data;
325  
326    if (!IsGotId(source_p))
327    {
# Line 332 | Line 329 | register_local_user(struct Client *sourc
329      const char *p = username;
330      unsigned int i = 0;
331  
332 <    if (IsNeedIdentd(aconf))
332 >    if (IsNeedIdentd(conf))
333      {
334        ++ServerStats.is_ref;
335        sendto_one(source_p, ":%s NOTICE %s :*** Notice -- You need to install "
# Line 343 | Line 340 | register_local_user(struct Client *sourc
340  
341      strlcpy(username, source_p->username, sizeof(username));
342  
343 <    if (!IsNoTilde(aconf))
343 >    if (!IsNoTilde(conf))
344        source_p->username[i++] = '~';
345  
346      for (; *p && i < USERLEN; ++p)
# Line 354 | Line 351 | register_local_user(struct Client *sourc
351    }
352  
353    /* password check */
354 <  if (!EmptyString(aconf->passwd))
354 >  if (!EmptyString(conf->passwd))
355    {
356      const char *pass = source_p->localClient->passwd;
357  
358 <    if (!match_conf_password(pass, aconf))
358 >    if (!match_conf_password(pass, conf))
359      {
360        ++ServerStats.is_ref;
361        sendto_one(source_p, form_str(ERR_PASSWDMISMATCH),
# Line 374 | Line 371 | register_local_user(struct Client *sourc
371     */
372  
373    /* report if user has &^>= etc. and set flags as needed in source_p */
374 <  report_and_set_user_flags(source_p, aconf);
374 >  report_and_set_user_flags(source_p, conf);
375  
376    if (IsDead(source_p))
377      return;
# Line 390 | Line 387 | register_local_user(struct Client *sourc
387    if ((Count.local >= ServerInfo.max_clients + MAX_BUFFER) ||
388        (Count.local >= ServerInfo.max_clients && !IsExemptLimits(source_p)))
389    {
390 <    sendto_realops_flags(UMODE_FULL, L_ALL,
390 >    sendto_realops_flags(UMODE_FULL, L_ALL, SEND_NOTICE,
391                           "Too many clients, rejecting %s[%s].",
392                           source_p->name, source_p->host);
393      ++ServerStats.is_ref;
# Line 403 | Line 400 | register_local_user(struct Client *sourc
400    {
401      char tmpstr2[IRCD_BUFSIZE];
402  
403 <    sendto_realops_flags(UMODE_REJ, L_ALL, "Invalid username: %s (%s@%s)",
403 >    sendto_realops_flags(UMODE_REJ, L_ALL, SEND_NOTICE,
404 >                         "Invalid username: %s (%s@%s)",
405                           source_p->name, source_p->username, source_p->host);
406      ++ServerStats.is_ref;
407      snprintf(tmpstr2, sizeof(tmpstr2), "Invalid username [%s]",
# Line 421 | Line 419 | register_local_user(struct Client *sourc
419    strlcpy(source_p->id, id, sizeof(source_p->id));
420    hash_add_id(source_p);
421  
422 <  sendto_realops_flags(UMODE_CCONN, L_ALL,
422 >  sendto_realops_flags(UMODE_CCONN, L_ALL, SEND_NOTICE,
423                         "Client connecting: %s (%s@%s) [%s] {%s} [%s] <%s>",
424                         source_p->name, source_p->username, source_p->host,
425                         ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ?
426                         "255.255.255.255" : source_p->sockhost,
427 <                       get_client_class(source_p),
427 >                       get_client_class(&source_p->localClient->confs),
428                         source_p->info, source_p->id);
429  
430 <  sendto_realops_flags(UMODE_CCONN_FULL, L_ALL,
430 >  sendto_realops_flags(UMODE_CCONN_FULL, L_ALL, SEND_NOTICE,
431                         "CLICONN %s %s %s %s %s %s %s 0 %s",
432                         source_p->name, source_p->username, source_p->host,
433                         ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ?
434                         "255.255.255.255" : source_p->sockhost,
435 <                       get_client_class(source_p),
435 >                       get_client_class(&source_p->localClient->confs),
436                         ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ?
437                             "<hidden>" : source_p->localClient->client_host,
438                         ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ?
# Line 453 | Line 451 | register_local_user(struct Client *sourc
451      Count.max_loc = Count.local;
452  
453      if (!(Count.max_loc % 10))
454 <      sendto_realops_flags(UMODE_ALL, L_ALL, "New Max Local Clients: %d",
454 >      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
455 >                           "New Max Local Clients: %d",
456                             Count.max_loc);
457    }
458  
# Line 509 | Line 508 | register_remote_user(struct Client *sour
508     */
509    source_p->servptr = hash_find_server(server);
510  
511 <  /* Super GhostDetect:
511 >  /*
512 >   * Super GhostDetect:
513     * If we can't find the server the user is supposed to be on,
514     * then simply blow the user away.        -Taner
515     */
516    if (source_p->servptr == NULL)
517    {
518 <    sendto_realops_flags(UMODE_ALL, L_ALL,
518 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
519                           "No server %s for user %s[%s@%s] from %s",
520                           server, source_p->name, source_p->username,
521                           source_p->host, source_p->from->name);
# Line 528 | Line 528 | register_remote_user(struct Client *sour
528  
529    if ((target_p = source_p->servptr) && target_p->from != source_p->from)
530    {
531 <    sendto_realops_flags(UMODE_DEBUG, L_ALL,
531 >    sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE,
532                           "Bad User [%s] :%s USER %s@%s %s, != %s[%s]",
533                           source_p->from->name, source_p->name, source_p->username,
534                           source_p->host, source_p->servptr->name,
# Line 658 | Line 658 | valid_hostname(const char *hostname)
658      if (!IsHostChar(*p))
659        return 0;
660  
661 <  return 1;
661 >  return p - hostname <= HOSTLEN;
662   }
663  
664   /* valid_username()
# Line 734 | Line 734 | valid_nickname(const char *nickname, con
734   /* report_and_set_user_flags()
735   *
736   * inputs       - pointer to source_p
737 < *              - pointer to aconf for this user
737 > *              - pointer to conf for this user
738   * output       - NONE
739   * side effects - Report to user any special flags
740   *                they are getting, and set them.
741   */
742   static void
743 < report_and_set_user_flags(struct Client *source_p, const struct AccessItem *aconf)
743 > report_and_set_user_flags(struct Client *source_p, const struct MaskItem *conf)
744   {
745    /* If this user is being spoofed, tell them so */
746 <  if (IsConfDoSpoofIp(aconf))
746 >  if (IsConfDoSpoofIp(conf))
747    {
748      sendto_one(source_p,
749                 ":%s NOTICE %s :*** Spoofing your IP. congrats.",
# Line 751 | Line 751 | report_and_set_user_flags(struct Client
751    }
752  
753    /* If this user is in the exception class, Set it "E lined" */
754 <  if (IsConfExemptKline(aconf))
754 >  if (IsConfExemptKline(conf))
755    {
756      SetExemptKline(source_p);
757      sendto_one(source_p,
# Line 762 | Line 762 | report_and_set_user_flags(struct Client
762    /* The else here is to make sure that G line exempt users
763     * do not get noticed twice.
764     */
765 <  else if (IsConfExemptGline(aconf))
765 >  else if (IsConfExemptGline(conf))
766    {
767      SetExemptGline(source_p);
768      sendto_one(source_p, ":%s NOTICE %s :*** You are exempt from G lines.",
769                 me.name, source_p->name);
770    }
771  
772 <  if (IsConfExemptResv(aconf))
772 >  if (IsConfExemptResv(conf))
773    {
774      SetExemptResv(source_p);
775      sendto_one(source_p, ":%s NOTICE %s :*** You are exempt from resvs.",
# Line 777 | Line 777 | report_and_set_user_flags(struct Client
777    }
778  
779    /* If this user is exempt from user limits set it "F lined" */
780 <  if (IsConfExemptLimits(aconf))
780 >  if (IsConfExemptLimits(conf))
781    {
782      SetExemptLimits(source_p);
783      sendto_one(source_p,
# Line 785 | Line 785 | report_and_set_user_flags(struct Client
785                 me.name,source_p->name);
786    }
787  
788 <  if (IsConfCanFlood(aconf))
788 >  if (IsConfCanFlood(conf))
789    {
790      SetCanFlood(source_p);
791      sendto_one(source_p, ":%s NOTICE %s :*** You are exempt from flood "
# Line 846 | Line 846 | set_user_mode(struct Client *client_p, s
846      return;
847    }
848  
849  if (IsServer(source_p))
850  {
851     sendto_realops_flags(UMODE_ALL, L_ADMIN, "*** Mode for User %s from %s",
852                          parv[1], source_p->name);
853     return;
854  }
855
849    if (source_p != target_p)
850    {
851       sendto_one(source_p, form_str(ERR_USERSDONTMATCH),
# Line 917 | Line 910 | set_user_mode(struct Client *client_p, s
910              {
911                dlink_node *dm;
912  
913 <              detach_conf(source_p, OPER_TYPE);
913 >              detach_conf(source_p, CONF_OPER);
914                ClrOFlag(source_p);
915                DelUMode(source_p, ConfigFileEntry.oper_only_umodes);
916  
# Line 1088 | Line 1081 | send_umode_out(struct Client *client_p,
1081      send_umode(client_p, source_p, old, 0xffffffff, buf);
1082   }
1083  
1084 + void
1085 + user_set_hostmask(struct Client *target_p, const char *hostname)
1086 + {
1087 +  if (!valid_hostname(hostname))
1088 +    return;
1089 +
1090 +  if (IsUserHostIp(target_p))
1091 +    delete_user_host(target_p->username, target_p->host, !MyConnect(target_p));
1092 +
1093 +  strlcpy(target_p->host, hostname, sizeof(target_p->host));
1094 +  SetIPSpoof(target_p);
1095 +
1096 +  add_user_host(target_p->username, target_p->host, !MyConnect(target_p));
1097 +  SetUserHost(target_p);
1098 +
1099 +  if (MyClient(target_p))
1100 +    clear_ban_cache_client(target_p);
1101 + }
1102 +
1103   /* user_welcome()
1104   *
1105   * inputs       - client pointer to client to welcome
# Line 1154 | Line 1166 | user_welcome(struct Client *source_p)
1166   static int
1167   check_xline(struct Client *source_p)
1168   {
1169 <  struct ConfItem *conf = NULL;
1169 >  struct MaskItem *conf = NULL;
1170    const char *reason = NULL;
1171  
1172 <  if ((conf = find_matching_name_conf(XLINE_TYPE, source_p->info, NULL, NULL, 0)) ||
1173 <      (conf = find_matching_name_conf(RXLINE_TYPE, source_p->info, NULL, NULL, 0)))
1172 >  if ((conf = find_matching_name_conf(CONF_XLINE, source_p->info, NULL, NULL, 0)) ||
1173 >      (conf = find_matching_name_conf(CONF_RXLINE, source_p->info, NULL, NULL, 0)))
1174    {
1175 <    struct MatchItem *reg = map_to_conf(conf);
1164 <
1165 <    ++reg->count;
1175 >    ++conf->count;
1176  
1177 <    if (reg->reason != NULL)
1178 <      reason = reg->reason;
1177 >    if (conf->reason != NULL)
1178 >      reason = conf->reason;
1179      else
1180        reason = "No Reason";
1181  
1182 <    sendto_realops_flags(UMODE_REJ, L_ALL,
1182 >    sendto_realops_flags(UMODE_REJ, L_ALL, SEND_NOTICE,
1183                           "X-line Rejecting [%s] [%s], user %s [%s]",
1184                           source_p->info, reason,
1185                           get_client_name(source_p, HIDE_IP),
# Line 1187 | Line 1197 | check_xline(struct Client *source_p)
1197   *
1198   * inputs       - pointer to given client to oper
1199   * output       - NONE
1200 < * side effects - Blindly opers up given source_p, using aconf info
1200 > * side effects - Blindly opers up given source_p, using conf info
1201   *                all checks on passwords have already been done.
1202   *                This could also be used by rsa oper routines.
1203   */
# Line 1195 | Line 1205 | void
1205   oper_up(struct Client *source_p)
1206   {
1207    const unsigned int old = source_p->umodes;
1208 <  const struct AccessItem *oconf = NULL;
1208 >  const struct MaskItem *conf = source_p->localClient->confs.head->data;
1209  
1210    assert(source_p->localClient->confs.head);
1201  oconf = map_to_conf((source_p->localClient->confs.head)->data);
1211  
1212    ++Count.oper;
1213    SetOper(source_p);
1214  
1215 <  if (oconf->modes)
1216 <    AddUMode(source_p, oconf->modes);
1215 >  if (conf->modes)
1216 >    AddUMode(source_p, conf->modes);
1217    else if (ConfigFileEntry.oper_umodes)
1218      AddUMode(source_p, ConfigFileEntry.oper_umodes);
1219  
# Line 1216 | Line 1225 | oper_up(struct Client *source_p)
1225    assert(dlinkFind(&oper_list, source_p) == NULL);
1226    dlinkAdd(source_p, make_dlink_node(), &oper_list);
1227  
1228 <  AddOFlag(source_p, oconf->port);
1228 >  AddOFlag(source_p, conf->port);
1229  
1230    if (HasOFlag(source_p, OPER_FLAG_ADMIN))
1231      AddUMode(source_p, UMODE_ADMIN);
1232    if (!HasOFlag(source_p, OPER_FLAG_N))
1233      DelUMode(source_p, UMODE_NCHANGE);
1234  
1235 <  sendto_realops_flags(UMODE_ALL, L_ALL, "%s is now an operator",
1235 >  sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, "%s is now an operator",
1236                         get_oper_name(source_p));
1237    send_umode_out(source_p, source_p, old);
1238    sendto_one(source_p, form_str(RPL_YOUREOPER), me.name, source_p->name);
# Line 1340 | Line 1349 | init_isupport(void)
1349    add_isupport("DEAF", "D", -1);
1350    add_isupport("KICKLEN", NULL, KICKLEN);
1351    add_isupport("MODES", NULL, MAXMODEPARAMS);
1343  add_isupport("NICKLEN", NULL, NICKLEN);
1352   #ifdef HALFOPS
1353    add_isupport("PREFIX", "(ohv)@%+", -1);
1354    add_isupport("STATUSMSG", "@%+", -1);
# Line 1348 | Line 1356 | init_isupport(void)
1356    add_isupport("PREFIX", "(ov)@+", -1);
1357    add_isupport("STATUSMSG", "@+", -1);
1358   #endif
1351  add_isupport("TOPICLEN", NULL, TOPICLEN);
1359   }
1360  
1361   /*
# Line 1383 | Line 1390 | add_isupport(const char *name, const cha
1390      dlinkAddTail(support, &support->node, &support_list);
1391    }
1392  
1393 <  DupString(support->name, name);
1393 >  support->name = xstrdup(name);
1394    if (options != NULL)
1395 <    DupString(support->options, options);
1395 >    support->options = xstrdup(options);
1396    support->number = n;
1397  
1398    rebuild_isupport_message_line();
# Line 1444 | Line 1451 | rebuild_isupport_message_line(void)
1451    {
1452      struct Isupport *support = ptr->data;
1453  
1454 <    p += (n = ircsprintf(p, "%s", support->name));
1454 >    p += (n = sprintf(p, "%s", support->name));
1455      len += n;
1456  
1457      if (support->options != NULL)
1458      {
1459 <      p += (n = ircsprintf(p, "=%s", support->options));
1459 >      p += (n = sprintf(p, "=%s", support->options));
1460        len += n;
1461      }
1462  
1463      if (support->number > 0)
1464      {
1465 <      p += (n = ircsprintf(p, "=%d", support->number));
1465 >      p += (n = sprintf(p, "=%d", support->number));
1466        len += n;
1467      }
1468  

Diff Legend

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