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 2022 by michael, Sun May 12 18:07:07 2013 UTC vs.
Revision 2159 by michael, Sun Jun 2 18:22:01 2013 UTC

# Line 52 | Line 52
52   #include "parse.h"
53   #include "watch.h"
54  
55
55   static char umode_buffer[IRCD_BUFSIZE];
56  
57   static void user_welcome(struct Client *);
# Line 73 | Line 72 | struct Isupport
72    int number;
73   };
74  
75 < static dlink_list support_list = { NULL, NULL, 0 };
76 < MessageFile *isupportFile;
75 > static dlink_list support_list;
76 > static dlink_list support_list_lines;
77  
78   /* memory is cheap. map 0-255 to equivalent mode */
79   const unsigned int user_modes[256] =
# Line 135 | Line 134 | const unsigned int user_modes[256] =
134    UMODE_UNAUTH,       /* u */
135    0,                  /* v */
136    UMODE_WALLOP,       /* w */
137 <  0,                  /* x */
137 >  UMODE_HIDDENHOST,   /* x */
138    UMODE_SPY,          /* y */
139    UMODE_OPERWALL,     /* z      0x7A */
140    0,0,0,0,0,          /* 0x7B - 0x7F */
# Line 243 | Line 242 | show_lusers(struct Client *source_p)
242   void
243   show_isupport(struct Client *source_p)
244   {
245 <  send_message_file(source_p, isupportFile);
245 >  const dlink_node *ptr = NULL;
246 >
247 >  DLINK_FOREACH(ptr, support_list_lines.head)
248 >    sendto_one(source_p, form_str(RPL_ISUPPORT), me.name,
249 >               source_p->name, ptr->data);
250   }
251  
252   /*
# Line 390 | Line 393 | register_local_user(struct Client *sourc
393    }
394  
395    /* valid user name check */
396 <  if (valid_username(source_p->username) == 0)
396 >  if (valid_username(source_p->username, 1) == 0)
397    {
398      char tmpstr2[IRCD_BUFSIZE];
399  
# Line 674 | Line 677 | valid_hostname(const char *hostname)
677   * style of username
678   */
679   int
680 < valid_username(const char *username)
680 > valid_username(const char *username, const int local)
681   {
682    int dots      = 0;
683    const char *p = username;
# Line 684 | Line 687 | valid_username(const char *username)
687    if (*p == '~')
688      ++p;
689  
690 <  /* reject usernames that don't start with an alphanum
690 >  /*
691 >   * Reject usernames that don't start with an alphanum
692     * i.e. reject jokers who have '-@somehost' or '.@somehost'
693     * or "-hi-@somehost", "h-----@somehost" would still be accepted.
694     */
695    if (!IsAlNum(*p))
696      return 0;
697  
698 <  while (*++p)
698 >  if (local)
699    {
700 <    if ((*p == '.') && ConfigFileEntry.dots_in_ident)
700 >    while (*++p)
701      {
702 <      if (++dots > ConfigFileEntry.dots_in_ident)
703 <        return 0;
704 <      if (!IsUserChar(*(p + 1)))
702 >      if ((*p == '.') && ConfigFileEntry.dots_in_ident)
703 >      {
704 >        if (++dots > ConfigFileEntry.dots_in_ident)
705 >          return 0;
706 >        if (!IsUserChar(*(p + 1)))
707 >          return 0;
708 >      }
709 >      else if (!IsUserChar(*p))
710          return 0;
711      }
712 <    else if (!IsUserChar(*p))
713 <      return 0;
712 >  }
713 >  else
714 >  {
715 >    while (*++p)
716 >      if (!IsUserChar(*p))
717 >        return 0;
718    }
719  
720 <  return 1;
720 >  return  p - username <= USERLEN;;
721   }
722  
723   /* clean_nick_name()
# Line 745 | Line 758 | report_and_set_user_flags(struct Client
758   {
759    /* If this user is being spoofed, tell them so */
760    if (IsConfDoSpoofIp(conf))
748  {
761      sendto_one(source_p,
762 <               ":%s NOTICE %s :*** Spoofing your IP. congrats.",
762 >               ":%s NOTICE %s :*** Spoofing your IP. Congrats.",
763                 me.name, source_p->name);
752  }
764  
765    /* If this user is in the exception class, Set it "E lined" */
766    if (IsConfExemptKline(conf))
767    {
768      SetExemptKline(source_p);
769      sendto_one(source_p,
770 <               ":%s NOTICE %s :*** You are exempt from K/D/G lines. congrats.",
770 >               ":%s NOTICE %s :*** You are exempt from K/D/G lines. Congrats.",
771                 me.name, source_p->name);
772    }
773  
# Line 766 | Line 777 | report_and_set_user_flags(struct Client
777    else if (IsConfExemptGline(conf))
778    {
779      SetExemptGline(source_p);
780 <    sendto_one(source_p, ":%s NOTICE %s :*** You are exempt from G lines.",
780 >    sendto_one(source_p, ":%s NOTICE %s :*** You are exempt from G lines. Congrats.",
781                 me.name, source_p->name);
782    }
783  
784    if (IsConfExemptResv(conf))
785    {
786      SetExemptResv(source_p);
787 <    sendto_one(source_p, ":%s NOTICE %s :*** You are exempt from resvs.",
787 >    sendto_one(source_p, ":%s NOTICE %s :*** You are exempt from resvs. Congrats.",
788                 me.name, source_p->name);
789    }
790  
# Line 782 | Line 793 | report_and_set_user_flags(struct Client
793    {
794      SetExemptLimits(source_p);
795      sendto_one(source_p,
796 <               ":%s NOTICE %s :*** You are exempt from user limits. congrats.",
796 >               ":%s NOTICE %s :*** You are exempt from user limits. Congrats.",
797                 me.name,source_p->name);
798    }
799  
# Line 894 | Line 905 | set_user_mode(struct Client *client_p, s
905  
906            break;
907  
908 <        /*
909 <         * We may not get these, but they shouldnt be in default
899 <         */
900 <        case 'r':
901 <        case ' ' :
902 <        case '\n':
903 <        case '\r':
904 <        case '\t':
908 >        case 'r':  /* Only services may set +r */
909 >        case 'x':  /* Only services may set +x */
910            break;
911  
912          default:
# Line 1051 | Line 1056 | send_umode_out(struct Client *client_p,
1056   }
1057  
1058   void
1059 < user_set_hostmask(struct Client *target_p, const char *hostname)
1059 > user_set_hostmask(struct Client *target_p, const char *hostname, const int what)
1060   {
1061 <  if (!valid_hostname(hostname))
1061 >  dlink_node *ptr = NULL;
1062 >
1063 >  if (!strcmp(target_p->host, hostname))
1064      return;
1065  
1066 +  switch (what)
1067 +  {
1068 +    case MODE_ADD:
1069 +      AddUMode(target_p, UMODE_HIDDENHOST);
1070 +      AddFlag(target_p, FLAGS_IP_SPOOFING);
1071 +      break;
1072 +    case MODE_DEL:
1073 +      DelUMode(target_p, UMODE_HIDDENHOST);
1074 +
1075 +      if (!HasFlag(target_p, FLAGS_AUTH_SPOOF))
1076 +        DelFlag(target_p, FLAGS_IP_SPOOFING);
1077 +      break;
1078 +    default: return;
1079 +  }
1080 +
1081 +  sendto_common_channels_local(target_p, 0, 0, ":%s!%s@%s QUIT :Changing hostname",
1082 +                               target_p->name, target_p->username, target_p->host);
1083 +
1084    if (IsUserHostIp(target_p))
1085      delete_user_host(target_p->username, target_p->host, !MyConnect(target_p));
1086  
1087    strlcpy(target_p->host, hostname, sizeof(target_p->host));
1063  SetIPSpoof(target_p);
1088  
1089    add_user_host(target_p->username, target_p->host, !MyConnect(target_p));
1090    SetUserHost(target_p);
1091  
1092    if (MyClient(target_p))
1093 +  {
1094 +    sendto_one(target_p, form_str(RPL_NEWHOSTIS), me.name,
1095 +               target_p->name, target_p->host);
1096      clear_ban_cache_client(target_p);
1097 +  }
1098 +
1099 +  DLINK_FOREACH(ptr, target_p->channel.head)
1100 +  {
1101 +    char modebuf[4], nickbuf[NICKLEN * 3 + 3] = { '\0' };
1102 +    char *p = modebuf;
1103 +    int len = 0;
1104 +    const struct Membership *ms = ptr->data;
1105 +
1106 +    if (has_member_flags(ms, CHFL_CHANOP)) {
1107 +      *p++ = 'o';
1108 +      len += snprintf(nickbuf + len, sizeof(nickbuf) - len, len ? " %s" : "%s", target_p->name);
1109 +    }
1110 +
1111 +    if (has_member_flags(ms, CHFL_HALFOP)) {
1112 +      *p++ = 'h';
1113 +      len += snprintf(nickbuf + len, sizeof(nickbuf) - len, len ? " %s" : "%s", target_p->name);
1114 +    }
1115 +
1116 +    if (has_member_flags(ms, CHFL_VOICE)) {
1117 +      *p++ = 'v';
1118 +      len += snprintf(nickbuf + len, sizeof(nickbuf) - len, len ? " %s" : "%s", target_p->name);
1119 +    }
1120 +
1121 +    *p = '\0';
1122 +
1123 +    sendto_channel_local_butone(target_p, 0, 0, ms->chptr, ":%s!%s@%s JOIN :%s",
1124 +                                target_p->name, target_p->username, target_p->host,
1125 +                                ms->chptr->chname);
1126 +    if (nickbuf[0])
1127 +      sendto_channel_local_butone(target_p, 0, 0, ms->chptr, ":%s MODE %s +%s %s",
1128 +                                  target_p->servptr->name, ms->chptr->chname,
1129 +                                  modebuf, nickbuf);
1130 +
1131 +  }
1132 +
1133 +  if (target_p->away[0])
1134 +    sendto_common_channels_local(target_p, 0, CAP_AWAY_NOTIFY,
1135 +                                 ":%s!%s@%s AWAY :%s",
1136 +                                 target_p->name, target_p->username,
1137 +                                 target_p->host, target_p->away);
1138   }
1139  
1140   /* user_welcome()
# Line 1092 | Line 1160 | user_welcome(struct Client *source_p)
1160   #endif
1161  
1162    sendto_one(source_p, form_str(RPL_WELCOME), me.name, source_p->name,
1163 <             ServerInfo.network_name, source_p->name,
1096 <             source_p->username, source_p->host);
1163 >             ServerInfo.network_name, source_p->name);
1164    sendto_one(source_p, form_str(RPL_YOURHOST), me.name, source_p->name,
1165               get_listener_name(source_p->localClient->listener), ircd_version);
1166    sendto_one(source_p, form_str(RPL_CREATED),
# Line 1107 | Line 1174 | user_welcome(struct Client *source_p)
1174                 source_p->name, source_p->id);
1175  
1176    show_lusers(source_p);
1177 <
1111 <  if (ConfigFileEntry.short_motd)
1112 <  {
1113 <    sendto_one(source_p, ":%s NOTICE %s :*** Notice -- motd was last changed at %s",
1114 <               me.name, source_p->name, ConfigFileEntry.motd.lastChangedDate);
1115 <    sendto_one(source_p,
1116 <               ":%s NOTICE %s :*** Notice -- Please read the motd if you haven't "
1117 <               "read it", me.name, source_p->name);
1118 <    sendto_one(source_p, form_str(RPL_MOTDSTART),
1119 <               me.name, source_p->name, me.name);
1120 <    sendto_one(source_p, form_str(RPL_MOTD),
1121 <               me.name, source_p->name,
1122 <               "*** This is the short motd ***");
1123 <    sendto_one(source_p, form_str(RPL_ENDOFMOTD),
1124 <               me.name, source_p->name);
1125 <  }
1126 <  else  
1127 <    send_message_file(source_p, &ConfigFileEntry.motd);
1177 >  motd_signon(source_p);
1178   }
1179  
1180   /* check_xline()
# Line 1306 | Line 1356 | uid_get(void)
1356   void
1357   init_isupport(void)
1358   {
1309  isupportFile = init_MessageLine();
1310
1359    add_isupport("CALLERID", NULL, -1);
1360    add_isupport("CASEMAPPING", CASEMAP, -1);
1361    add_isupport("DEAF", "D", -1);
# Line 1403 | Line 1451 | rebuild_isupport_message_line(void)
1451   {
1452    char isupportbuffer[IRCD_BUFSIZE];
1453    char *p = isupportbuffer;
1454 <  dlink_node *ptr = NULL;
1454 >  dlink_node *ptr = NULL, *ptr_next = NULL;
1455    int n = 0;
1456    int tokens = 0;
1457    size_t len = 0;
1458    size_t reserve = strlen(me.name) + HOSTLEN + strlen(form_str(RPL_ISUPPORT));
1459  
1460 <  destroy_MessageLine(isupportFile);
1460 >  DLINK_FOREACH_SAFE(ptr, ptr_next, support_list_lines.head)
1461 >  {
1462 >    dlinkDelete(ptr, &support_list_lines);
1463 >    MyFree(ptr->data);
1464 >    free_dlink_node(ptr);
1465 >  }
1466  
1467    DLINK_FOREACH(ptr, support_list.head)
1468    {
# Line 1439 | Line 1492 | rebuild_isupport_message_line(void)
1492        if (*--p == ' ')
1493          *p = '\0';
1494  
1495 <      addto_MessageLine(isupportFile, isupportbuffer);
1495 >      dlinkAddTail(xstrdup(isupportbuffer), make_dlink_node(), &support_list_lines);
1496        p = isupportbuffer;
1497        len = 0;
1498        n = tokens = 0;
# Line 1450 | Line 1503 | rebuild_isupport_message_line(void)
1503    {
1504      if (*--p == ' ')
1505        *p = '\0';
1506 <    addto_MessageLine(isupportFile, isupportbuffer);
1506 >    dlinkAddTail(xstrdup(isupportbuffer), make_dlink_node(), &support_list_lines);
1507    }
1508   }

Diff Legend

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