00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "services.h"
00016
00017
00018
00025 void bad_password(User * u)
00026 {
00027 time_t now = time(NULL);
00028
00029 if (!u || !BadPassLimit) {
00030 return;
00031 }
00032
00033 if (BadPassTimeout > 0 && u->invalid_pw_time > 0
00034 && u->invalid_pw_time < now - BadPassTimeout)
00035 u->invalid_pw_count = 0;
00036 u->invalid_pw_count++;
00037 u->invalid_pw_time = now;
00038 if (u->invalid_pw_count >= BadPassLimit) {
00039 kill_user(NULL, u->nick, "Too many invalid passwords");
00040 }
00041 }
00042
00043
00044
00052 void kill_user(char *source, char *user, char *reason)
00053 {
00054 char buf[BUFSIZE];
00055
00056 if (!user || !*user) {
00057 return;
00058 }
00059 if (!source || !*source) {
00060 source = ServerName;
00061 }
00062 if (!reason) {
00063 reason = "";
00064 }
00065
00066 snprintf(buf, sizeof(buf), "%s (%s)", source, reason);
00067
00068 anope_cmd_svskill(source, user, buf);
00069
00070 if (!ircd->quitonkill && finduser(user)) {
00071 do_kill(user, buf);
00072 }
00073 }
00074
00075
00076
00083 void sqline(char *mask, char *reason)
00084 {
00085 int i;
00086 Channel *c, *next;
00087 char *av[3];
00088 struct c_userlist *cu, *cunext;
00089
00090 if (ircd->chansqline) {
00091 if (*mask == '#') {
00092 anope_cmd_sqline(mask, reason);
00093
00094 for (i = 0; i < 1024; i++) {
00095 for (c = chanlist[i]; c; c = next) {
00096 next = c->next;
00097
00098 if (!match_wild_nocase(mask, c->name)) {
00099 continue;
00100 }
00101 for (cu = c->users; cu; cu = cunext) {
00102 cunext = cu->next;
00103 if (is_oper(cu->user)) {
00104 continue;
00105 }
00106 av[0] = c->name;
00107 av[1] = cu->user->nick;
00108 av[2] = reason;
00109 anope_cmd_kick(s_OperServ, av[0], av[1],
00110 "Q-Lined: %s", av[2]);
00111 do_kick(s_ChanServ, 3, av);
00112 }
00113 }
00114 }
00115 } else {
00116 anope_cmd_sqline(mask, reason);
00117 }
00118 } else {
00119 anope_cmd_sqline(mask, reason);
00120 }
00121 }
00122
00123
00124
00131 void common_unban(ChannelInfo * ci, char *nick)
00132 {
00133 int count, i;
00134 char *av[3], **bans;
00135 User *u;
00136 char *host = NULL;
00137 int matchfound = 0;
00138
00139 if (!ci || !ci->c || !nick) {
00140 return;
00141 }
00142
00143 if (!(u = finduser(nick))) {
00144 return;
00145 }
00146
00147 if (u->hostip == NULL) {
00148 host = host_resolve(u->host);
00149
00150
00151 if (host) {
00152 u->hostip = sstrdup(host);
00153 }
00154 } else {
00155 host = sstrdup(u->hostip);
00156 }
00157
00158 if (ircd->svsmode_unban) {
00159 anope_cmd_unban(ci->name, nick);
00160 } else {
00161 av[0] = ci->name;
00162 av[1] = sstrdup("-b");
00163 count = ci->c->bancount;
00164 bans = scalloc(sizeof(char *) * count, 1);
00165 memcpy(bans, ci->c->bans, sizeof(char *) * count);
00166 for (i = 0; i < count; i++) {
00167 if (match_usermask(bans[i], u)) {
00168 anope_cmd_mode(whosends(ci), ci->name, "-b %s", bans[i]);
00169 av[2] = bans[i];
00170 do_cmode(whosends(ci), 3, av);
00171 matchfound++;
00172 }
00173 if (host) {
00174
00175
00176
00177
00178
00179
00180
00181 if (!matchfound) {
00182 if (match_userip(bans[i], u, host)) {
00183 anope_cmd_mode(whosends(ci), ci->name, "-b %s",
00184 bans[i]);
00185 av[2] = bans[i];
00186 do_cmode(whosends(ci), 3, av);
00187 }
00188 }
00189 }
00190 matchfound = 0;
00191 }
00192 free(bans);
00193 free(av[1]);
00194 }
00195
00196 if (host) {
00197 free(host);
00198 }
00199 }
00200
00201
00202
00210 void common_svsmode(User * u, char *modes, char *arg)
00211 {
00212 int ac = 1;
00213 char *av[2];
00214
00215 av[0] = modes;
00216 if (arg) {
00217 av[1] = arg;
00218 ac++;
00219 }
00220
00221 anope_cmd_svsmode(u, ac, av);
00222 anope_set_umode(u, ac, av);
00223 }
00224
00225
00226
00233 char *common_get_vhost(User * u)
00234 {
00235 if (!u)
00236 return NULL;
00237
00238 if (ircd->vhostmode && (u->mode & ircd->vhostmode))
00239 return u->vhost;
00240 else if (ircd->vhost && u->vhost)
00241 return u->vhost;
00242 else
00243 return u->host;
00244 }
00245
00246
00247
00254 char *common_get_vident(User * u)
00255 {
00256 if (!u)
00257 return NULL;
00258
00259 if (ircd->vhostmode && (u->mode & ircd->vhostmode))
00260 return u->vident;
00261 else if (ircd->vident && u->vident)
00262 return u->vident;
00263 else
00264 return u->username;
00265 }