int do_redirect (User *u) { char *buf = moduleGetLastBuffer(); User *target= NULL; Channel *c; ChannelInfo *ci; char *nick = myStrGetToken (buf,' ', 0); char *chan1 = myStrGetToken (buf,' ', 1); char *chan2 = myStrGetToken (buf,' ', 2); if (!u ||!chan1||!nick||!chan2) { if (nick) free(nick); if (chan1) free(chan1); if (chan2) free(chan2); return MOD_STOP; } if (!(target = finduser(nick))) { notice (s_OperServ, u->nick,"No such user to redirect"); if (nick) free(nick); if (chan1) free(chan1); if (chan2) free(chan2); return MOD_STOP; } if (!(ci = cs_findchan(chan1))) { if (nick) free(nick); if (chan1) free(chan1); if (chan2) free(chan2); return MOD_STOP; } if (!(c = findchan(ci->name))) { notice (s_OperServ, u->nick,"No such channel to be redirected from."); if (nick) free(nick); if (chan1) free(chan1); if (chan2) free(chan2); return MOD_STOP; } if (!(is_on_chan(c,target))) { notice (s_OperServ, u->nick,"User %s is not in this channel", target->nick); if (nick) free(nick); if (chan1) free(chan1); if (chan2) free(chan2); return MOD_STOP; } notice (s_OperServ, u->nick,"Redirecting user %s from channel %s to channel %s",target->nick,chan1,chan2); wallops(c->ci->bi->nick, "%s redirected %s from channel %s to channel %s .", u->nick, nick, c->name , chan2); anope_cmd_svspart(c->ci->bi->nick, nick, c->name); anope_cmd_svsjoin(s_OperServ, target->nick, chan2, NULL); notice (s_OperServ, target->nick,"You have been redirected from channel %s to channel %s by operator %s", chan1,chan2,u->nick); if (nick) free(nick); if (chan1) free(chan1); if (chan2) free(chan2); /* Halt processing */ return MOD_STOP; }
/** * Provide the user interface to add/remove a qdb ban from a nickname * @param u The user who executed this command * @return MOD_CONT if we want to process other commands in this command * stack, MOD_STOP if we dont **/ int myAddQDBBan(User * u) { char *text; char *nick; char *command; char *setting; int stop = 0; NickCore *nc; NickAlias *na; text = moduleGetLastBuffer(); if (text) { nick = myStrGetToken(text, ' ', 0); if (nick) { command = myStrGetToken(text, ' ', 1); if (command) { if (stricmp(command, "QDBBAN") == 0) { setting = myStrGetToken(text, ' ', 2); if (setting) { if (!(na = findnick(nick))) { notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick); } else { nc = na->nc; if (stricmp(setting, "ON") == 0) { moduleAddData(&nc->moduleData, "qdbban", "on"); moduleNoticeLang(s_NickServ, u, QDBBAN_ADD_SUCCESS, nc->display); alog("ns_qdbban: %s!%s@%s banned %s from using the QDB", u->nick, u->username, u->host, nc->display); } else if (stricmp(setting, "OFF") == 0) { moduleDelData(&nc->moduleData, "qdbban"); moduleNoticeLang(s_NickServ, u, QDBBAN_DEL_SUCCESS, nc->display); alog("ns_qdbban: %s!%s@%s unbanned %s from using the QDB", u->nick, u->username, u->host, nc->display); } else { moduleNoticeLang(s_NickServ, u, QDBBAN_HELP); } } free(setting); } else { moduleNoticeLang(s_NickServ, u, QDBBAN_HELP); } stop = 1; } free(command); } free(nick); } } if (stop == 0) { return MOD_CONT; } else { return MOD_STOP; } }
/** * Called after an svsadmin does a /ns info nick * @param u The user who requested info * @return MOD_CONT to continue processing commands or MOD_STOP to stop **/ int myNickInfo(User * u) { char *text; char *nick; char *data; NickCore *nc; NickAlias *na; if (is_services_oper(u)) { text = moduleGetLastBuffer(); if (text) { nick = myStrGetToken(text, ' ', 0); if (nick) { if ((na = findnick(nick))) { nc = na->nc; if ((data = moduleGetData(&nc->moduleData, "qdbban"))) { notice_user(s_NickServ, u, "%s is banned from submitting to the QDB", na->nick); } if (data) free(data); } free(nick); } } } return MOD_CONT; }
int do_resendcode(User * u) { char *buffer = NULL; char *nick = NULL; NickAlias *na = NULL; buffer = moduleGetLastBuffer(); if (buffer) nick = myStrGetToken(buffer, ' ', 0); if (!nick) { moduleNoticeLang(s_NickServ, u, RESENDCODE_SYNTAX); } else if (!anope_valid_nick(nick)) { notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, nick); } else if (!(na = findnick(nick))) { notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick); } else if (nick_identified(na->u)) { notice_lang(s_NickServ, u, NICK_ALREADY_IDENTIFIED); } else if (!(moduleGetData(&na->nc->moduleData, MODULEDATAKEY))) { moduleNoticeLang(s_NickServ, u, RESETPASS_NOT_REQUESTED, u->nick); } else { if (do_sendmail(u, na) != 0) { alog(LOG_COULDNT_SENDMAIL, MYNAME, na->nick); } else { moduleNoticeLang(s_NickServ, u, RESETPASS_SUCCESS, na->nick); moduleNoticeLang(s_NickServ, u, RESETPASS_INSTRUC); } } return MOD_CONT; }
int my_ns_set(User * u) { char *cur_buffer; char *set; char *email; int ret; cur_buffer = moduleGetLastBuffer(); set = myStrGetToken(cur_buffer, ' ', 0); if (!set) return MOD_CONT; if (stricmp(set, "email") != 0) { free(set); return MOD_CONT; } free(set); email = myStrGetToken(cur_buffer, ' ', 1); if (!email) return MOD_CONT; ret = check_email_limit_reached(email, u); free(email); return ret; }
static int hs_do_list_out(User * u) { char *key; key = moduleGetLastBuffer(); if (!key) return MOD_CONT; if (stricmp(key, "+req") != 0) return MOD_CONT; show_list(u); return MOD_CONT; }
static int hs_do_reject(User * u) { char *cur_buffer; char *nick; char *reason; HostCore *tmp, *hc; boolean found = false; cur_buffer = moduleGetLastBuffer(); nick = myStrGetToken(cur_buffer, ' ', 0); reason = myStrGetTokenRemainder(cur_buffer, ' ', 1); if (!nick) { moduleNoticeLang(s_HostServ, u, LNG_REJECT_SYNTAX); if (reason) free(reason); return MOD_CONT; } tmp = findHostCore(hs_request_head, nick, &found); if (found) { if (!tmp) hc = hs_request_head; else hc = tmp->next; if (HSRequestMemoUser) { if (reason) my_memo_lang(u, hc->nick, 2, NULL, LNG_REJECT_MEMO_REASON, reason); else my_memo_lang(u, hc->nick, 2, NULL, LNG_REJECT_MEMO); } hs_request_head = deleteHostCore(hs_request_head, tmp); moduleNoticeLang(s_HostServ, u, LNG_REJECTED, nick); alog("Host Request for %s rejected by %s (%s)", nick, u->nick, reason ? reason : ""); } else { moduleNoticeLang(s_HostServ, u, LNG_NO_REQUEST, nick); } free(nick); if (reason) free(reason); return MOD_CONT; }
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 my_ns_register(User * u) { char *cur_buffer; char *email; int ret; cur_buffer = moduleGetLastBuffer(); email = myStrGetToken(cur_buffer, ' ', 1); if (!email) return MOD_CONT; ret = check_email_limit_reached(email, u); free(email); return ret; }
static int hs_do_activate(User * u) { char *cur_buffer; char *nick; NickAlias *na; HostCore *tmp, *hc; boolean found = false; cur_buffer = moduleGetLastBuffer(); nick = myStrGetToken(cur_buffer, ' ', 0); if (!nick) { moduleNoticeLang(s_HostServ, u, LNG_ACTIVATE_SYNTAX); return MOD_CONT; } if ((na = findnick(nick))) { tmp = findHostCore(hs_request_head, nick, &found); if (found) { if (!tmp) hc = hs_request_head; else hc = tmp->next; addHostCore(hc->nick, hc->vIdent, hc->vHost, u->nick, time(NULL)); if (HSRequestMemoUser) my_memo_lang(u, hc->nick, 2, NULL, LNG_ACTIVATE_MEMO); hs_request_head = deleteHostCore(hs_request_head, tmp); moduleNoticeLang(s_HostServ, u, LNG_ACTIVATED, nick); alog("Host Request for %s activated by %s", nick, u->nick); } else { moduleNoticeLang(s_HostServ, u, LNG_NO_REQUEST, nick); } } else { notice_lang(s_HostServ, u, NICK_X_NOT_REGISTERED, nick); } free(nick); return MOD_CONT; }
int do_confirm(User * u) { char *buffer = NULL; char *nick = NULL; char *passcode = NULL; char *moduledata = NULL; NickAlias *na = NULL; buffer = moduleGetLastBuffer(); if (buffer) { nick = myStrGetToken(buffer, ' ', 0); passcode = myStrGetToken(buffer, ' ', 1); } if (!nick) { moduleNoticeLang(s_NickServ, u, ENTERCODE_SYNTAX); } else if (!anope_valid_nick(nick)) { notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, nick); } else if (!(na = findnick(nick))) { notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick); } else if (nick_identified(na->u)) { notice_lang(s_NickServ, u, NICK_ALREADY_IDENTIFIED); } else if (!passcode) { moduleNoticeLang(s_NickServ, u, ENTERCODE_SYNTAX); } else { if (!(moduledata = moduleGetData(&na->nc->moduleData, MODULEDATAKEY))) { moduleNoticeLang(s_NickServ, u, RESETPASS_NOT_REQUESTED, nick); } else if (strcmp(passcode, moduledata) != 0) { moduleNoticeLang(s_NickServ, u, ENTERCODE_WRONG_PASSCODE); free(moduledata); } else { ns_setpassword(u, na->nc); moduleDelData(&na->nc->moduleData, MODULEDATAKEY); free(moduledata); } } return MOD_CONT; }
static int do_tban(User * u) { char mask[BUFSIZE]; Channel *c; User *u2 = NULL; char *buffer = moduleGetLastBuffer(); char *chan; char *nick; char *time; chan = myStrGetToken(buffer, ' ', 0); nick = myStrGetToken(buffer, ' ', 1); time = myStrGetToken(buffer, ' ', 2); if (time && chan && nick) { if (!(c = findchan(chan))) { notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan); } else if (!(u2 = finduser(nick))) { notice_lang(s_ChanServ, u, NICK_X_NOT_IN_USE, nick); } else { if (canBanUser(c, u, u2)) { get_idealban(c->ci, u2, mask, sizeof(mask)); addBan(c, dotime(time), mask); mySendResponse(u, chan, mask, time); } } } else { myFullHelpSyntax(u); } if (time) free(time); if (nick) free(nick); if (chan) free(chan); return MOD_CONT; }
int do_saregister(User *u) { char *buf, *nick, *pass, *email; NickRequest *nr; NickAlias *na; User *user; buf = moduleGetLastBuffer(); nick = myStrGetToken(buf, ' ', 0); pass = myStrGetToken(buf, ' ', 1); email = myStrGetToken(buf, ' ', 2); if (!email) { notice_user(s_NickServ, u, "Syntax: \2SAREGISTER \37nick\37 \37password\37 \37email\37"); notice_lang(s_NickServ, u, MORE_INFO, s_NickServ, "SAREGISTER"); } else if (readonly) { notice_lang(s_NickServ, u, NICK_REGISTRATION_DISABLED); } else if ((nr = findrequestnick(nick))) { notice_lang(s_NickServ, u, NICK_REQUESTED); } else if (!anope_valid_nick(nick)) { notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, nick); } else if ((na = findnick(nick))) { if (na->status & NS_VERBOTEN) notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED, nick); else notice_lang(s_NickServ, u, NICK_ALREADY_REGISTERED, nick); } else if (!MailValidate(email)) { notice_lang(s_NickServ, u, MAIL_X_INVALID, email); } else { na = makenick(nick); if (!na) { alog("%s: makenick(%s) failed", s_NickServ, u->nick); notice_lang(s_NickServ, u, NICK_REGISTRATION_FAILED); } else { user = finduser(nick); enc_encrypt(pass, strlen(pass), na->nc->pass, PASSMAX - 1); na->nc->flags |= NSDefFlags; na->nc->memos.memomax = MSMaxMemos; if (user) na->last_usermask = user->vhost ? sstrdup(user->vhost) : sstrdup(user->host); else na->last_usermask = sstrdup("*@*"); if (user) na->last_realname = sstrdup(user->realname); else na->last_realname = sstrdup("unknown"); na->time_registered = na->last_seen = time(NULL); na->nc->language = NSDefLanguage; na->nc->email = sstrdup(email); send_event(EVENT_NICK_REGISTERED, 1, nick); alog("%s: %s (%s@%s) used saregister to register %s", s_NickServ, u->nick, u->username, u->host, nick); notice_user(s_NickServ, u, "Nick \2%s\2 has been registered", nick); if (user) { user->na = na; validate_user(user); } } } if (email) free(email); if (pass) free(pass); if (nick) free(nick); return MOD_CONT; }
int do_root(User *u) { char *buf = moduleGetLastBuffer(); char *cmd = myStrGetToken(buf, ' ', 0); char *nick = myStrGetToken(buf, ' ', 1); if (!cmd) { do_syntax_err(u); } else { if (!stricmp(cmd, "LIST")) { notice_user(s_OperServ, u, "Current services roots:"); int i; for (i = 0; i < RootNumber; ++i) { notice_user(s_OperServ, u, "%d. %s", i + 1, ServicesRoots[i]); } notice_user(s_OperServ, u, "End of services root list."); } else if (!nick) do_syntax_err(u); else { NickAlias *na = findnick(nick); if (!na) notice_lang(s_OperServ, u, NICK_X_NOT_REGISTERED, nick); else if (!stricmp(cmd, "ADD")) { if (na->nc->flags & NI_SERVICES_ROOT) { notice_user(s_OperServ, u, "\2%s\2 is already a services root", na->nick); } else { ++RootNumber; ServicesRoots = srealloc(ServicesRoots, sizeof(char *) * RootNumber); ServicesRoots[RootNumber - 1] = sstrdup(na->nick); na->nc->flags |= NI_SERVICES_ROOT; anope_cmd_global(s_OperServ, "\2%s\2 made \2%s\2 (\2%s\2) a services root administrator", u->nick, na->nick, na->nc->display); alog("%s: %s!%s@%s made %s (%s) a services root administrator", s_OperServ, u->nick, u->username, u->host, na->nick, na->nc->display); notice_user(s_OperServ, u, "\2%s\2 added to the services root administrator list.", na->nick); } } else if (!stricmp(cmd, "DEL")) { if (!(na->nc->flags & NI_SERVICES_ROOT)) { notice_user(s_OperServ, u, "\2%s\2 isn't already a services root", na->nick); } else { na->nc->flags &= ~NI_SERVICES_ROOT; int i, j, removed = 0; NickAlias *na2; for (i = 0; i < RootNumber; ++i) { for (j = 0; j < na->nc->aliases.count; ++j) { na2 = na->nc->aliases.list[j]; if (ServicesRoots[i] && !stricmp(ServicesRoots[i], na2->nick)) { free(ServicesRoots[i]); ServicesRoots[i] = NULL; ++removed; break; } } } int RealRootNum = RootNumber - removed;; char **RealRoots = scalloc(RealRootNum, sizeof(char *)); j = 0; for (i = 0; i < RootNumber; ++i) { if (ServicesRoots[i]) { RealRoots[j] = sstrdup(ServicesRoots[i]); ++j; } } free(ServicesRoots); ServicesRoots = RealRoots; RootNumber = RealRootNum; anope_cmd_global(s_OperServ, "\2%s\2 removed \2%s\2 (\2%s\2) from being a services root administrator", u->nick, na->nick, na->nc->display); alog("%s: %s!%s@%s made %s (%s) a services root administrator", s_OperServ, u->nick, u->username, u->host, na->nick, na->nc->display); notice_user(s_OperServ, u, "\2%s\2 removed from the services root administrator list.", na->nick); } } else do_syntax_err(u); } } if (cmd) free(cmd); if (nick) free(nick); return MOD_CONT; }
int do_resetpass(User * u) { char *buffer = NULL; char *nick = NULL; char *email = NULL; char passcode[PASSCODELEN]; char *callBackinfo[1]; NickAlias *na = NULL; if ((RestrictReset == 1) && !(is_oper(u))) { notice_lang(s_NickServ, u, ACCESS_DENIED); return MOD_CONT; } buffer = moduleGetLastBuffer(); nick = myStrGetToken(buffer, ' ', 0); email = myStrGetToken(buffer, ' ', 1); if (!nick) { moduleNoticeLang(s_NickServ, u, RESETPASS_SYNTAX); } else if (!anope_valid_nick(nick)) { notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, nick); } else if (!(na = findnick(nick))) { notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick); } 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 (!na->nc->email) { notice_user(s_NickServ, u, "%s has no email associated with their account.", na->nick); } else if (moduleGetData(&na->nc->moduleData, MODULEDATAKEY)) { moduleNoticeLang(s_NickServ, u, RESETPASS_ALREADY_REQUESTED1, na->nick); moduleNoticeLang(s_NickServ, u, RESETPASS_ALREADY_REQUESTED2); } else if (!email && !is_oper(u) && !is_helpop(u)) { notice(s_NickServ, u->nick, "You need to provide the e-mail address associated with the account you are trying to reset the password on."); notice(s_NickServ, u->nick, "Syntax: /ns resetpass <nickname> <e-mail>"); } else if (!is_oper(u) && !is_helpop(u) && strcasecmp(email, na->nc->email)) { notice(s_NickServ, u->nick, "The e-mail address %s does not match the one associated with account %s.", email, na->nc->display); } else { generatePassCode(passcode); moduleAddData(&na->nc->moduleData, MODULEDATAKEY, passcode); if (do_sendmail(u, na) != 0) { alog(LOG_COULDNT_SENDMAIL, MYNAME, na->nick); moduleDelData(&na->nc->moduleData, MODULEDATAKEY); } else { callBackinfo[0] = na->nick; moduleAddCallback(MYNAME, time(NULL) + ExpirePassCode, expirePassCode, 1, callBackinfo); alog(LOG_RESETPASS_REQUESTED, MYNAME, u->nick, na->nick); moduleNoticeLang(s_NickServ, u, RESETPASS_SUCCESS, na->nick); moduleNoticeLang(s_NickServ, u, RESETPASS_INSTRUC); } } if (nick) free(nick); if (email) free(email); return MOD_CONT; }
int do_avoice(User *u) { char *buf = moduleGetLastBuffer(); char *chan = myStrGetToken(buf, ' ', 0); char *option = myStrGetTokenRemainder(buf, ' ', 1); char *data; ChannelInfo *ci; if (!chan) { moduleNoticeLang(s_ChanServ, u, CS_AUTOVOICE_SYNTAX); return MOD_CONT; } if ((ci = cs_findchan(chan))) { if (!check_access(u, ci, CA_PROTECT)) { notice_lang(s_ChanServ, u, PERMISSION_DENIED); if (chan) free(chan); if (option) free(option); return MOD_CONT; } if (!option) { if ((data = moduleGetData(&ci->moduleData, "avoice"))) { if (stricmp(data, "REG") == 0) { moduleNoticeLang(s_ChanServ, u, CS_AUTOVOICE_STATUS_REG, chan); } else if (stricmp(data, "ALL") == 0) { moduleNoticeLang(s_ChanServ, u, CS_AUTOVOICE_STATUS_ALL, chan); } free(data); } else { moduleNoticeLang(s_ChanServ, u, CS_AUTOVOICE_STATUS_OFF, chan); } } else { if (stricmp(option, "REG") == 0) { moduleAddData(&ci->moduleData, "avoice", "REG"); moduleNoticeLang(s_ChanServ, u, CS_AUTOVOICE_SET_REG, chan); } else if (stricmp(option, "ALL") == 0) { moduleAddData(&ci->moduleData, "avoice", "ALL"); moduleNoticeLang(s_ChanServ, u, CS_AUTOVOICE_SET_ALL, chan); } else if (stricmp(option, "OFF") == 0) { moduleDelData(&ci->moduleData, "avoice"); moduleNoticeLang(s_ChanServ, u, CS_AUTOVOICE_SET_OFF, chan); } else if (stricmp(option, "STATUS") == 0) { if ((data = moduleGetData(&ci->moduleData, "avoice"))) { if (stricmp(data, "REG") == 0) { moduleNoticeLang(s_ChanServ, u, CS_AUTOVOICE_STATUS_REG, chan); } else if (stricmp(data, "ALL") == 0) { moduleNoticeLang(s_ChanServ, u, CS_AUTOVOICE_STATUS_ALL, chan); } free(data); } else { moduleNoticeLang(s_ChanServ, u, CS_AUTOVOICE_STATUS_OFF, chan); } } else { moduleNoticeLang(s_ChanServ, u, CS_AUTOVOICE_SYNTAX); } } } else { notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); } if (chan) free(chan); if (option) free(option); return MOD_CONT; }
static int my_cs_appendtopic(User * u) { char *cur_buffer; char *chan; char *newtopic; char topic[1024]; Channel *c; ChannelInfo *ci; cur_buffer = moduleGetLastBuffer(); chan = myStrGetToken(cur_buffer, ' ', 0); newtopic = myStrGetTokenRemainder(cur_buffer, ' ', 1); if (!chan || !newtopic) { moduleNoticeLang(s_ChanServ, u, LNG_APPENDTOPIC_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, c->name); } 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_TOPIC)) { notice_lang(s_ChanServ, u, PERMISSION_DENIED); } else { if (ci->last_topic) { snprintf(topic, sizeof(topic), "%s %s", ci->last_topic, newtopic); free(ci->last_topic); } else { strscpy(topic, newtopic, sizeof(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)) alog("%s: %s!%s@%s changed topic of %s as services admin.", s_ChanServ, u->nick, u->username, u->host, c->name); if (ircd->join2set) { if (whosends(ci) == s_ChanServ) { anope_cmd_join(s_ChanServ, c->name, c->creation_time); anope_cmd_mode(NULL, c->name, "+o %s", GET_BOT(s_ChanServ)); } } anope_cmd_topic(whosends(ci), c->name, u->nick, topic, c->topic_time); if (ircd->join2set) { if (whosends(ci) == s_ChanServ) { anope_cmd_part(s_ChanServ, c->name, NULL); } } } Anope_Free(chan); Anope_Free(newtopic); return MOD_CONT; }
static int hs_do_request(User * u) { char *cur_buffer; char *nick; char *rawhostmask; char hostmask[HOSTMAX]; NickAlias *na; int32 tmp_time; char *s; char *vIdent = NULL; time_t now = time(NULL); cur_buffer = moduleGetLastBuffer(); nick = u->nick; rawhostmask = myStrGetToken(cur_buffer, ' ', 0); if (!nick || !rawhostmask) { if (rawhostmask) free(rawhostmask); moduleNoticeLang(s_HostServ, u, LNG_REQUEST_SYNTAX); return MOD_CONT; } vIdent = myStrGetOnlyToken(rawhostmask, '@', 0); /* Get the first substring, @ as delimiter */ if (vIdent) { rawhostmask = myStrGetTokenRemainder(rawhostmask, '@', 1); /* get the remaining string */ if (!rawhostmask) { moduleNoticeLang(s_HostServ, u, LNG_REQUEST_SYNTAX); free(vIdent); return MOD_CONT; } if (strlen(vIdent) > USERMAX - 1) { notice_lang(s_HostServ, u, HOST_SET_IDENTTOOLONG, USERMAX); free(vIdent); free(rawhostmask); return MOD_CONT; } else { for (s = vIdent; *s; s++) { if (!my_isvalidchar(*s)) { notice_lang(s_HostServ, u, HOST_SET_IDENT_ERROR); free(vIdent); free(rawhostmask); return MOD_CONT; } } } if (!ircd->vident) { notice_lang(s_HostServ, u, HOST_NO_VIDENT); free(vIdent); free(rawhostmask); return MOD_CONT; } } if (strlen(rawhostmask) < HOSTMAX) { snprintf(hostmask, HOSTMAX, "%s", rawhostmask); } else { notice_lang(s_HostServ, u, HOST_SET_TOOLONG, HOSTMAX); if (vIdent) free(vIdent); free(rawhostmask); return MOD_CONT; } if (!isValidHost(hostmask, 3)) { notice_lang(s_HostServ, u, HOST_SET_ERROR); if (vIdent) free(vIdent); free(rawhostmask); return MOD_CONT; } tmp_time = time(NULL); if ((na = findnick(nick))) { if (HSRequestMemoOper || HSRequestMemoSetters) { if (MSSendDelay > 0 && u && u->lastmemosend + MSSendDelay > now) { moduleNoticeLang(s_HostServ, u, LNG_REQUEST_WAIT, MSSendDelay); u->lastmemosend = now; if (vIdent) free(vIdent); free(rawhostmask); return MOD_CONT; } } my_add_host_request(nick, vIdent, hostmask, u->nick, tmp_time); moduleNoticeLang(s_HostServ, u, LNG_REQUESTED); req_send_memos(u, hostmask); alog("New vHost Requested by %s", nick); } else { notice_lang(s_HostServ, u, HOST_NOREG, nick); } if (vIdent) free(vIdent); free(rawhostmask); return MOD_CONT; }