/** * The /ns logout command. * @param u The user who issued the command * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing. **/ int do_logout(User * u) { char *nick = strtok(NULL, " "); char *param = strtok(NULL, " "); User *u2; if (!is_services_admin(u) && nick) { syntax_error(s_NickServ, u, "LOGOUT", NICK_LOGOUT_SYNTAX); } else if (!(u2 = (nick ? finduser(nick) : u))) { notice_lang(s_NickServ, u, NICK_X_NOT_IN_USE, nick); } else if (!u2->na) { if (nick) notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick); else notice_lang(s_NickServ, u, NICK_NOT_REGISTERED); } else if (u2->na->status & NS_VERBOTEN) { notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, u2->na->nick); } else if (!nick && !nick_identified(u)) { notice_lang(s_NickServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); } else if (nick && is_services_admin(u2)) { notice_lang(s_NickServ, u, NICK_LOGOUT_SERVICESADMIN, nick); } else { if (nick && param && !stricmp(param, "REVALIDATE")) { cancel_user(u2); validate_user(u2); } else { u2->na->status &= ~(NS_IDENTIFIED | NS_RECOGNIZED); } if (ircd->modeonreg) { common_svsmode(u2, ircd->modeonunreg, "1"); } u->isSuperAdmin = 0; /* Dont let people logout and remain a SuperAdmin */ alog("%s: %s!%s@%s logged out nickname %s", s_NickServ, u->nick, u->username, u->host, u2->nick); if (nick) notice_lang(s_NickServ, u, NICK_LOGOUT_X_SUCCEEDED, nick); else notice_lang(s_NickServ, u, NICK_LOGOUT_SUCCEEDED); /* Stop nick tracking if enabled */ if (NSNickTracking) /* Shouldn't this be u2? -GD */ nsStopNickTracking(u); /* Clear any timers again */ if (u->na->nc->flags & NI_KILLPROTECT) { del_ns_timeout(u->na, TO_COLLIDE); } /* Send out an event */ send_event(EVENT_NICK_LOGOUT, 1, u2->nick); } return MOD_CONT; }
static int do_qakill_some_lameass(User * u) { char *to_be_akilled, *reason; char reasonx[512]; char mask[USERMAX + HOSTMAX + 2]; User *target; to_be_akilled = strtok(NULL, " "); reason = strtok(NULL, ""); if (!is_services_admin(u)) { notice(s_OperServ, u->nick, "Access Denied"); return MOD_STOP; } if (to_be_akilled) { if (!reason) { reason = "You have been AKILLED"; } if (AddAkiller) { snprintf(reasonx, sizeof(reasonx), "[%s] %s", u->nick, reason); } if ((target = finduser(to_be_akilled))) { sprintf(mask, "*@%s", target->host); #ifdef DISABLE_LOWER_QAKILL if ((is_services_admin(target)) && (!is_services_root(u))) { notice(s_OperServ, u->nick, "Permission Denied"); #ifndef ANOPE17x wallops(s_OperServ, "%s attempted to QAKILL %s (%s)", u->nick, target->nick, reasonx); #else anope_cmd_global(s_OperServ, "%s attempted to QAKILL %s (%s)", u->nick, target->nick, reasonx); #endif return MOD_STOP; } #endif add_akill(u, mask, u->nick, time(NULL)+AutokillExpiry, reason); if (WallOSAkill) { #ifndef ANOPE17x wallops(s_OperServ, "%s used QAKILL on %s (%s)", u->nick, target->nick, reasonx); #else anope_cmd_global(s_OperServ, "%s used QAKILL on %s (%s)", u->nick, target->nick, reasonx); #endif } if (!AkillOnAdd) { kill_user(s_OperServ, target->nick, reasonx); } } else { notice_lang(s_OperServ, u, NICK_X_NOT_IN_USE, to_be_akilled); } } else { notice(s_OperServ, u->nick, "See /msg OperServ HELP QAKILL for more info."); } return MOD_CONT; }
int do_mynicks(User * u) { char *nick = strtok(NULL, " "); NickAlias *na, *na2; int is_servadmin = is_services_admin(u); int nick_ided = nick_identified(u); int i; if ((nick ? (stricmp(nick, u->nick) ? !is_servadmin : !nick_ided) : !nick_ided)) { notice_lang(s_NickServ, u, (nick_ided ? ACCESS_DENIED : NICK_IDENTIFY_REQUIRED), s_NickServ); } else if ((!nick ? !(na = u->na) : !(na = findnick(nick)))) { notice_lang(s_NickServ, u, (!nick ? NICK_NOT_REGISTERED : NICK_X_NOT_REGISTERED), nick); } else if (na->status & NS_VERBOTEN) { notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick); } else { time_t expt; struct tm *tm; char buf[BUFSIZE]; int wont_expire; notice_lang(s_NickServ, u, nick ? NS_MYNICKS_HEADER_X : NS_MYNICKS_HEADER, na->nc->display); for (i = 0; i < na->nc->aliases.count; i++) { na2 = na->nc->aliases.list[i]; if (na2->nc == na->nc) { if (!(wont_expire = na2->status & NS_NO_EXPIRE)) { expt = na2->last_seen + NSExpire; tm = localtime(&expt); strftime_lang(buf, sizeof(buf), na2->u, STRFTIME_DATE_TIME_FORMAT, tm); } notice_lang(s_NickServ, u, ((is_services_admin(u) && !wont_expire) ? NS_MYNICKS_REPLY_ADMIN : NS_MYNICKS_REPLY), (wont_expire ? '!' : ' '), na2->nick, buf); } } notice_lang(s_NickServ, u, NS_MYNICKS_FOOTER, na->nc->aliases.count); } return MOD_CONT; }
void SGR_Module_Help_OPERSERV_QAKILL(User *u) { if (is_services_admin(u)) { notice(s_OperServ, u->nick, " QAKILL AKILL a user by nick."); } return; }
int set_topic(User * u, Channel *c, char *topic) { ChannelInfo *ci = c->ci; if (!my_check_access(u, ci, CA_TOPIC) && ((ci->flags & CI_TOPICLOCK) || !my_check_access(u, ci, CA_OPDEOPME))) notice_lang(ci->bi->nick, u, PERMISSION_DENIED); else { if (ci->last_topic) free(ci->last_topic); ci->last_topic = topic ? sstrdup(topic) : NULL; strscpy(ci->last_topic_setter, u->nick, NICKMAX); ci->last_topic_time = time(NULL); if (c->topic) free(c->topic); c->topic = topic ? sstrdup(topic) : NULL; strscpy(c->topic_setter, u->nick, NICKMAX); if (ircd->topictsbackward) { c->topic_time = c->topic_time - 1; } else { c->topic_time = ci->last_topic_time; } if (is_services_admin(u) && !check_access(u, ci, CA_TOPIC) && ((ci->flags & CI_TOPICLOCK) || !check_access(u, ci, CA_OPDEOPME))) alog("%s: %s!%s@%s changed topic of %s as services admin.", ci->bi->nick, u->nick, u->username, u->host, c->name); anope_cmd_topic(ci->bi->nick, c->name, u->nick, topic ? topic : "", c->topic_time); } return MOD_CONT; }
/** * The /os mode command. * @param u The user who issued the command * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing. **/ static int do_os_mode(User * u) { int ac; char **av; char *chan = strtok(NULL, " "), *modes = strtok(NULL, ""); Channel *c; if (!chan || !modes) { syntax_error(s_OperServ, u, "MODE", OPER_MODE_SYNTAX); return MOD_CONT; } if (!(c = findchan(chan))) { notice_lang(s_OperServ, u, CHAN_X_NOT_IN_USE, chan); } else if (c->bouncy_modes) { notice_lang(s_OperServ, u, OPER_BOUNCY_MODES_U_LINE); return MOD_CONT; } else if ((ircd->adminmode) && (!is_services_admin(u)) && (c->mode & ircd->adminmode)) { notice_lang(s_OperServ, u, PERMISSION_DENIED); return MOD_CONT; } else { anope_cmd_mode(s_OperServ, chan, "%s", modes); ac = split_buf(modes, &av, 1); chan_set_modes(s_OperServ, c, ac, av, -1); free(av); if (WallOSMode) anope_cmd_global(s_OperServ, "%s used MODE %s on %s", u->nick, modes, chan); } return MOD_CONT; }
/** * The /ns help command. * @param u The user who issued the command * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing. **/ int do_help(User * u) { char *cmd = strtok(NULL, ""); if (!cmd) { notice_help(s_NickServ, u, NICK_HELP); moduleDisplayHelp(1, u); if (is_services_admin(u)) { notice_help(s_NickServ, u, NICK_SERVADMIN_HELP); } if (NSExpire >= 86400) notice_help(s_NickServ, u, NICK_HELP_EXPIRES, NSExpire / 86400); notice_help(s_NickServ, u, NICK_HELP_FOOTER); } else if (stricmp(cmd, "SET LANGUAGE") == 0) { int i; notice_help(s_NickServ, u, NICK_HELP_SET_LANGUAGE); for (i = 0; i < NUM_LANGS && langlist[i] >= 0; i++) notice_user(s_NickServ, u, " %2d) %s", i + 1, langnames[langlist[i]]); } else { mod_help_cmd(s_NickServ, u, NICKSERV, cmd); } return MOD_CONT; }
int topic_replace_prepend(User * u, Channel *c, char *newtopic) { char topic[1024], buf[1024], *mtopic; ChannelInfo *ci = c->ci; if (ci->flags & CI_VERBOTEN) { notice_lang(ci->bi->nick, u, CHAN_X_FORBIDDEN, ci->name); return MOD_STOP; } if (!my_check_access(u, ci, CA_TOPIC) && ((ci->flags & CI_TOPICLOCK) || !my_check_access(u, ci, CA_OPDEOPME))) { notice_lang(ci->bi->nick, u, PERMISSION_DENIED); return MOD_STOP; } memset(topic, 0, 1024); if (ci->last_topic) { /* Copy topic starting after the first delimiter.. */ mtopic = strstr(ci->last_topic, (AppendToTopicDel ? AppendToTopicDel : "||")); if (mtopic) { memset(buf, 0, 1024); strcat(buf, mtopic + strlen((AppendToTopicDel ? AppendToTopicDel : "||"))); if (newtopic) snprintf(topic, sizeof(topic), "%s %s%s", newtopic, (AppendToTopicDel ? AppendToTopicDel : "||"), buf); else snprintf(topic, sizeof(topic), "%s", buf); } else snprintf(topic, sizeof(topic), "%s %s %s", newtopic, (AppendToTopicDel ? AppendToTopicDel : "||"), ci->last_topic); } else if (newtopic) strcpy(topic, newtopic); ci->last_topic = *topic ? sstrdup(topic) : NULL; strscpy(ci->last_topic_setter, u->nick, NICKMAX); ci->last_topic_time = time(NULL); if (c->topic) free(c->topic); c->topic = *topic ? sstrdup(topic) : NULL; strscpy(c->topic_setter, u->nick, NICKMAX); if (ircd->topictsbackward) { c->topic_time = c->topic_time - 1; } else { c->topic_time = ci->last_topic_time; } if (is_services_admin(u) && !check_access(u, ci, CA_TOPIC) && ((ci->flags & CI_TOPICLOCK) || !check_access(u, ci, CA_OPDEOPME))) alog("%s: %s!%s@%s changed topic of %s as services admin.", ci->bi->nick, u->nick, u->username, u->host, c->name); anope_cmd_topic(ci->bi->nick, c->name, u->nick, topic, c->topic_time); return MOD_CONT; }
int append_to_topic(User * u, Channel *c, char *newtopic) { char topic[1024]; ChannelInfo *ci = c->ci; if (!newtopic) { noticeLang(ci->bi->nick, u, LANG_APPENDT_SYNTAX); return MOD_STOP; } if (ci->flags & CI_VERBOTEN) { notice_lang(ci->bi->nick, u, CHAN_X_FORBIDDEN, ci->name); return MOD_STOP; } if (!my_check_access(u, ci, CA_TOPIC) && ((ci->flags & CI_TOPICLOCK) || !my_check_access(u, ci, CA_OPDEOPME))) { notice_lang(ci->bi->nick, u, PERMISSION_DENIED); return MOD_STOP; } if (ci->last_topic) { snprintf(topic, sizeof(topic), "%s %s %s", ci->last_topic, (AppendToTopicDel ? AppendToTopicDel : "||"), newtopic); free(ci->last_topic); } else strcpy(topic, newtopic); ci->last_topic = *topic ? sstrdup(topic) : NULL; strscpy(ci->last_topic_setter, u->nick, NICKMAX); ci->last_topic_time = time(NULL); if (c->topic) free(c->topic); c->topic = *topic ? sstrdup(topic) : NULL; strscpy(c->topic_setter, u->nick, NICKMAX); if (ircd->topictsbackward) { c->topic_time = c->topic_time - 1; } else { c->topic_time = ci->last_topic_time; } if (is_services_admin(u) && !check_access(u, ci, CA_TOPIC) && ((ci->flags & CI_TOPICLOCK) || !check_access(u, ci, CA_OPDEOPME))) alog("%s: %s!%s@%s changed topic of %s as services admin.", ci->bi->nick, u->nick, u->username, u->host, c->name); anope_cmd_topic(ci->bi->nick, c->name, u->nick, topic, c->topic_time); return MOD_CONT; }
static int access_del(User * u, ChannelInfo *ci, ChanAccess * access, int *perm, int uacc) { char *nick; if (!access->in_use) return 0; if (!is_services_admin(u) && uacc <= access->level) { (*perm)++; return 0; } nick = access->nc->display; access->nc = NULL; access->in_use = 0; send_event(EVENT_ACCESS_DEL, 3, ci->name, u->nick, nick); return 1; }
static int my_cs_enforce(User * u) { char *cur_buffer; char *chan=NULL; char *what=NULL; Channel *c; ChannelInfo *ci; cur_buffer = moduleGetLastBuffer(); chan = myStrGetToken(cur_buffer, ' ', 0); if (!chan) { moduleNoticeLang(s_ChanServ, u, LNG_ENFORCE_SYNTAX); } else if (!(c = findchan(chan))) { notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan); } else if (!(ci = c->ci)) { notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); } else if (ci->flags & CI_VERBOTEN) { notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, ci->name); } else if (!is_services_admin(u) && !check_access(u, ci, CA_AKICK)) { notice_lang(s_ChanServ, u, PERMISSION_DENIED); } else { what = myStrGetToken(cur_buffer, ' ', 1); if (!what || (stricmp(what, "SET") == 0)) { do_enforce_set(c); moduleNoticeLang(s_ChanServ,u,LNG_CHAN_RESPONSE, what ? what : "SET"); } else if (stricmp(what, "MODES") == 0) { do_enforce_modes(c); moduleNoticeLang(s_ChanServ,u,LNG_CHAN_RESPONSE,what); } else if (stricmp(what, "SECUREOPS") == 0) { do_enforce_secureops(c); moduleNoticeLang(s_ChanServ,u,LNG_CHAN_RESPONSE,what); } else if (stricmp(what, "RESTRICTED") == 0) { do_enforce_restricted(c); moduleNoticeLang(s_ChanServ,u,LNG_CHAN_RESPONSE,what); } else if (stricmp(what, "+R") == 0) { do_enforce_cmode_R(c); moduleNoticeLang(s_ChanServ,u,LNG_CHAN_RESPONSE,what); } else { moduleNoticeLang(s_ChanServ, u, LNG_ENFORCE_SYNTAX); } } if(chan) free(chan); if(what) free(what); return MOD_CONT; }
int check_email_limit_reached(char *email, User * u) { if ((NSEmailMax < 1) || !email || is_services_admin(u)) return MOD_CONT; if (count_email_in_use(email, u) < NSEmailMax) return MOD_CONT; if (NSEmailMax == 1) moduleNoticeLang(s_NickServ, u, LNG_NSEMAILMAX_REACHED_ONE); else moduleNoticeLang(s_NickServ, u, LNG_NSEMAILMAX_REACHED, NSEmailMax); return MOD_STOP; }
int list_global_opers(Channel *c, User *u) { int j, i , carryon, count = 0; User *u2; char *access; noticeLang(c->ci->bi->nick, u, LANG_GOLIST_HEADER); for (j = 0; j < 1024; j++) { for (u2 = userlist[j]; u2; u2 = u2->next) { carryon = 0; /* Prevent listing of users with +H */ if (finduser((u2->nick)) && !has_umode_H(u2) && !has_umode_B(u2) && !is_ulined(u2->server->name)) { i = 0; while (i < excempt_nr) { if (!ListExempts[i] || !u2->nick) break; if (my_match_wild_nocase(ListExempts[i], u2->nick)) { carryon = 1; break; } i++; } if (carryon) continue; if (is_oper(u2)) { count++; access = getLangString(u->na, LANG_GOLIST_OPER_ONLY); if (is_services_oper(u2)) access = getLangString(u->na, LANG_GOLIST_OPER_AND_SO); if (is_services_admin(u2)) access = getLangString(u->na, LANG_GOLIST_OPER_AND_SA); if (is_services_root(u2)) access = getLangString(u->na, LANG_GOLIST_OPER_AND_SRA); notice(c->ci->bi->nick, u->nick, "%-15s - %s", u2->nick, access); } } } } if (count == 0) noticeLang(c->ci->bi->nick, u, LANG_GOLIST_NONE); noticeLang(c->ci->bi->nick, u, LANG_GOLIST_FOOTER, count); return MOD_CONT; }
int list_admins(Channel *c, User *u) { int j, i , carryon, count = 0; User *u2; noticeLang(c->ci->bi->nick, u, LANG_ADLIST_HEADER); for (j = 0; j < 1024; j++) { for (u2 = userlist[j]; u2; u2 = u2->next) { carryon = 0; /* Prevent listing of users with +H */ if (finduser((u2->nick)) && !has_umode_H(u2) && !has_umode_B(u2) && !is_ulined(u2->server->name)) { i = 0; while (i < excempt_nr) { if (!ListExempts[i] || !u2->nick) break; if (!stricmp(u2->nick, ListExempts[i])) carryon = 1; i++; } if (carryon) continue; if (is_oper(u2)) { if (is_services_root(u2)) { count++; notice(c->ci->bi->nick, u->nick, "%-15s - %s", u2->nick, getLangString(u->na, LANG_ADLIST_SRA)); continue; } if (is_services_admin(u2)) { count++; notice(c->ci->bi->nick, u->nick, "%-15s - %s", u2->nick, getLangString(u->na, LANG_ADLIST_SA)); } } } } } if (count == 0) noticeLang(c->ci->bi->nick, u, LANG_ADLIST_NONE); noticeLang(c->ci->bi->nick, u, LANG_ADLIST_FOOTER, count); return MOD_CONT; }
int SGR_Module_Help_OPERSERV_QAKILL_FULL(User *u) { if (is_services_admin(u)) { notice(s_OperServ, u->nick, "-----------------------------------------------------------------------"); notice(s_OperServ, u->nick, " Syntax: QAKILL Nick [Reason]"); notice(s_OperServ, u->nick, " "); notice(s_OperServ, u->nick, " Allows Services Admins to add an akill with just a nick. A reason"); notice(s_OperServ, u->nick, " is not mandatory, however it is often useful for you put a valid one."); notice(s_OperServ, u->nick, " The akill placed will be in the form *@full.host.mask for the default"); notice(s_OperServ, u->nick, " AKILL expiry time."); #ifdef DISABLE_LOWER_QAKILL notice(s_OperServ, u->nick, " You will not be able to QAKILL identifed services admins or services"); notice(s_OperServ, u->nick, " roots unless you are a services root."); #endif notice(s_OperServ, u->nick, "-----------------------------------------------------------------------"); return MOD_CONT; } return MOD_CONT; }
int is_services_oper(User * u) { unsigned int fields, rows; MYSQL_RES *result; if (!(u->mode & UMODE_o)) return(0); if (!nick_identified(u)) return(0); if (is_services_admin(u)) return(1); result = smysql_bulk_query(mysqlconn, &fields, &rows, "SELECT 1 FROM oper WHERE nick_id=%u || nick_id=%u", u->nick_id, u->real_id); mysql_free_result(result); return(rows? 1 : 0); }
void help_cmd(const char *service, User *u, Command *list, const char *cmd) { Command *c = lookup_cmd(list, cmd); if (c) { const char *p1 = c->help_param1, *p2 = c->help_param2, *p3 = c->help_param3, *p4 = c->help_param4; if (c->helpmsg_all >= 0) { notice_help(service, u, c->helpmsg_all, p1, p2, p3, p4); } if (is_services_root(u)) { if (c->helpmsg_root >= 0) notice_help(service, u, c->helpmsg_root, p1, p2, p3, p4); else if (c->helpmsg_all < 0) notice_lang(service, u, NO_HELP_AVAILABLE, cmd); } else if (is_services_admin(u)) { if (c->helpmsg_admin >= 0) notice_help(service, u, c->helpmsg_admin, p1, p2, p3, p4); else if (c->helpmsg_all < 0) notice_lang(service, u, NO_HELP_AVAILABLE, cmd); } else if (is_services_oper(u)) { if (c->helpmsg_oper >= 0) notice_help(service, u, c->helpmsg_oper, p1, p2, p3, p4); else if (c->helpmsg_all < 0) notice_lang(service, u, NO_HELP_AVAILABLE, cmd); } else { if (c->helpmsg_reg >= 0) notice_help(service, u, c->helpmsg_reg, p1, p2, p3, p4); else if (c->helpmsg_all < 0) notice_lang(service, u, NO_HELP_AVAILABLE, cmd); } } else { notice_lang(service, u, NO_HELP_AVAILABLE, cmd); } }
void plexus_cmd_svid_umode3 (User * u, char *ts) { char modes[512]; strlcpy(modes, "+r", sizeof(modes)); if(ircd->rootmodeonid && is_services_root(u)) { strlcat(modes, ircd->rootmodeonid, sizeof(modes)); } else if(ircd->adminmodeonid && is_services_admin(u)) { strlcat(modes, ircd->adminmodeonid, sizeof(modes)); } else if(ircd->opermodeonid && is_services_oper(u)) { strlcat(modes, ircd->opermodeonid, sizeof(modes)); } if (u->svid != u->timestamp) { strlcat(modes, "d", sizeof(modes)); common_svsmode (u, modes, ts); } else { common_svsmode (u, modes, NULL); } }
/** * The /cs command. * @param u The user who issued the command * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing. **/ int do_logout(User * u) { char *chan = strtok(NULL, " "); char *nick = strtok(NULL, " "); ChannelInfo *ci; User *u2 = NULL; int is_servadmin = is_services_admin(u); if (!chan || (!nick && !is_servadmin)) { syntax_error(s_ChanServ, u, "LOGOUT", (!is_servadmin ? CHAN_LOGOUT_SYNTAX : CHAN_LOGOUT_SERVADMIN_SYNTAX)); } else if (!(ci = cs_findchan(chan))) { notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); } else if (!is_servadmin && (ci->flags & CI_VERBOTEN)) { notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); } else if (nick && !(u2 = finduser(nick))) { notice_lang(s_ChanServ, u, NICK_X_NOT_IN_USE, nick); } else if (!is_servadmin && u2 != u && !is_real_founder(u, ci)) { notice_lang(s_ChanServ, u, ACCESS_DENIED); } else { if (u2) { make_unidentified(u2, ci); notice_lang(s_ChanServ, u, CHAN_LOGOUT_SUCCEEDED, nick, chan); alog("%s: User %s!%s@%s has been logged out of channel %s.", s_ChanServ, u2->nick, u2->username, u2->host, chan); } else { int i; for (i = 0; i < 1024; i++) for (u2 = userlist[i]; u2; u2 = u2->next) make_unidentified(u2, ci); notice_lang(s_ChanServ, u, CHAN_LOGOUT_ALL_SUCCEEDED, chan); alog("%s: All users identified have been logged out of channel %s.", s_ChanServ, chan); } } return MOD_CONT; }
/** * The /bs assign command. * @param u The user who issued the command * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing. **/ int do_assign(User * u) { char *chan = strtok(NULL, " "); char *nick = strtok(NULL, " "); BotInfo *bi; ChannelInfo *ci; if (readonly) notice_lang(s_BotServ, u, BOT_ASSIGN_READONLY); else if (!chan || !nick) syntax_error(s_BotServ, u, "ASSIGN", BOT_ASSIGN_SYNTAX); else if (!(bi = findbot(nick))) notice_lang(s_BotServ, u, BOT_DOES_NOT_EXIST, nick); else if (bi->flags & BI_PRIVATE && !is_oper(u)) notice_lang(s_BotServ, u, PERMISSION_DENIED); else if (!(ci = cs_findchan(chan))) notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan); else if (ci->flags & CI_VERBOTEN) notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan); else if ((ci->bi) && (stricmp(ci->bi->nick, nick) == 0)) notice_lang(s_BotServ, u, BOT_ASSIGN_ALREADY, ci->bi->nick, chan); else if ((ci->botflags & BS_NOBOT) || (!check_access(u, ci, CA_ASSIGN) && !is_services_admin(u))) notice_lang(s_BotServ, u, PERMISSION_DENIED); else { if (ci->bi) unassign(u, ci); ci->bi = bi; bi->chancount++; if (ci->c && ci->c->usercount >= BSMinUsers) { bot_join(ci); } notice_lang(s_BotServ, u, BOT_ASSIGN_ASSIGNED, bi->nick, ci->name); send_event(EVENT_BOT_ASSIGN, 2, ci->name, bi->nick); } return MOD_CONT; }
/** * The /ns identify command. * @param u The user who issued the command * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing. **/ int do_identify(User * u) { char *pass = strtok(NULL, " "); NickAlias *na; NickRequest *nr; int res; char tsbuf[16]; char modes[512]; int len; if (!pass) { syntax_error(s_NickServ, u, "IDENTIFY", NICK_IDENTIFY_SYNTAX); } else if (!(na = u->na)) { if ((nr = findrequestnick(u->nick))) { notice_lang(s_NickServ, u, NICK_IS_PREREG); } else { notice_lang(s_NickServ, u, NICK_NOT_REGISTERED); } } else if (na->status & NS_VERBOTEN) { notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick); } else if (na->nc->flags & NI_SUSPENDED) { notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick); } else if (nick_identified(u)) { notice_lang(s_NickServ, u, NICK_ALREADY_IDENTIFIED); } else if (!(res = enc_check_password(pass, na->nc->pass))) { alog("%s: Failed IDENTIFY for %s!%s@%s", s_NickServ, u->nick, u->username, u->host); notice_lang(s_NickServ, u, PASSWORD_INCORRECT); bad_password(u); } else if (res == -1) { notice_lang(s_NickServ, u, NICK_IDENTIFY_FAILED); } else { if (!(na->status & NS_IDENTIFIED) && !(na->status & NS_RECOGNIZED)) { if (na->last_usermask) free(na->last_usermask); na->last_usermask = scalloc(strlen(common_get_vident(u)) + strlen(common_get_vhost(u)) + 2, 1); sprintf(na->last_usermask, "%s@%s", common_get_vident(u), common_get_vhost(u)); if (na->last_realname) free(na->last_realname); na->last_realname = sstrdup(u->realname); } na->status |= NS_IDENTIFIED; na->last_seen = time(NULL); snprintf(tsbuf, sizeof(tsbuf), "%lu", (unsigned long int) u->timestamp); if (ircd->modeonreg) { len = strlen(ircd->modeonreg); strncpy(modes,ircd->modeonreg,512); if(ircd->rootmodeonid && is_services_root(u)) { strncat(modes,ircd->rootmodeonid,512-len); } else if(ircd->adminmodeonid && is_services_admin(u)) { strncat(modes,ircd->adminmodeonid,512-len); } else if(ircd->opermodeonid && is_services_oper(u)) { strncat(modes,ircd->opermodeonid,512-len); } if (ircd->tsonmode) { common_svsmode(u, modes, tsbuf); } else { common_svsmode(u, modes, ""); } } send_event(EVENT_NICK_IDENTIFY, 1, u->nick); alog("%s: %s!%s@%s identified for nick %s", s_NickServ, u->nick, u->username, u->host, u->nick); notice_lang(s_NickServ, u, NICK_IDENTIFY_SUCCEEDED); if (ircd->vhost) { do_on_id(u); } if (NSModeOnID) { do_setmodes(u); } if (NSForceEmail && u->na && !u->na->nc->email) { notice_lang(s_NickServ, u, NICK_IDENTIFY_EMAIL_REQUIRED); notice_help(s_NickServ, u, NICK_IDENTIFY_EMAIL_HOWTO); } if (!(na->status & NS_RECOGNIZED)) check_memos(u); /* Enable nick tracking if enabled */ if (NSNickTracking) nsStartNickTracking(u); /* Clear any timers */ if (na->nc->flags & NI_KILLPROTECT) { del_ns_timeout(na, TO_COLLIDE); } } return MOD_CONT; }
int do_addnick(User * u) { NickAlias *na, *target; NickCore *nc; char *nick = strtok(NULL, " "); char *pass = strtok(NULL, " "); int i; char tsbuf[16]; char modes[512]; int len; if (NSEmailReg && (findrequestnick(u->nick))) { notice_lang(s_NickServ, u, NS_REQUESTED); return MOD_CONT; } if (readonly) { notice_lang(s_NickServ, u, NS_ADDNICK_DISABLED); return MOD_CONT; } if (checkDefCon(DEFCON_NO_NEW_NICKS)) { notice_lang(s_NickServ, u, OPER_DEFCON_DENIED); return MOD_CONT; } if (RestrictOperNicks) { for (i = 0; i < RootNumber; i++) { if (stristr(u->nick, ServicesRoots[i]) && !is_oper(u)) { notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED, u->nick); return MOD_CONT; } } for (i = 0; i < servadmins.count && (nc = servadmins.list[i]); i++) { if (stristr(u->nick, nc->display) && !is_oper(u)) { notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED, u->nick); return MOD_CONT; } } for (i = 0; i < servopers.count && (nc = servopers.list[i]); i++) { if (stristr(u->nick, nc->display) && !is_oper(u)) { notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED, u->nick); return MOD_CONT; } } } if (!nick || !pass) { syntax_error(s_NickServ, u, "ADDNICK", NS_ADDNICK_SYNTAX); } else if (!(target = findnick(nick))) { notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick); } else if (time(NULL) < u->lastnickreg + NSRegDelay) { notice_lang(s_NickServ, u, NS_ADDNICK_PLEASE_WAIT, NSRegDelay); } else if (u->na && (u->na->status & NS_VERBOTEN)) { alog("%s: %s@%s tried to use ADDNICK from forbidden nick %s.", s_NickServ, u->username, u->host, u->nick); notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, u->nick); } else if (u->na && (u->na->nc->flags & NI_SUSPENDED)) { alog("%s: %s!%s@%s tried to use ADDNICK from suspended nick %s.", s_NickServ, u->nick, u->username, u->host, target->nick); notice_lang(s_NickServ, u, NICK_X_SUSPENDED, u->nick); } else if (u->na && NSNoGroupChange) { notice_lang(s_NickServ, u, NS_ADDNICK_CHANGE_DISABLED, s_NickServ); } else if (u->na && !nick_identified(u)) { notice_lang(s_NickServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); } else if (target && (target->nc->flags & NI_SUSPENDED)) { alog("%s: %s!%s@%s tried to use GROUP from SUSPENDED nick %s", s_NickServ, u->nick, u->username, u->host, target->nick); notice_lang(s_NickServ, u, NICK_X_SUSPENDED, target->nick); } else if (target->status & NS_VERBOTEN) { notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, nick); } else if (u->na && target->nc == u->na->nc) { notice_lang(s_NickServ, u, NS_ADDNICK_SAME, target->nick); } else if (NSMaxAliases && (target->nc->aliases.count >= NSMaxAliases) && !nick_is_services_admin(target->nc)) { notice_lang(s_NickServ, u, NS_ADDNICK_TOO_MANY, target->nick, s_NickServ, s_NickServ); } else if (enc_check_password(pass, target->nc->pass) != 1) { alog("%s: Failed ADDNICK for %s!%s@%s (invalid password).", s_NickServ, u->nick, u->username, u->host); notice_lang(s_NickServ, u, PASSWORD_INCORRECT); bad_password(u); } else { /* If the nick is already registered, drop it. * If not, check that it is valid. */ if (u->na) { delnick(u->na); } else { int prefixlen = strlen(NSGuestNickPrefix); int nicklen = strlen(u->nick); if (nicklen <= prefixlen + 7 && nicklen >= prefixlen + 1 && stristr(u->nick, NSGuestNickPrefix) == u->nick && strspn(u->nick + prefixlen, "1234567890") == nicklen - prefixlen) { notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED, u->nick); return MOD_CONT; } } na = makealias(u->nick, target->nc); if (na) { na->last_usermask = scalloc(strlen(common_get_vident(u)) + strlen(common_get_vhost(u)) + 2, 1); sprintf(na->last_usermask, "%s@%s", common_get_vident(u), common_get_vhost(u)); na->last_realname = sstrdup(u->realname); na->time_registered = na->last_seen = time(NULL); na->status = (int16) (NS_IDENTIFIED | NS_RECOGNIZED); if (!(na->nc->flags & NI_SERVICES_ROOT)) { for (i = 0; i < RootNumber; i++) { if (!stricmp(ServicesRoots[i], u->nick)) { na->nc->flags |= NI_SERVICES_ROOT; break; } } } u->na = na; na->u = u; #ifdef USE_RDB /* Is this really needed? Since this is a new alias it will get * its unique id on the next update, since it was previously * deleted by delnick. Must observe... */ if (rdb_open()) { rdb_save_ns_alias(na); rdb_close(); } #endif send_event(EVENT_GROUP, 1, u->nick); alog("%s: %s!%s@%s makes %s join group of %s (%s) (e-mail: %s)", s_NickServ, u->nick, u->username, u->host, u->nick, target->nick, target->nc->display, (target->nc->email ? target->nc->email : "none")); notice_lang(s_NickServ, u, NS_ADDNICK_SUCCESS, target->nick); u->lastnickreg = time(NULL); snprintf(tsbuf, sizeof(tsbuf), "%lu", (unsigned long int) u->timestamp); if (ircd->modeonreg) { len = strlen(ircd->modeonreg); strncpy(modes,ircd->modeonreg,512); if(ircd->rootmodeonid && is_services_root(u)) { strncat(modes,ircd->rootmodeonid,512-len); } else if(ircd->adminmodeonid && is_services_admin(u)) { strncat(modes,ircd->adminmodeonid,512-len); } else if(ircd->opermodeonid && is_services_oper(u)) { strncat(modes,ircd->opermodeonid,512-len); } if (ircd->tsonmode) { common_svsmode(u, modes, tsbuf); } else { common_svsmode(u, modes, NULL); } } check_memos(u); } else { alog("%s: makealias(%s) failed", s_NickServ, u->nick); notice_lang(s_NickServ, u, NS_ADDNICK_FAILED); } } return MOD_CONT; }
/** * Add the help response to anopes /os help output. * @param u The user who is requesting help **/ void myOperServHelp(User * u) { if (is_services_admin(u) && u->isSuperAdmin) { notice_lang(s_OperServ, u, OPER_HELP_CMD_OLINE); } }
static void do_oper(User * u) { MYSQL_ROW row; unsigned int nick_id, fields, rows, err; MYSQL_RES *result; char *cmd, *nick; cmd = strtok(NULL, " "); if (!cmd) cmd = ""; if (stricmp(cmd, "ADD") == 0) { if (!is_services_admin(u)) { notice_lang(s_OperServ, u, PERMISSION_DENIED); return; } nick = strtok(NULL, " "); if (nick) { if (!(nick_id = mysql_findnick(nick))) { notice_lang(s_OperServ, u, NICK_X_NOT_REGISTERED, nick); return; } else if (num_serv_opers() >= MAX_SERVOPERS) { notice_lang(s_OperServ, u, OPER_OPER_TOO_MANY, MAX_SERVOPERS); return; } nick_id = mysql_getlink(nick_id); result = mysql_simple_query(mysqlconn, &err, "INSERT INTO oper (nick_id) VALUES (%u)", nick_id); switch (err) { case 0: mysql_free_result(result); notice_lang(s_OperServ, u, OPER_OPER_ADDED, nick); break; case ER_DUP_ENTRY: notice_lang(s_OperServ, u, OPER_OPER_EXISTS, nick); break; default: handle_mysql_error(mysqlconn, "insert_oper"); break; /* never reached */ } } else { syntax_error(s_OperServ, u, "OPER", OPER_OPER_ADD_SYNTAX); } } else if (stricmp(cmd, "DEL") == 0) { if (!is_services_admin(u)) { notice_lang(s_OperServ, u, PERMISSION_DENIED); return; } nick = strtok(NULL, " "); if (nick) { if (!(nick_id = mysql_findnick(nick))) { notice_lang(s_OperServ, u, NICK_X_NOT_REGISTERED, nick); return; } nick_id = mysql_getlink(nick_id); result = smysql_bulk_query(mysqlconn, &fields, &rows, "DELETE FROM oper WHERE nick_id=%u", nick_id); if (rows) { notice_lang(s_OperServ, u, OPER_OPER_REMOVED, nick); } else { notice_lang(s_OperServ, u, OPER_OPER_NOT_FOUND, nick); } mysql_free_result(result); } else { syntax_error(s_OperServ, u, "OPER", OPER_OPER_DEL_SYNTAX); } } else if (stricmp(cmd, "LIST") == 0) { notice_lang(s_OperServ, u, OPER_OPER_LIST_HEADER); result = smysql_bulk_query(mysqlconn, &fields, &rows, "SELECT nick.nick FROM nick, oper " "WHERE nick.nick_id=oper.nick_id ORDER BY nick.nick"); while ((row = smysql_fetch_row(mysqlconn, result))) notice(s_OperServ, u->nick, "%s", row[0]); } else { syntax_error(s_OperServ, u, "OPER", OPER_OPER_SYNTAX); } }
static void do_stats(User * u) { char timebuf[64]; time_t uptime; long count, mem, count2, mem2; int days, hours, mins, secs, timeout; struct tm *tm; char *extra; uptime = time(NULL) - start_time; extra = strtok(NULL, ""); days = uptime / 86400; hours = (uptime / 3600) % 24; mins = (uptime / 60) % 60; secs = uptime % 60; if (extra && stricmp(extra, "ALL") != 0) { if (stricmp(extra, "AKILL") == 0) { timeout = AutokillExpiry + 59; notice_lang(s_OperServ, u, OPER_STATS_AKILL_COUNT, num_akills()); if (timeout >= 172800) { notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_DAYS, timeout / 86400); } else if (timeout >= 86400) { notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_DAY); } else if (timeout >= 7200) { notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_HOURS, timeout / 3600); } else if (timeout >= 3600) { notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_HOUR); } else if (timeout >= 120) { notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_MINS, timeout / 60); } else if (timeout >= 60) { notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_MIN); } else { notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_NONE); } return; } else { notice_lang(s_OperServ, u, OPER_STATS_UNKNOWN_OPTION, strupper(extra)); } } notice_lang(s_OperServ, u, OPER_STATS_CURRENT_USERS, usercnt, opcnt); tm = localtime(&maxusertime); strftime_lang(timebuf, sizeof(timebuf), u, STRFTIME_DATE_TIME_FORMAT, tm); notice_lang(s_OperServ, u, OPER_STATS_MAX_USERS, maxusercnt, timebuf); if (days > 1) { notice_lang(s_OperServ, u, OPER_STATS_UPTIME_DHMS, days, hours, mins, secs); } else if (days == 1) { notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1DHMS, days, hours, mins, secs); } else { if (hours > 1) { if (mins != 1) { if (secs != 1) { notice_lang(s_OperServ, u, OPER_STATS_UPTIME_HMS, hours, mins, secs); } else { notice_lang(s_OperServ, u, OPER_STATS_UPTIME_HM1S, hours, mins, secs); } } else { if (secs != 1) { notice_lang(s_OperServ, u, OPER_STATS_UPTIME_H1MS, hours, mins, secs); } else { notice_lang(s_OperServ, u, OPER_STATS_UPTIME_H1M1S, hours, mins, secs); } } } else if (hours == 1) { if (mins != 1) { if (secs != 1) { notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1HMS, hours, mins, secs); } else { notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1HM1S, hours, mins, secs); } } else { if (secs != 1) { notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1H1MS, hours, mins, secs); } else { notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1H1M1S, hours, mins, secs); } } } else { if (mins != 1) { if (secs != 1) { notice_lang(s_OperServ, u, OPER_STATS_UPTIME_MS, mins, secs); } else { notice_lang(s_OperServ, u, OPER_STATS_UPTIME_M1S, mins, secs); } } else { if (secs != 1) { notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1MS, mins, secs); } else { notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1M1S, mins, secs); } } } } if (extra && stricmp(extra, "ALL") == 0 && is_services_admin(u)) { notice_lang(s_OperServ, u, OPER_STATS_BYTES_READ, total_read / 1024); notice_lang(s_OperServ, u, OPER_STATS_BYTES_WRITTEN, total_written / 1024); get_user_stats(&count, &mem); notice_lang(s_OperServ, u, OPER_STATS_USER_MEM, count, (mem + 512) / 1024); get_server_stats(&count, &mem); notice_lang(s_OperServ, u, OPER_STATS_SERVER_MEM, count, (mem + 512) / 1024); get_channel_stats(&count, &mem); notice_lang(s_OperServ, u, OPER_STATS_CHANNEL_MEM, count, (mem + 512) / 1024); get_nickserv_stats(&count, &mem); notice_lang(s_OperServ, u, OPER_STATS_NICKSERV_MEM, count, (mem + 512) / 1024); get_chanserv_stats(&count, &mem); notice_lang(s_OperServ, u, OPER_STATS_CHANSERV_MEM, count, (mem + 512) / 1024); get_memoserv_stats(&count, &mem); notice_lang(s_OperServ, u, OPER_STATS_MEMOSERV_MEM, count, (mem + 512) / 1024); count = 0; get_akill_stats(&count2, &mem2); count += count2; mem += mem2; get_news_stats(&count2, &mem2); count += count2; mem += mem2; get_exception_stats(&count2, &mem2); count += count2; mem += mem2; notice_lang(s_OperServ, u, OPER_STATS_OPERSERV_MEM, count, (mem + 512) / 1024); get_session_stats(&count, &mem); notice_lang(s_OperServ, u, OPER_STATS_SESSIONS_MEM, count, (mem + 512) / 1024); } }
/** * Add the help response to anopes /os help output. * @param u The user who is requesting help **/ void myOperServHelp(User * u) { if (is_services_admin(u)) { notice_lang(s_OperServ, u, OPER_HELP_CMD_GLOBAL); } }
int do_akick(User * u, Channel *c, char *cmd, char *mask, char *reason) { ChannelInfo *ci = c->ci; AutoKick *akick; int i; struct c_userlist *cu = NULL, *next = NULL; User *u2; char *argv[3]; int count = 0; if (!cmd || (!mask && (!stricmp(cmd, "ADD") || !stricmp(cmd, "STICK") || !stricmp(cmd, "UNSTICK") || !stricmp(cmd, "DEL")))) { noticeLang(ci->bi->nick, u, LANG_AKICK_SYNTAX); } else if (!check_access(u, ci, CA_AKICK) && !is_services_admin(u)) { notice_lang(ci->bi->nick, u, ACCESS_DENIED); } else if (stricmp(cmd, "ADD") == 0) { NickAlias *na = findnick(mask), *na2; User *target = finduser(mask); NickCore *nc = NULL; char *nick, *user, *host; int freemask = 0; if (readonly) { notice_lang(ci->bi->nick, u, CHAN_AKICK_DISABLED); return MOD_CONT; } if (!na) { if (target) { char tmp[BUFSIZE]; mask = NULL; freemask = 1; get_idealban(ci, target, tmp, BUFSIZE); mask = sstrdup(tmp); } else { split_usermask(mask, &nick, &user, &host); mask = scalloc(strlen(nick) + strlen(user) + strlen(host) + 3, 1); freemask = 1; sprintf(mask, "%s!%s@%s", nick, user, host); free(nick); free(user); free(host); } } else { if (na->status & NS_VERBOTEN) { notice_lang(ci->bi->nick, u, NICK_X_FORBIDDEN, mask); return MOD_CONT; } nc = na->nc; } /* Check excepts BEFORE we get this far */ if (ircd->except) { if (is_excepted_mask(ci, mask) == 1) { notice_lang(ci->bi->nick, u, CHAN_EXCEPTED, mask, c->name); if (freemask) free(mask); return MOD_CONT; } } /* Check whether target nick has equal/higher access * or whether the mask matches a user with higher/equal access ~ Viper */ if ((ci->flags & CI_PEACE) && nc) { if ((nc == ci->founder) || (get_access_nc(nc, ci) >= get_access(u, ci))) { notice_lang(s_ChanServ, u, PERMISSION_DENIED); if (freemask) free(mask); return MOD_CONT; } } else if ((ci->flags & CI_PEACE)) { char buf[BUFSIZE]; /* Match against all currently online users with equal or * higher access. - Viper */ for (i = 0; i < 1024; i++) { for (u2 = userlist[i]; u2; u2 = u2->next) { if (is_founder(u2, ci) || (get_access(u2, ci) >= get_access(u, ci))) { if (match_usermask(mask, u2)) { notice_lang(s_ChanServ, u, PERMISSION_DENIED); free(mask); return MOD_CONT; } } } } /* Match against the lastusermask of all nickalias's with equal * or higher access. ~ Viper */ for (i = 0; i < 1024; i++) { for (na2 = nalists[i]; na2; na2 = na2->next) { if (na2->status & NS_VERBOTEN) continue; if (na2->nc && ((na2->nc == ci->founder) || (get_access_nc(na2->nc, ci) >= get_access(u, ci)))) { snprintf(buf, BUFSIZE, "%s!%s", na2->nick, na2->last_usermask); if (match_wild_nocase(mask, buf)) { notice_lang(s_ChanServ, u, PERMISSION_DENIED); free(mask); return MOD_CONT; } } } } } for (akick = ci->akick, i = 0; i < ci->akickcount; akick++, i++) { if (!(akick->flags & AK_USED)) continue; if ((akick->flags & AK_ISNICK) ? akick->u.nc == nc : stricmp(akick->u.mask, mask) == 0) { notice_lang(ci->bi->nick, u, CHAN_AKICK_ALREADY_EXISTS, (akick->flags & AK_ISNICK) ? akick->u.nc-> display : akick->u.mask, c->name); if (freemask) free(mask); return MOD_CONT; } } /* All entries should be in use so we don't have to go over * the entire list. We simply add new entries at the end. */ if (ci->akickcount >= CSAutokickMax) { notice_lang(s_ChanServ, u, CHAN_AKICK_REACHED_LIMIT, CSAutokickMax); if (freemask) free(mask); return MOD_CONT; } ci->akickcount++; ci->akick = srealloc(ci->akick, sizeof(AutoKick) * ci->akickcount); akick = &ci->akick[i]; akick->flags = AK_USED; if (nc) { akick->flags |= AK_ISNICK; akick->u.nc = nc; } else { akick->u.mask = sstrdup(mask); } akick->creator = sstrdup(u->nick); akick->addtime = time(NULL); if (reason) { if (strlen(reason) > 200) reason[200] = '\0'; akick->reason = sstrdup(reason); } else { akick->reason = NULL; } /* Auto ENFORCE #63 */ cu = c->users; while (cu) { next = cu->next; if (check_kick(cu->user, c->name, c->creation_time)) { argv[0] = sstrdup(c->name); argv[1] = sstrdup(cu->user->nick); if (akick->reason) argv[2] = sstrdup(akick->reason); else argv[2] = sstrdup("none"); do_kick(ci->bi->nick, 3, argv); free(argv[2]); free(argv[1]); free(argv[0]); count++; } cu = next; } alog("%s: %s!%s@%s added akick for %s to %s", ci->bi->nick, u->nick, u->username, u->host, mask, c->name); notice_lang(ci->bi->nick, u, CHAN_AKICK_ADDED, mask, c->name); if (count) notice_lang(ci->bi->nick, u, CHAN_AKICK_ENFORCE_DONE, c->name, count); if (freemask) free(mask); } else if (stricmp(cmd, "STICK") == 0) { NickAlias *na; NickCore *nc; if (readonly) { notice_lang(ci->bi->nick, u, CHAN_AKICK_DISABLED); return MOD_CONT; } if (ci->akickcount == 0) { notice_lang(ci->bi->nick, u, CHAN_AKICK_LIST_EMPTY, ci->name); return MOD_CONT; } na = findnick(mask); nc = (na ? na->nc : NULL); for (akick = ci->akick, i = 0; i < ci->akickcount; akick++, i++) { if (!(akick->flags & AK_USED) || (akick->flags & AK_ISNICK)) continue; if (!stricmp(akick->u.mask, mask)) break; } if (i == ci->akickcount) { notice_lang(ci->bi->nick, u, CHAN_AKICK_NOT_FOUND, mask, ci->name); return MOD_CONT; } akick->flags |= AK_STUCK; alog("%s: %s!%s@%s set STICK on akick %s on %s", ci->bi->nick, u->nick, u->username, u->host, akick->u.mask, ci->name); notice_lang(ci->bi->nick, u, CHAN_AKICK_STUCK, akick->u.mask, ci->name); if (ci->c) stick_mask(ci, akick); } else if (stricmp(cmd, "UNSTICK") == 0) { NickAlias *na; NickCore *nc; if (readonly) { notice_lang(ci->bi->nick, u, CHAN_AKICK_DISABLED); return MOD_CONT; } if (ci->akickcount == 0) { notice_lang(ci->bi->nick, u, CHAN_AKICK_LIST_EMPTY, ci->name); return MOD_CONT; } na = findnick(mask); nc = (na ? na->nc : NULL); for (akick = ci->akick, i = 0; i < ci->akickcount; akick++, i++) { if (!(akick->flags & AK_USED) || (akick->flags & AK_ISNICK)) continue; if (!stricmp(akick->u.mask, mask)) break; } if (i == ci->akickcount) { notice_lang(ci->bi->nick, u, CHAN_AKICK_NOT_FOUND, mask, ci->name); return MOD_CONT; } akick->flags &= ~AK_STUCK; alog("%s: %s!%s@%s unset STICK on akick %s on %s", ci->bi->nick, u->nick, u->username, u->host, akick->u.mask, ci->name); notice_lang(ci->bi->nick, u, CHAN_AKICK_UNSTUCK, akick->u.mask, ci->name); } else if (stricmp(cmd, "DEL") == 0) { int deleted, a, b; if (readonly) { notice_lang(ci->bi->nick, u, CHAN_AKICK_DISABLED); return MOD_CONT; } if (ci->akickcount == 0) { notice_lang(ci->bi->nick, u, CHAN_AKICK_LIST_EMPTY, c->name); return MOD_CONT; } /* Special case: is it a number/list? Only do search if it isn't. */ if (isdigit(*mask) && strspn(mask, "1234567890,-") == strlen(mask)) { int count, last = -1; deleted = process_numlist(mask, &count, akick_del_callback, u, ci, &last); if (!deleted) { if (count == 1) { notice_lang(ci->bi->nick, u, CHAN_AKICK_NO_SUCH_ENTRY, last, ci->name); } else { notice_lang(ci->bi->nick, u, CHAN_AKICK_NO_MATCH, ci->name); } } else if (deleted == 1) { alog("%s: %s!%s@%s deleted 1 akick on %s", ci->bi->nick, u->nick, u->username, u->host, ci->name); notice_lang(ci->bi->nick, u, CHAN_AKICK_DELETED_ONE, ci->name); } else { alog("%s: %s!%s@%s deleted %d akicks on %s", ci->bi->nick, u->nick, u->username, u->host, deleted, ci->name); notice_lang(ci->bi->nick, u, CHAN_AKICK_DELETED_SEVERAL, deleted, ci->name); } } else { NickAlias *na = findnick(mask); NickCore *nc = (na ? na->nc : NULL); for (akick = ci->akick, i = 0; i < ci->akickcount; akick++, i++) { if (!(akick->flags & AK_USED)) continue; if (((akick->flags & AK_ISNICK) && akick->u.nc == nc) || (!(akick->flags & AK_ISNICK) && stricmp(akick->u.mask, mask) == 0)) break; } if (i == ci->akickcount) { notice_lang(ci->bi->nick, u, CHAN_AKICK_NOT_FOUND, mask, c->name); return MOD_CONT; } alog("%s: %s!%s@%s deleted akick %s on %s", ci->bi->nick, u->nick, u->username, u->host, mask, c->name); notice_lang(ci->bi->nick, u, CHAN_AKICK_DELETED, mask, c->name); akick_del(u, akick); deleted = 1; } if (deleted) { /* Reordering - DrStein */ for (b = 0; b < ci->akickcount; b++) { if (ci->akick[b].flags & AK_USED) { for (a = 0; a < ci->akickcount; a++) { if (a > b) break; if (!(ci->akick[a].flags & AK_USED)) { ci->akick[a].flags = ci->akick[b].flags; if (ci->akick[b].flags & AK_ISNICK) { ci->akick[a].u.nc = ci->akick[b].u.nc; } else { ci->akick[a].u.mask = sstrdup(ci->akick[b].u.mask); } /* maybe we should first check whether there is a reason before we sstdrup it -Certus */ if (ci->akick[b].reason) ci->akick[a].reason = sstrdup(ci->akick[b].reason); else ci->akick[a].reason = NULL; ci->akick[a].creator = sstrdup(ci->akick[b].creator); ci->akick[a].addtime = ci->akick[b].addtime; akick_del(u, &ci->akick[b]); break; } } } } /* After reordering only the entries at the end could still be empty. * We ll free the places no longer in use... - Viper */ for (i = ci->akickcount - 1; i >= 0; i--) { if (ci->akick[i].flags & AK_USED) break; ci->akickcount--; } ci->akick = srealloc(ci->akick,sizeof(AutoKick) * ci->akickcount); } } else if (stricmp(cmd, "LIST") == 0) { int sent_header = 0; if (ci->akickcount == 0) { notice_lang(ci->bi->nick, u, CHAN_AKICK_LIST_EMPTY, c->name); return MOD_CONT; } if (mask && isdigit(*mask) && strspn(mask, "1234567890,-") == strlen(mask)) { process_numlist(mask, NULL, akick_list_callback, u, ci, &sent_header); } else { for (akick = ci->akick, i = 0; i < ci->akickcount; akick++, i++) { if (!(akick->flags & AK_USED)) continue; if (mask) { if (!(akick->flags & AK_ISNICK) && !my_match_wild_nocase(mask, akick->u.mask)) continue; if ((akick->flags & AK_ISNICK) && !my_match_wild_nocase(mask, akick->u.nc->display)) continue; } akick_list(u, i, ci, &sent_header); } } if (!sent_header) notice_lang(ci->bi->nick, u, CHAN_AKICK_NO_MATCH, c->name); } else if (stricmp(cmd, "VIEW") == 0) { int sent_header = 0; if (ci->akickcount == 0) { notice_lang(ci->bi->nick, u, CHAN_AKICK_LIST_EMPTY, c->name); return MOD_CONT; } if (mask && isdigit(*mask) && strspn(mask, "1234567890,-") == strlen(mask)) { process_numlist(mask, NULL, akick_view_callback, u, ci, &sent_header); } else { for (akick = ci->akick, i = 0; i < ci->akickcount; akick++, i++) { if (!(akick->flags & AK_USED)) continue; if (mask) { if (!(akick->flags & AK_ISNICK) && !my_match_wild_nocase(mask, akick->u.mask)) continue; if ((akick->flags & AK_ISNICK) && !my_match_wild_nocase(mask, akick->u.nc->display)) continue; } akick_view(u, i, ci, &sent_header); } } if (!sent_header) notice_lang(ci->bi->nick, u, CHAN_AKICK_NO_MATCH, c->name); } else if (stricmp(cmd, "ENFORCE") == 0) { struct c_userlist *cu = NULL, *next = NULL; char *argv[3]; int count = 0; if (!c) { notice_lang(ci->bi->nick, u, CHAN_X_NOT_IN_USE, ci->name); return MOD_CONT; } cu = c->users; while (cu) { next = cu->next; if (check_kick(cu->user, c->name, c->creation_time)) { argv[0] = sstrdup(c->name); argv[1] = sstrdup(cu->user->nick); argv[2] = sstrdup(CSAutokickReason); do_kick(ci->bi->nick, 3, argv); free(argv[2]); free(argv[1]); free(argv[0]); count++; } cu = next; } notice_lang(ci->bi->nick, u, CHAN_AKICK_ENFORCE_DONE, ci->name, count); } else if (stricmp(cmd, "CLEAR") == 0) { if (readonly) { notice_lang(ci->bi->nick, u, CHAN_AKICK_DISABLED); return MOD_CONT; } for (akick = ci->akick, i = 0; i < ci->akickcount; akick++, i++) { if (!(akick->flags & AK_USED)) continue; akick_del(u, akick); } free(ci->akick); ci->akick = NULL; ci->akickcount = 0; alog("%s: %s!%s@%s cleared akicks on %s", ci->bi->nick, u->nick, u->username, u->host, ci->name); notice_lang(ci->bi->nick, u, CHAN_AKICK_CLEAR, ci->name); } else { noticeLang(ci->bi->nick, u, LANG_AKICK_SYNTAX); } return MOD_CONT; }
void myNickServHelp(User *u) { if (is_services_admin(u)) notice_user(s_NickServ, u, " SAREGISTER Register a nickname"); }
/** * Add the help response to anopes /os help output. * @param u The user who is requesting help **/ static void myOperServHelp(User * u) { if (is_services_admin(u)) { notice_lang(s_OperServ, u, OPER_HELP_CMD_RANDOMNEWS); } }
/** * Add the help response to anopes /ms help output. * @param u The user who is requesting help **/ void myMemoServHelp(User * u) { if (is_services_admin(u)) { notice_lang(s_MemoServ, u, MEMO_HELP_CMD_SENDALL); } }