static void cs_cmd_hold(char *origin) { char *target = strtok(NULL, " "); char *action = strtok(NULL, " "); mychan_t *mc; if (!target || !action) { notice(chansvs.nick, origin, STR_INSUFFICIENT_PARAMS, "HOLD"); notice(chansvs.nick, origin, "Usage: HOLD <#channel> <ON|OFF>"); return; } if (*target != '#') { notice(chansvs.nick, origin, STR_INVALID_PARAMS, "HOLD"); return; } if (!(mc = mychan_find(target))) { notice(chansvs.nick, origin, "\2%s\2 is not registered.", target); return; } if (!strcasecmp(action, "ON")) { if (mc->flags & MC_HOLD) { notice(chansvs.nick, origin, "\2%s\2 is already held.", target); return; } mc->flags |= MC_HOLD; wallops("%s set the HOLD option for the channel \2%s\2.", origin, target); logcommand(chansvs.me, user_find_named(origin), CMDLOG_ADMIN, "%s HOLD ON", mc->name); notice(chansvs.nick, origin, "\2%s\2 is now held.", target); } else if (!strcasecmp(action, "OFF")) { if (!(mc->flags & MC_HOLD)) { notice(chansvs.nick, origin, "\2%s\2 is not held.", target); return; } mc->flags &= ~MC_HOLD; wallops("%s removed the HOLD option on the channel \2%s\2.", origin, target); logcommand(chansvs.me, user_find_named(origin), CMDLOG_ADMIN, "%s HOLD OFF", mc->name); notice(chansvs.nick, origin, "\2%s\2 is no longer held.", target); } else { notice(chansvs.nick, origin, STR_INVALID_PARAMS, "HOLD"); notice(chansvs.nick, origin, "Usage: HOLD <#channel> <ON|OFF>"); } }
static void ns_cmd_staff(sourceinfo_t *si, int parc, char *parv[]) { char *target = parv[0]; char *action = parv[1]; myuser_t *mu; if (!target || !action) { command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "STAFF"); command_fail(si, fault_needmoreparams, _("Usage: STAFF <account> <ON|OFF>")); return; } if (!(mu = myuser_find_ext(target))) { command_fail(si, fault_nosuch_target, _("\2%s\2 is not registered."), target); return; } if (!strcasecmp(action, "ON")) { if (metadata_find(mu, "private:staff:setter")) { command_fail(si, fault_badparams, _("\2%s\2 is already a member of staff."), entity(mu)->name); return; } metadata_add(mu, "private:staff:setter", get_oper_name(si)); metadata_add(mu, "private:staff:timestamp", number_to_string(CURRTIME)); wallops("%s set the STAFF option for the account \2%s\2.", get_oper_name(si), entity(mu)->name); logcommand(si, CMDLOG_ADMIN, "STAFF:ON: \2%s\2", entity(mu)->name); command_success_nodata(si, _("\2%s\2 is now a member of staff."), entity(mu)->name); } else if (!strcasecmp(action, "OFF")) { if (!metadata_find(mu, "private:staff:setter")) { command_fail(si, fault_badparams, _("\2%s\2 is not a member of staff."), entity(mu)->name); return; } metadata_delete(mu, "private:staff:setter"); metadata_delete(mu, "private:staff:timestamp"); wallops("%s removed the STAFF option on the account \2%s\2.", get_oper_name(si), entity(mu)->name); logcommand(si, CMDLOG_ADMIN, "STAFF:OFF: \2%s\2", entity(mu)->name); command_success_nodata(si, _("\2%s\2 is no longer a member of staff."), entity(mu)->name); } else { command_fail(si, fault_needmoreparams, STR_INVALID_PARAMS, "STAFF"); command_fail(si, fault_needmoreparams, _("Usage: STAFF <account> <ON|OFF>")); } }
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; }
static void ns_cmd_regnolimit(struct sourceinfo *si, int parc, char *parv[]) { char *target = parv[0]; char *action = parv[1]; struct myuser *mu; if (!target || !action) { command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "REGNOLIMIT"); command_fail(si, fault_needmoreparams, _("Usage: REGNOLIMIT <account> <ON|OFF>")); return; } if (!(mu = myuser_find_ext(target))) { command_fail(si, fault_nosuch_target, _("\2%s\2 is not registered."), target); return; } if (!strcasecmp(action, "ON")) { if (mu->flags & MU_REGNOLIMIT) { command_fail(si, fault_badparams, _("\2%s\2 can already bypass registration limits."), entity(mu)->name); return; } mu->flags |= MU_REGNOLIMIT; wallops("%s set the REGNOLIMIT option for the account \2%s\2.", get_oper_name(si), entity(mu)->name); logcommand(si, CMDLOG_ADMIN, "REGNOLIMIT:ON: \2%s\2", entity(mu)->name); command_success_nodata(si, _("\2%s\2 can now bypass registration limits."), entity(mu)->name); } else if (!strcasecmp(action, "OFF")) { if (!(mu->flags & MU_REGNOLIMIT)) { command_fail(si, fault_badparams, _("\2%s\2 cannot bypass registration limits."), entity(mu)->name); return; } mu->flags &= ~MU_REGNOLIMIT; wallops("%s removed the REGNOLIMIT option on the account \2%s\2.", get_oper_name(si), entity(mu)->name); logcommand(si, CMDLOG_ADMIN, "REGNOLIMIT:OFF: \2%s\2", entity(mu)->name); command_success_nodata(si, _("\2%s\2 cannot bypass registration limits anymore."), entity(mu)->name); } else { command_fail(si, fault_needmoreparams, STR_INVALID_PARAMS, "REGNOLIMIT"); command_fail(si, fault_needmoreparams, _("Usage: REGNOLIMIT <account> <ON|OFF>")); } }
static void ns_cmd_hold(struct sourceinfo *si, int parc, char *parv[]) { char *target = parv[0]; char *action = parv[1]; struct myuser *mu; if (!target || !action) { command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "HOLD"); command_fail(si, fault_needmoreparams, _("Usage: HOLD <account> <ON|OFF>")); return; } if (!(mu = myuser_find_ext(target))) { command_fail(si, fault_nosuch_target, STR_IS_NOT_REGISTERED, target); return; } if (!strcasecmp(action, "ON")) { if (mu->flags & MU_HOLD) { command_fail(si, fault_badparams, _("\2%s\2 is already held."), entity(mu)->name); return; } mu->flags |= MU_HOLD; wallops("%s set the HOLD option for the account \2%s\2.", get_oper_name(si), entity(mu)->name); logcommand(si, CMDLOG_ADMIN, "HOLD:ON: \2%s\2", entity(mu)->name); command_success_nodata(si, _("\2%s\2 is now held."), entity(mu)->name); } else if (!strcasecmp(action, "OFF")) { if (!(mu->flags & MU_HOLD)) { command_fail(si, fault_badparams, _("\2%s\2 is not held."), entity(mu)->name); return; } mu->flags &= ~MU_HOLD; wallops("%s removed the HOLD option on the account \2%s\2.", get_oper_name(si), entity(mu)->name); logcommand(si, CMDLOG_ADMIN, "HOLD:OFF: \2%s\2", entity(mu)->name); command_success_nodata(si, _("\2%s\2 is no longer held."), entity(mu)->name); } else { command_fail(si, fault_needmoreparams, STR_INVALID_PARAMS, "HOLD"); command_fail(si, fault_needmoreparams, _("Usage: HOLD <account> <ON|OFF>")); } }
static void ns_cmd_fenforce(sourceinfo_t *si, int parc, char *parv[]) { char *setting; myuser_t *mu; if (parc < 2) { command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "FENFORCE"); command_fail(si, fault_needmoreparams, _("Syntax: FENFORCE <account> ON|OFF")); return; } mu = myuser_find_ext(parv[0]); if (!mu) { command_fail(si, fault_nosuch_target, _("\2%s\2 is not registered."), parv[0]); return; } setting = parv[1]; if (strcasecmp(setting, "ON") == 0) { if (metadata_find(mu, "private:doenforce")) { command_fail(si, fault_nochange, _("The \2%s\2 flag is already set for account \2%s\2."), "ENFORCE", entity(mu)->name); } else { wallops("%s enabled ENFORCE on the account \2%s\2.", get_oper_name(si), entity(mu)->name); logcommand(si, CMDLOG_ADMIN, "FENFORCE:ON: \2%s\2", entity(mu)->name); metadata_add(mu, "private:doenforce", "1"); command_success_nodata(si, _("The \2%s\2 flag has been set for account \2%s\2."), "ENFORCE", entity(mu)->name); } } else if (strcasecmp(setting, "OFF") == 0) { if (metadata_find(mu, "private:doenforce")) { wallops("%s disabled ENFORCE on the account \2%s\2.", get_oper_name(si), entity(mu)->name); logcommand(si, CMDLOG_ADMIN, "FENFORCE:OFF: \2%s\2", entity(mu)->name); metadata_delete(mu, "private:doenforce"); command_success_nodata(si, _("The \2%s\2 flag has been removed for account \2%s\2."), "ENFORCE", entity(mu)->name); } else { command_fail(si, fault_nochange, _("The \2%s\2 flag is not set for account \2%s\2."), "ENFORCE", entity(mu)->name); } } else { command_fail(si, fault_badparams, STR_INVALID_PARAMS, "FENFORCE"); } }
static void os_cmd_restart(char *origin) { snoop("UPDATE: \2%s\2", origin); wallops("Updating database by request of \2%s\2.", origin); expire_check(NULL); db_save(NULL); logcommand(opersvs.me, user_find_named(origin), CMDLOG_ADMIN, "RESTART"); snoop("RESTART: \2%s\2", origin); wallops("Restarting by request of \2%s\2.", origin); runflags |= RF_RESTART; }
static void gs_cmd_acsnolimit(sourceinfo_t *si, int parc, char *parv[]) { mygroup_t *mg; if (!parv[0] || !parv[1]) { command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "ACSNOLIMIT"); command_fail(si, fault_needmoreparams, _("Syntax: ACSNOLIMIT <!group> <ON|OFF>")); return; } if ((mg = mygroup_find(parv[0])) == NULL) { command_fail(si, fault_nosuch_target, _("The group \2%s\2 does not exist."), parv[0]); return; } if (!strcasecmp(parv[1], "ON")) { if (mg->flags & MG_ACSNOLIMIT) { command_fail(si, fault_nochange, _("\2%s\2 can already bypass access list limits."), entity(mg)->name); return; } mg->flags |= MG_ACSNOLIMIT; wallops("%s set the ACSNOLIMIT option on the group \2%s\2.", get_oper_name(si), entity(mg)->name); logcommand(si, CMDLOG_ADMIN, "ACSNOLIMIT:ON: \2%s\2", entity(mg)->name); command_success_nodata(si, _("\2%s\2 can now bypass access list limits."), entity(mg)->name); } else if (!strcasecmp(parv[1], "OFF")) { if (!(mg->flags & MG_ACSNOLIMIT)) { command_fail(si, fault_nochange, _("\2%s\2 cannot bypass access list limits."), entity(mg)->name); return; } mg->flags &= ~MG_ACSNOLIMIT; wallops("%s removed the ACSNOLIMIT option from the group \2%s\2.", get_oper_name(si), entity(mg)->name); logcommand(si, CMDLOG_ADMIN, "ACSNOLIMIT:OFF: \2%s\2", entity(mg)->name); command_success_nodata(si, _("\2%s\2 cannot bypass access list limits anymore."), entity(mg)->name); } else { command_fail(si, fault_badparams, STR_INVALID_PARAMS, "ACSNOLIMIT"); command_fail(si, fault_badparams, _("Syntax: ACSNOLIMIT <!group> <ON|OFF>")); } }
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; }
static void opensex_db_close(database_handle_t *db) { opensex_t *rs; int errno1; char oldpath[BUFSIZE], newpath[BUFSIZE]; return_if_fail(db != NULL); rs = db->priv; mowgli_strlcpy(oldpath, db->file, sizeof oldpath); mowgli_strlcat(oldpath, ".new", sizeof oldpath); mowgli_strlcpy(newpath, db->file, sizeof newpath); fclose(rs->f); if (db->txn == DB_WRITE) { /* now, replace the old database with the new one, using an atomic rename */ if (srename(oldpath, newpath) < 0) { errno1 = errno; slog(LG_ERROR, "db_save(): cannot rename services.db.new to services.db: %s", strerror(errno1)); wallops(_("\2DATABASE ERROR\2: db_save(): cannot rename services.db.new to services.db: %s"), strerror(errno1)); } hook_call_db_saved(); } free(rs->buf); free(rs); free(db->file); free(db); }
static void gs_cmd_fdrop(sourceinfo_t *si, int parc, char *parv[]) { mygroup_t *mg; char *name = parv[0]; if (!name) { command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "DROP"); command_fail(si, fault_needmoreparams, _("Syntax: DROP <!group>")); return; } if (*name != '!') { command_fail(si, fault_badparams, STR_INVALID_PARAMS, "DROP"); command_fail(si, fault_badparams, _("Syntax: DROP <!group>")); return; } if (!(mg = mygroup_find(name))) { command_fail(si, fault_nosuch_target, _("Group \2%s\2 does not exist."), name); return; } remove_group_chanacs(mg); hook_call_group_drop(mg); logcommand(si, CMDLOG_ADMIN | LG_REGISTER, "FDROP: \2%s\2", entity(mg)->name); wallops("%s dropped the group \2%s\2", get_oper_name(si), name); command_success_nodata(si, _("The group \2%s\2 has been dropped."), entity(mg)->name); object_unref(mg); return; }
static void os_cmd_mode(sourceinfo_t *si, int parc, char *parv[]) { char *channel = parv[0]; char *mode = parv[1]; channel_t *c; int modeparc; char *modeparv[256]; if (!channel || !mode) { command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "MODE"); command_fail(si, fault_needmoreparams, _("Syntax: MODE <channel> <parameters>")); return; } c = channel_find(channel); if (!c) { command_fail(si, fault_nosuch_target, _("Channel \2%s\2 does not exist."), channel); return; } wallops("\2%s\2 is using MODE on \2%s\2 (set: \2%s\2)", get_oper_name(si), channel, mode); logcommand(si, CMDLOG_ADMIN, "MODE: \2%s\2 on \2%s\2", mode, channel); modeparc = sjtoken(mode, ' ', modeparv); channel_mode(si->service->me, c, modeparc, modeparv); command_success_nodata(si, _("Set modes \2%s\2 on \2%s\2."), mode, channel); }
static void connavg_newuser(hook_user_nick_t *data) { user_t *u = data->u; /* If the user has been killed, don't do anything. */ if (!(u)) return; /* If the user is an internal client, still don't do anything. */ if (is_internal_client(u)) return; /* Most likely, we will have a massive influx in connections when bursts happen; skip those. */ if (me.bursting) return; s.connections++; if (s.connections > safe_connections) { /* Send a warning every five connects greater than the "safe" connection allowence. */ if (s.connections % 5 == 0) { wallops("WARNING! Connections in the last minute was %d, which is above the maxium safe connections of %d per minute!", s.connections, safe_connections); s.alert_time = time(NULL); } } if (s.connections > s.peak_conn) { s.peak_conn = s.connections; s.peak_time = time(NULL); } }
static void check_hidehost(user_t *u) { static bool warned = false; /* do they qualify? */ if (!(u->flags & UF_HIDEHOSTREQ) || u->myuser == NULL || (u->myuser->flags & MU_WAITAUTH)) return; /* don't use this if they have some other kind of vhost */ if (strcmp(u->host, u->vhost)) { slog(LG_DEBUG, "check_hidehost(): +x overruled by other vhost for %s", u->nick); return; } if (me.hidehostsuffix == NULL) { if (!warned) { wallops("Misconfiguration: serverinfo::hidehostsuffix not set"); warned = true; } return; } snprintf(u->vhost, sizeof u->vhost, "%s.%s", u->myuser->name, me.hidehostsuffix); slog(LG_DEBUG, "check_hidehost(): %s -> %s", u->nick, u->vhost); }
/* REHASH */ void os_cmd_rehash(sourceinfo_t *si, int parc, char *parv[]) { slog(LG_INFO, "UPDATE (due to REHASH): \2%s\2", get_oper_name(si)); wallops("Updating database by request of \2%s\2.", get_oper_name(si)); expire_check(NULL); if (db_save) db_save(NULL, DB_SAVE_BG_IMPORTANT); logcommand(si, CMDLOG_ADMIN, "REHASH"); wallops("Rehashing \2%s\2 by request of \2%s\2.", config_file, get_oper_name(si)); if (conf_rehash()) command_success_nodata(si, _("REHASH completed.")); else command_fail(si, fault_nosuch_target, _("REHASH of \2%s\2 failed. Please correct any errors in the file and try again."), config_file); }
static void os_cmd_shutdown(sourceinfo_t *si, int parc, char *parv[]) { logcommand(si, CMDLOG_ADMIN, "SHUTDOWN"); wallops("Shutting down by request of \2%s\2.", get_oper_name(si)); runflags |= RF_SHUTDOWN; }
static void do_os_kick(User * u) { char *argv[3]; char *chan, *nick, *s; Channel *c; chan = strtok(NULL, " "); nick = strtok(NULL, " "); s = strtok(NULL, ""); if (!chan || !nick || !s) { syntax_error(s_OperServ, u, "KICK", OPER_KICK_SYNTAX); return; } 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; } send_cmd(s_OperServ, "KICK %s %s :%s (%s)", chan, nick, u->nick, s); if (WallOSKick) { wallops(s_OperServ, "%s used KICK on %s/%s", u->nick, nick, chan); } argv[0] = sstrdup(chan); argv[1] = sstrdup(nick); argv[2] = sstrdup(s); do_kick(s_OperServ, 3, argv); free(argv[2]); free(argv[1]); free(argv[0]); }
static void os_cmd_restart(struct sourceinfo *si, int parc, char *parv[]) { logcommand(si, CMDLOG_ADMIN, "RESTART"); wallops("Restarting by request of \2%s\2.", get_oper_name(si)); runflags |= RF_RESTART; }
static void cs_cmd_drop(char *origin) { user_t *u = user_find_named(origin); mychan_t *mc; char *name = strtok(NULL, " "); if (!name) { notice(chansvs.nick, origin, STR_INSUFFICIENT_PARAMS, "DROP"); notice(chansvs.nick, origin, "Syntax: DROP <#channel>"); return; } if (*name != '#') { notice(chansvs.nick, origin, STR_INVALID_PARAMS, "DROP"); notice(chansvs.nick, origin, "Syntax: DROP <#channel>"); return; } if (!(mc = mychan_find(name))) { notice(chansvs.nick, origin, "\2%s\2 is not registered.", name); return; } if (!is_founder(mc, u->myuser) && !has_priv(u, PRIV_CHAN_ADMIN)) { notice(chansvs.nick, origin, "You are not authorized to perform this operation."); return; } if (metadata_find(mc, METADATA_CHANNEL, "private:close:closer") && !has_priv(u, PRIV_CHAN_ADMIN)) { logcommand(chansvs.me, u, CMDLOG_REGISTER, "%s failed DROP (closed)", mc->name); notice(chansvs.nick, origin, "The channel \2%s\2 is closed; it cannot be dropped.", mc->name); return; } if (!is_founder(mc, u->myuser)) { logcommand(chansvs.me, u, CMDLOG_ADMIN, "%s DROP", mc->name); wallops("%s dropped the channel \2%s\2", origin, name); } else logcommand(chansvs.me, u, CMDLOG_REGISTER, "%s DROP", mc->name); snoop("DROP: \2%s\2 by \2%s\2 as \2%s\2", mc->name, u->nick, u->myuser->name); hook_call_event("channel_drop", mc); if ((config_options.chan && irccasecmp(mc->name, config_options.chan)) || !config_options.chan) part(mc->name, chansvs.nick); mychan_delete(mc->name); notice(chansvs.nick, origin, "The channel \2%s\2 has been dropped.", name); return; }
void os_cmd_update(sourceinfo_t *si, int parc, char *parv[]) { logcommand(si, CMDLOG_ADMIN, "UPDATE"); wallops("Updating database by request of \2%s\2.", get_oper_name(si)); expire_check(NULL); if (db_save) db_save(NULL); /* db_save() will wallops/snoop/log the error */ command_success_nodata(si, _("UPDATE completed.")); }
static void do_killclones(User * u) { char killreason[NICKMAX + 32]; char akillreason[] = "Temporary KILLCLONES akill."; int count; char *clonenick, *clonemask, *akillmask; User *cloneuser, *user, *tempuser; clonenick = strtok(NULL, " "); count = 0; if (!clonenick) { notice_lang(s_OperServ, u, OPER_KILLCLONES_SYNTAX); } else if (!(cloneuser = finduser(clonenick))) { notice_lang(s_OperServ, u, OPER_KILLCLONES_UNKNOWN_NICK, clonenick); } else { clonemask = smalloc(strlen(cloneuser->host) + 5); sprintf(clonemask, "*!*@%s", cloneuser->host); akillmask = smalloc(strlen(cloneuser->host) + 3); sprintf(akillmask, "*@%s", strlower(cloneuser->host)); user = firstuser(); while (user) { if (match_usermask(clonemask, user) != 0) { tempuser = nextuser(); count++; snprintf(killreason, sizeof(killreason), "Cloning [%d]", count); kill_user(NULL, user->nick, killreason); user = tempuser; } else { user = nextuser(); } } add_akill(akillmask, akillreason, u->nick, time(NULL) + (60 * 60 * 6)); wallops(s_OperServ, "\2%s\2 used KILLCLONES for \2%s\2 " "killing \2%d\2 clones. A temporary AKILL has been " "added for \2%s\2.", u->nick, clonemask, count, akillmask); log("%s: KILLCLONES: %d clone(s) matching %s killed.", s_OperServ, count, clonemask); free(akillmask); free(clonemask); } }
static void do_jupe(User * u) { char buf[NICKMAX + 16]; char *jserver, *reason; jserver = strtok(NULL, " "); reason = strtok(NULL, ""); if (!jserver) { syntax_error(s_OperServ, u, "JUPE", OPER_JUPE_SYNTAX); } else if (strchr(jserver, '.')) { /* Juping a server, squit the target first. */ send_cmd(NULL, ":OperServ SQUIT %s :Server jupitered by %s (%s)", jserver, u->nick, reason ? reason : u->nick); /* I can't get it to work without this sleep here :/ */ sleep(1); wallops(s_OperServ, "\2Juping\2 %s by request of \2%s\2 (%s).", jserver, u->nick, reason ? reason : u->nick); if (!reason) { snprintf(buf, sizeof(buf), "Jupitered by %s", u->nick); reason = buf; } send_cmd(NULL, "SERVER %s 2 :%s", jserver, reason); } else { /* Juping a nick. */ wallops(s_OperServ, "\2Juping\2 %s by request of \2%s\2 (%s).", jserver, u->nick, reason ? reason : u->nick); send_cmd(NULL, "KILL %s :Juped by %s: %s", jserver, u->nick, reason ? reason : u->nick); snprintf(buf, sizeof(buf), "Juped (%s)", reason ? reason : u->nick); send_nick(jserver, ServiceUser, ServiceHost, ServerName, buf); } }
static void helpserv_cmd_helpme(sourceinfo_t *si, int parc, char *parv[]) { char *topic = parv[0]; if ((unsigned int)(CURRTIME - ratelimit_firsttime) > config_options.ratelimit_period) ratelimit_count = 0, ratelimit_firsttime = CURRTIME; if (ratelimit_count > config_options.ratelimit_uses && !has_priv(si, PRIV_FLOOD)) { command_fail(si, fault_toomany, _("The system is currently too busy to process your help request, please try again later.")); slog(LG_INFO, "HELPME:THROTTLED: %s", si->su->nick); return; } if (si->smu != NULL && metadata_find(si->smu, "private:restrict:setter")) { command_fail(si, fault_noprivs, _("You have been restricted from requesting help by network staff.")); return; } command_add_flood(si, FLOOD_HEAVY); if (topic) { logcommand(si, CMDLOG_ADMIN, "HELPME: \2%s\2", topic); wallops("\2%s\2 has requested help about \2%s\2", get_source_name(si), topic); } else { logcommand(si, CMDLOG_ADMIN, "HELPME"); wallops("\2%s\2 has requested help.", get_source_name(si)); } command_success_nodata(si, "The network staff has been notified that you need help and will be with you shortly."); if (config_options.ratelimit_uses && config_options.ratelimit_period) ratelimit_count++; return; }
void os_cmd_update(struct sourceinfo *si, int parc, char *parv[]) { logcommand(si, CMDLOG_ADMIN, "UPDATE"); wallops("Updating database by request of \2%s\2.", get_oper_name(si)); expire_check(NULL); command_success_nodata(si, _("Updating database.")); if (db_save) db_save(NULL, DB_SAVE_BG_IMPORTANT); // db_save() will wallops/snoop/log the error }
static void cs_cmd_fdrop(sourceinfo_t *si, int parc, char *parv[]) { mychan_t *mc; char *name = parv[0]; if (!name) { command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "FDROP"); command_fail(si, fault_needmoreparams, _("Syntax: FDROP <#channel>")); return; } if (*name != '#') { command_fail(si, fault_badparams, STR_INVALID_PARAMS, "FDROP"); command_fail(si, fault_badparams, _("Syntax: FDROP <#channel>")); return; } if (!(mc = mychan_find(name))) { command_fail(si, fault_nosuch_target, _("Channel \2%s\2 is not registered."), name); return; } if (si->c != NULL) { command_fail(si, fault_noprivs, _("For security reasons, you may not drop a channel registration with a fantasy command.")); return; } if (mc->flags & MC_HOLD) { command_fail(si, fault_noprivs, _("The channel \2%s\2 is held; it cannot be dropped."), mc->name); return; } logcommand(si, CMDLOG_ADMIN | LG_REGISTER, "FDROP: \2%s\2", mc->name); wallops("%s dropped the channel \2%s\2", get_oper_name(si), name); verbose(mc, _("The channel has been dropped by %s administration"), me.netname); hook_call_channel_drop(mc); if (mc->chan != NULL && !(mc->chan->flags & CHAN_LOG)) part(mc->name, chansvs.nick); object_unref(mc); command_success_nodata(si, _("The channel \2%s\2 has been dropped."), name); return; }
static void ns_cmd_fdrop(sourceinfo_t *si, int parc, char *parv[]) { myuser_t *mu; mynick_t *mn; char *acc = parv[0]; if (!acc) { command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "FDROP"); command_fail(si, fault_needmoreparams, _("Syntax: FDROP <account>")); return; } if (!(mu = myuser_find(acc))) { if (!nicksvs.no_nick_ownership) { mn = mynick_find(acc); if (mn != NULL && command_find(si->service->cmdtree, "FUNGROUP")) { command_fail(si, fault_nosuch_target, _("\2%s\2 is a grouped nick, use %s to remove it."), acc, "FUNGROUP"); return; } } command_fail(si, fault_nosuch_target, _("\2%s\2 is not registered."), acc); return; } if (is_soper(mu)) { command_fail(si, fault_noprivs, _("The nickname \2%s\2 belongs to a services operator; it cannot be dropped."), acc); return; } if (mu->flags & MU_HOLD) { command_fail(si, fault_noprivs, _("The account \2%s\2 is held; it cannot be dropped."), acc); return; } wallops("%s dropped the account \2%s\2", get_oper_name(si), mu->name); snoop("FDROP: \2%s\2 by \2%s\2", mu->name, get_oper_name(si)); logcommand(si, CMDLOG_ADMIN | LG_REGISTER, "FDROP %s", mu->name); hook_call_user_drop(mu); command_success_nodata(si, _("The account \2%s\2 has been dropped."), mu->name); object_unref(mu); }
static void do_os_mode(User * u) { int argc; char **argv; char *chan, *modes, *s; Channel *c; s = strtok(NULL, ""); if (!s) { syntax_error(s_OperServ, u, "MODE", OPER_MODE_SYNTAX); return; } chan = s; s += strcspn(s, " "); if (!*s) { syntax_error(s_OperServ, u, "MODE", OPER_MODE_SYNTAX); return; } *s = 0; modes = (s + 1) + strspn(s + 1, " "); if (!*modes) { syntax_error(s_OperServ, u, "MODE", OPER_MODE_SYNTAX); return; } 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; } else { send_cmd(s_OperServ, "MODE %s %s", chan, modes); if (WallOSMode) { wallops(s_OperServ, "%s used MODE %s on %s", u->nick, modes, chan); } *s = ' '; argc = split_buf(chan, &argv, 1); do_cmode(s_OperServ, argc, argv); } }
static database_handle_t *opensex_db_open_read(const char *filename) { database_handle_t *db; opensex_t *rs; FILE *f; int errno1; char path[BUFSIZE]; snprintf(path, BUFSIZE, "%s/%s", datadir, filename != NULL ? filename : "services.db"); f = fopen(path, "r"); if (!f) { errno1 = errno; /* ENOENT can happen if the database does not exist yet. */ if (errno == ENOENT) { slog(LG_ERROR, "db-open-read: database '%s' does not yet exist; a new one will be created.", path); return NULL; } slog(LG_ERROR, "db-open-read: cannot open '%s' for reading: %s", path, strerror(errno1)); wallops(_("\2DATABASE ERROR\2: db-open-read: cannot open '%s' for reading: %s"), path, strerror(errno1)); return NULL; } rs = scalloc(sizeof(opensex_t), 1); rs->grver = 1; rs->buf = scalloc(512, 1); rs->bufsize = 512; rs->token = NULL; rs->f = f; db = scalloc(sizeof(database_handle_t), 1); db->priv = rs; db->vt = &opensex_vt; db->txn = DB_READ; db->file = sstrdup(path); db->line = 0; db->token = 0; return db; }
static void os_cmd_jupe(sourceinfo_t *si, int parc, char *parv[]) { char *server = parv[0]; char *reason = parv[1]; char reasonbuf[BUFSIZE]; if (!server || !reason) { command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "JUPE"); command_fail(si, fault_needmoreparams, _("Usage: JUPE <server> <reason>")); return; } /* Disallow * in a jupe as a minimal sanity check; it makes it hard to * squit safely. */ if (!strchr(server, '.') || strchr(server, '*') || strchr(server, '?')) { command_fail(si, fault_badparams, _("\2%s\2 is not a valid server name."), server); return; } if (!irccasecmp(server, me.name)) { command_fail(si, fault_noprivs, _("\2%s\2 is the services server; it cannot be jupitered!"), server); return; } if (!irccasecmp(server, me.actual)) { command_fail(si, fault_noprivs, _("\2%s\2 is the current uplink; it cannot be jupitered!"), server); return; } logcommand(si, CMDLOG_ADMIN, "JUPE: \2%s\2 (reason: \2%s\2)", server, reason); wallops(_("%s jupitered server \2%s\2 (%s)."), get_oper_name(si), server, reason); snprintf(reasonbuf, BUFSIZE, "[%s] %s", get_oper_name(si), reason); jupe(server, reasonbuf); command_success_nodata(si, _("\2%s\2 has been jupitered."), server); }
static database_handle_t *opensex_db_open_write(const char *filename) { database_handle_t *db; opensex_t *rs; int fd; FILE *f; int errno1; char bpath[BUFSIZE], path[BUFSIZE]; snprintf(bpath, BUFSIZE, "%s/%s", datadir, filename != NULL ? filename : "services.db"); mowgli_strlcpy(path, bpath, sizeof path); mowgli_strlcat(path, ".new", sizeof path); fd = open(path, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); if (fd < 0 || ! (f = fdopen(fd, "w"))) { errno1 = errno; slog(LG_ERROR, "db-open-write: cannot open '%s' for writing: %s", path, strerror(errno1)); wallops(_("\2DATABASE ERROR\2: db-open-write: cannot open '%s' for writing: %s"), path, strerror(errno1)); return NULL; } rs = scalloc(sizeof(opensex_t), 1); rs->f = f; rs->grver = 1; db = scalloc(sizeof(database_handle_t), 1); db->priv = rs; db->vt = &opensex_vt; db->txn = DB_WRITE; db->file = sstrdup(bpath); db->line = 0; db->token = 0; db_start_row(db, "GRVER"); db_write_int(db, rs->grver); db_commit_row(db); return db; }