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/trunk/src/s_user.c (file contents), Revision 3319 by michael, Tue Apr 15 15:41:50 2014 UTC vs.
ircd-hybrid/trunk/src/user.c (file contents), Revision 4222 by michael, Mon Jul 14 18:56:29 2014 UTC

# Line 26 | Line 26
26  
27   #include "stdinc.h"
28   #include "list.h"
29 < #include "s_user.h"
29 > #include "user.h"
30   #include "channel.h"
31   #include "channel_mode.h"
32   #include "client.h"
# Line 38 | Line 38
38   #include "numeric.h"
39   #include "conf.h"
40   #include "log.h"
41 < #include "s_serv.h"
41 > #include "server.h"
42   #include "send.h"
43 #include "supported.h"
43   #include "memory.h"
44   #include "packet.h"
45   #include "rng_mt.h"
46   #include "userhost.h"
47 < #include "s_misc.h"
47 > #include "misc.h"
48   #include "parse.h"
49   #include "watch.h"
50  
# Line 117 | Line 116 | const unsigned int user_modes[256] =
116    0,                  /* m */
117    UMODE_NCHANGE,      /* n */
118    UMODE_OPER,         /* o */
119 <  0,                  /* p */
120 <  0,                  /* q */
119 >  UMODE_HIDECHANS,    /* p */
120 >  UMODE_HIDEIDLE,     /* q */
121    UMODE_REGISTERED,   /* r */
122    UMODE_SERVNOTICE,   /* s */
123    0,                  /* t */
# Line 127 | Line 126 | const unsigned int user_modes[256] =
126    UMODE_WALLOP,       /* w */
127    UMODE_HIDDENHOST,   /* x */
128    UMODE_SPY,          /* y */
129 <  UMODE_OPERWALL,     /* z      0x7A */
129 >  0,                  /* z      0x7A */
130    0,0,0,0,0,          /* 0x7B - 0x7F */
131  
132    /* 0x80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x8F */
# Line 164 | Line 163 | show_lusers(struct Client *source_p)
163   {
164    if (!ConfigServerHide.hide_servers || HasUMode(source_p, UMODE_OPER))
165      sendto_one_numeric(source_p, &me, RPL_LUSERCLIENT, (Count.total-Count.invisi),
166 <                       Count.invisi, dlink_list_length(&global_serv_list));
166 >                       Count.invisi, dlink_list_length(&global_server_list));
167    else
168      sendto_one_numeric(source_p, &me, RPL_LUSERCLIENT,
169 <                       (Count.total-Count.invisi), Count.invisi, 1);
169 >                       (Count.total - Count.invisi), Count.invisi, 1);
170  
171 <  if (Count.oper > 0)
171 >  if (Count.oper)
172      sendto_one_numeric(source_p, &me, RPL_LUSEROP, Count.oper);
173  
174 <  if (dlink_list_length(&unknown_list) > 0)
174 >  if (dlink_list_length(&unknown_list))
175      sendto_one_numeric(source_p, &me, RPL_LUSERUNKNOWN, dlink_list_length(&unknown_list));
176  
177 <  if (dlink_list_length(&global_channel_list) > 0)
178 <    sendto_one_numeric(source_p, &me, RPL_LUSERCHANNELS, dlink_list_length(&global_channel_list));
177 >  if (dlink_list_length(&channel_list))
178 >    sendto_one_numeric(source_p, &me, RPL_LUSERCHANNELS, dlink_list_length(&channel_list));
179  
180    if (!ConfigServerHide.hide_servers || HasUMode(source_p, UMODE_OPER))
181    {
# Line 286 | Line 285 | introduce_client(struct Client *source_p
285    char ubuf[IRCD_BUFSIZE] = "";
286  
287    if (MyClient(source_p))
288 <    send_umode(source_p, source_p, 0, SEND_UMODES, ubuf);
288 >    send_umode(source_p, source_p, 0, ubuf);
289    else
290 <    send_umode(NULL, source_p, 0, SEND_UMODES, ubuf);
290 >    send_umode(NULL, source_p, 0, ubuf);
291  
292    watch_check_hash(source_p, RPL_LOGON);
293  
# Line 298 | Line 297 | introduce_client(struct Client *source_p
297      ubuf[1] = '\0';
298    }
299  
300 <  DLINK_FOREACH(ptr, serv_list.head)
300 >  DLINK_FOREACH(ptr, local_server_list.head)
301    {
302      struct Client *server = ptr->data;
303  
# Line 360 | Line 359 | user_welcome(struct Client *source_p)
359    sendto_one_numeric(source_p, &me, RPL_CREATED, built_date);
360    sendto_one_numeric(source_p, &me, RPL_MYINFO, me.name, ircd_version, umode_buffer);
361    show_isupport(source_p);
362 <
364 <  if (source_p->id[0])
365 <    sendto_one_numeric(source_p, &me, RPL_YOURID, source_p->id);
362 >  sendto_one_numeric(source_p, &me, RPL_YOURID, source_p->id);
363  
364    show_lusers(source_p);
365    motd_signon(source_p);
# Line 476 | Line 473 | register_local_user(struct Client *sourc
473        source_p->username[i++] = '~';
474  
475      for (; *p && i < USERLEN; ++p)
476 <      if (*p != '[')
480 <        source_p->username[i++] = *p;
476 >      source_p->username[i++] = *p;
477  
478      source_p->username[i] = '\0';
479    }
# Line 485 | Line 481 | register_local_user(struct Client *sourc
481    /* Password check */
482    if (!EmptyString(conf->passwd))
483    {
484 <    const char *pass = source_p->localClient->passwd;
489 <
490 <    if (!match_conf_password(pass, conf))
484 >    if (!match_conf_password(source_p->localClient->passwd, conf))
485      {
486        ++ServerStats.is_ref;
487  
# Line 532 | Line 526 | register_local_user(struct Client *sourc
526  
527    if (!valid_username(source_p->username, 1))
528    {
529 <    char tmpstr2[IRCD_BUFSIZE] = "";
529 >    char buf[IRCD_BUFSIZE] = "";
530  
531      sendto_realops_flags(UMODE_REJ, L_ALL, SEND_NOTICE,
532                           "Invalid username: %s (%s@%s)",
533                           source_p->name, source_p->username, source_p->host);
534      ++ServerStats.is_ref;
535 <    snprintf(tmpstr2, sizeof(tmpstr2), "Invalid username [%s]",
536 <             source_p->username);
543 <    exit_client(source_p, tmpstr2);
535 >    snprintf(buf, sizeof(buf), "Invalid username [%s]", source_p->username);
536 >    exit_client(source_p, buf);
537      return;
538    }
539  
# Line 584 | Line 577 | register_local_user(struct Client *sourc
577    assert(source_p->servptr == &me);
578    SetClient(source_p);
579    dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->client_list);
580 <
588 <  source_p->localClient->allow_read = MAX_FLOOD_BURST;
580 >  dlinkAdd(source_p, &source_p->node, &global_client_list);
581  
582    assert(dlinkFind(&unknown_list, source_p));
583  
# Line 610 | Line 602 | register_local_user(struct Client *sourc
602   *                is introduced by a server.
603   */
604   void
605 < register_remote_user(struct Client *source_p, const char *username,
614 <                     const char *host, const char *server)
605 > register_remote_user(struct Client *source_p)
606   {
607    struct Client *target_p = NULL;
608  
618  assert(source_p->username != username);
619
620  strlcpy(source_p->host, host, sizeof(source_p->host));
621  strlcpy(source_p->username, username, sizeof(source_p->username));
622
623  /*
624   * Coming from another server, take the servers word for it
625   */
626  source_p->servptr = hash_find_server(server);
627
628  /*
629   * Super GhostDetect:
630   * If we can't find the server the user is supposed to be on,
631   * then simply blow the user away.        -Taner
632   */
633  if (source_p->servptr == NULL)
634  {
635    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
636                         "No server %s for user %s[%s@%s] from %s",
637                         server, source_p->name, source_p->username,
638                         source_p->host, source_p->from->name);
639    sendto_one(source_p->from,
640               ":%s KILL %s :%s (Ghosted, server %s doesn't exist)",
641               me.id, source_p->id, me.name, server);
642
643    AddFlag(source_p, FLAGS_KILLED);
644    exit_client(source_p, "Ghosted Client");
645    return;
646  }
647
609    if ((target_p = source_p->servptr) && target_p->from != source_p->from)
610    {
611      sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE,
# Line 674 | Line 635 | register_remote_user(struct Client *sour
635  
636    SetClient(source_p);
637    dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->client_list);
638 +  dlinkAdd(source_p, &source_p->node, &global_client_list);
639    add_user_host(source_p->username, source_p->host, 1);
640    SetUserHost(source_p);
641  
# Line 727 | Line 689 | valid_hostname(const char *hostname)
689   int
690   valid_username(const char *username, const int local)
691   {
692 <  int dots      = 0;
692 >  unsigned int dots = 0;
693    const char *p = username;
694  
695    assert(p);
# Line 747 | Line 709 | valid_username(const char *username, con
709    {
710      while (*++p)
711      {
712 <      if ((*p == '.') && ConfigFileEntry.dots_in_ident)
712 >      if (*p == '.' && ConfigFileEntry.dots_in_ident)
713        {
714          if (++dots > ConfigFileEntry.dots_in_ident)
715            return 0;
# Line 765 | Line 727 | valid_username(const char *username, con
727          return 0;
728    }
729  
730 <  return  p - username <= USERLEN;;
730 >  return p - username <= USERLEN;
731   }
732  
733   /* clean_nick_name()
# Line 808 | Line 770 | valid_nickname(const char *nickname, con
770   */
771   void
772   send_umode(struct Client *client_p, struct Client *source_p,
773 <           unsigned int old, unsigned int sendmask, char *umode_buf)
773 >           unsigned int old, char *umode_buf)
774   {
775    char *m = umode_buf;
776    int what = 0;
815  unsigned int i;
816  unsigned int flag;
777  
778    /*
779     * Build a string in umode_buf to represent the change in the user's
780     * mode between the new (source_p->umodes) and 'old'.
781     */
782 <  for (i = 0; i < 128; ++i)
782 >  for (unsigned int i = 0; i < 128; ++i)
783    {
784 <    flag = user_modes[i];
825 <    if (!flag)
826 <      continue;
784 >    unsigned int flag = user_modes[i];
785  
786 <    if (MyClient(source_p) && !(flag & sendmask))
786 >    if (!flag)
787        continue;
788  
789      if ((flag & old) && !HasUMode(source_p, flag))
# Line 872 | Line 830 | send_umode_out(struct Client *client_p,
830   {
831    char buf[IRCD_BUFSIZE] = "";
832  
833 <  send_umode(NULL, source_p, old, SEND_UMODES, buf);
833 >  send_umode(NULL, source_p, old, buf);
834  
835    if (buf[0])
836      sendto_server(source_p, NOCAPS, NOCAPS, ":%s MODE %s :%s",
837                    source_p->id, source_p->id, buf);
838  
839    if (client_p && MyClient(client_p))
840 <    send_umode(client_p, source_p, old, 0xffffffff, buf);
840 >    send_umode(client_p, source_p, old, buf);
841   }
842  
843   void
# Line 1009 | Line 967 | oper_up(struct Client *source_p)
967    sendto_one_numeric(source_p, &me, RPL_YOUREOPER);
968   }
969  
970 < static char new_uid[TOTALSIDUID + 1];     /* allow for \0 */
970 > static char new_uid[TOTALSIDUID + 1];  /* Allow for \0 */
971  
972   int
973   valid_sid(const char *sid)
# Line 1056 | Line 1014 | init_uid(void)
1014   *                note this is a recursive function
1015   */
1016   static void
1017 < add_one_to_uid(int i)
1017 > add_one_to_uid(unsigned int i)
1018   {
1019 <  if (i != IRC_MAXSID)    /* Not reached server SID portion yet? */
1019 >  if (i != IRC_MAXSID)  /* Not reached server SID portion yet? */
1020    {
1021      if (new_uid[i] == 'Z')
1022        new_uid[i] = '0';
1023      else if (new_uid[i] == '9')
1024      {
1025        new_uid[i] = 'A';
1026 <      add_one_to_uid(i-1);
1026 >      add_one_to_uid(i - 1);
1027      }
1028      else
1029        ++new_uid[i];
# Line 1090 | Line 1048 | add_one_to_uid(int i)
1048   static const char *
1049   uid_get(void)
1050   {
1051 <  add_one_to_uid(TOTALSIDUID - 1);    /* index from 0 */
1051 >  add_one_to_uid(TOTALSIDUID - 1);  /* Index from 0 */
1052    return new_uid;
1053   }
1054  
# Line 1105 | Line 1063 | void
1063   init_isupport(void)
1064   {
1065    add_isupport("CALLERID", NULL, -1);
1066 <  add_isupport("CASEMAPPING", CASEMAP, -1);
1066 >  add_isupport("CASEMAPPING", "rfc1459", -1);
1067    add_isupport("DEAF", "D", -1);
1068    add_isupport("KICKLEN", NULL, KICKLEN);
1069    add_isupport("MODES", NULL, MAXMODEPARAMS);
1112 #ifdef HALFOPS
1070    add_isupport("PREFIX", "(ohv)@%+", -1);
1071    add_isupport("STATUSMSG", "@%+", -1);
1115 #else
1116  add_isupport("PREFIX", "(ov)@+", -1);
1117  add_isupport("STATUSMSG", "@+", -1);
1118 #endif
1072    add_isupport("EXCEPTS", "e", -1);
1073    add_isupport("INVEX", "I", -1);
1074   }
# Line 1133 | Line 1086 | void
1086   add_isupport(const char *name, const char *options, int n)
1087   {
1088    dlink_node *ptr;
1089 <  struct Isupport *support;
1089 >  struct Isupport *support = NULL;
1090  
1091    DLINK_FOREACH(ptr, support_list.head)
1092    {
# Line 1148 | Line 1101 | add_isupport(const char *name, const cha
1101  
1102    if (ptr == NULL)
1103    {
1104 <    support = MyMalloc(sizeof(*support));
1104 >    support = MyCalloc(sizeof(*support));
1105      dlinkAddTail(support, &support->node, &support_list);
1106    }
1107  
1108    support->name = xstrdup(name);
1109 <  if (options != NULL)
1109 >  if (options)
1110      support->options = xstrdup(options);
1111    support->number = n;
1112  
# Line 1221 | Line 1174 | rebuild_isupport_message_line(void)
1174      p += (n = sprintf(p, "%s", support->name));
1175      len += n;
1176  
1177 <    if (support->options != NULL)
1177 >    if (support->options)
1178      {
1179        p += (n = sprintf(p, "=%s", support->options));
1180        len += n;
# Line 1249 | Line 1202 | rebuild_isupport_message_line(void)
1202      }
1203    }
1204  
1205 <  if (len != 0)
1205 >  if (len)
1206    {
1207      if (*--p == ' ')
1208        *p = '\0';

Diff Legend

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