static void cs_fcmd_topicappend(char *origin, char *chan) { char *topic = strtok(NULL, ""); mychan_t *mc; user_t *u = user_find_named(origin); char topicbuf[BUFSIZE]; channel_t *c; if (!topic) { notice(chansvs.nick, origin, STR_INSUFFICIENT_PARAMS, "!TOPICAPPEND"); notice(chansvs.nick, origin, "Syntax: !TOPICAPPEND <topic>"); return; } c = channel_find(chan); if (!c) { notice(chansvs.nick, origin, "\2%s\2 is not registered.", chan); return; } mc = mychan_find(chan); if (!mc) { notice(chansvs.nick, origin, "Channel \2%s\2 is not registered.", chan); return; } if (!chanacs_user_has_flag(mc, u, CA_TOPIC)) { notice(chansvs.nick, origin, "You are not authorized to perform this operation."); return; } if (metadata_find(mc, METADATA_CHANNEL, "private:close:closer")) { notice(chansvs.nick, origin, "\2%s\2 is closed.", chan); return; } topicbuf[0] = '\0'; if (c->topic) { strlcpy(topicbuf, c->topic, BUFSIZE); strlcat(topicbuf, " | ", BUFSIZE); strlcat(topicbuf, topic, BUFSIZE); } else strlcpy(topicbuf, topic, BUFSIZE); handle_topic(c, origin, CURRTIME, topicbuf); topic_sts(chan, origin, CURRTIME, topicbuf); logcommand(chansvs.me, u, CMDLOG_SET, "%s TOPICAPPEND", mc->name); }
static void cs_cmd_topic(char *origin) { char *chan = strtok(NULL, " "); char *topic = strtok(NULL, ""); mychan_t *mc; channel_t *c; user_t *u; if (!chan || !topic) { notice(chansvs.nick, origin, STR_INSUFFICIENT_PARAMS, "TOPIC"); notice(chansvs.nick, origin, "Syntax: TOPIC <#channel> <topic>"); return; } c = channel_find(chan); if (!c) { notice(chansvs.nick, origin, "\2%s\2 is not registered.", chan); return; } mc = mychan_find(chan); if (!mc) { notice(chansvs.nick, origin, "Channel \2%s\2 is not registered.", chan); return; } if (metadata_find(mc, METADATA_CHANNEL, "private:close:closer")) { notice(chansvs.nick, origin, "\2%s\2 is closed.", chan); return; } u = user_find_named(origin); if (!chanacs_user_has_flag(mc, u, CA_TOPIC)) { notice(chansvs.nick, origin, "You are not authorized to perform this operation."); return; } handle_topic(c, origin, CURRTIME, topic); topic_sts(chan, origin, CURRTIME, topic); logcommand(chansvs.me, u, CMDLOG_SET, "%s TOPIC", mc->name); if (!chanuser_find(c, u)) notice(chansvs.nick, origin, "Topic set to \2%s\2 on \2%s\2.", topic, chan); }
static void cs_cmd_owner(sourceinfo_t *si, int parc, char *parv[]) { char *chan = parv[0]; char *nick = parv[1]; mychan_t *mc; user_t *tu; chanuser_t *cu; char *nicklist; char *strtokctx; if (ircd->uses_owner == false) { command_fail(si, fault_noprivs, _("The IRCd software you are running does not support this feature.")); return; } if (!chan) { command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "OWNER"); command_fail(si, fault_needmoreparams, _("Syntax: OWNER <#channel> [nickname] [...]")); return; } mc = mychan_find(chan); if (!mc) { command_fail(si, fault_nosuch_target, _("Channel \2%s\2 is not registered."), chan); return; } if (!chanacs_source_has_flag(mc, si, CA_USEOWNER)) { command_fail(si, fault_noprivs, _("You are not authorized to perform this operation.")); return; } if (metadata_find(mc, "private:close:closer")) { command_fail(si, fault_noprivs, _("\2%s\2 is closed."), chan); return; } nicklist = (!nick ? strdup(si->su->nick) : strdup(nick)); nick = strtok_r(nicklist, " ", &strtokctx); do { if (invert_purpose(si, parc, chan, &nick, '-', &cs_cmd_deowner)) continue; /* figure out who we're going to op */ if (!(tu = user_find_named(nick))) { command_fail(si, fault_nosuch_target, _("\2%s\2 is not online."), nick); continue; } if (is_internal_client(tu)) continue; /* SECURE check; we can skip this if sender == target, because we already verified */ if ((si->su != tu) && (mc->flags & MC_SECURE) && !chanacs_user_has_flag(mc, tu, CA_OP) && !chanacs_user_has_flag(mc, tu, CA_AUTOOP)) { command_fail(si, fault_noprivs, _("You are not authorized to perform this operation.")); command_fail(si, fault_noprivs, _("\2%s\2 has the SECURE option enabled, and \2%s\2 does not have appropriate access."), mc->name, tu->nick); continue; } cu = chanuser_find(mc->chan, tu); if (!cu) { command_fail(si, fault_nosuch_target, _("\2%s\2 is not on \2%s\2."), tu->nick, mc->name); continue; } modestack_mode_param(chansvs.nick, mc->chan, MTYPE_ADD, ircd->owner_mchar[1], CLIENT_NAME(tu)); cu->modes |= CSTATUS_OWNER; if (si->c == NULL && tu != si->su) change_notify(chansvs.nick, tu, "You have been set as owner on %s by %s", mc->name, get_source_name(si)); logcommand(si, CMDLOG_DO, "OWNER: \2%s!%s@%s\2 on \2%s\2", tu->nick, tu->user, tu->vhost, mc->name); if (si->su == NULL || !chanuser_find(mc->chan, si->su)) command_success_nodata(si, _("\2%s\2 has been set as owner on \2%s\2."), tu->nick, mc->name); } while ((nick = strtok_r(NULL, " ", &strtokctx)) != NULL); free(nicklist); }
static void cs_cmd_halfop(sourceinfo_t *si, int parc, char *parv[]) { char *chan = parv[0]; char *nick = parv[1]; mychan_t *mc; user_t *tu; chanuser_t *cu; if (!ircd->uses_halfops) { command_fail(si, fault_noprivs, _("Your IRC server does not support halfops.")); return; } if (!chan) { command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "HALFOP"); command_fail(si, fault_needmoreparams, _("Syntax: HALFOP <#channel> [nickname]")); return; } mc = mychan_find(chan); if (!mc) { command_fail(si, fault_nosuch_target, _("Channel \2%s\2 is not registered."), chan); return; } if (!chanacs_source_has_flag(mc, si, CA_HALFOP)) { command_fail(si, fault_noprivs, _("You are not authorized to perform this operation.")); return; } if (metadata_find(mc, "private:close:closer")) { command_fail(si, fault_noprivs, _("\2%s\2 is closed."), chan); return; } /* figure out who we're going to halfop */ if (!nick) tu = si->su; else { if (!(tu = user_find_named(nick))) { command_fail(si, fault_nosuch_target, _("\2%s\2 is not online."), nick); return; } } if (is_internal_client(tu)) return; /* SECURE check; we can skip this if sender == target, because we already verified */ if ((si->su != tu) && (mc->flags & MC_SECURE) && !chanacs_user_has_flag(mc, tu, CA_HALFOP) && !chanacs_user_has_flag(mc, tu, CA_AUTOHALFOP)) { command_fail(si, fault_noprivs, _("You are not authorized to perform this operation.")); command_fail(si, fault_noprivs, _("\2%s\2 has the SECURE option enabled, and \2%s\2 does not have appropriate access."), mc->name, tu->nick); return; } cu = chanuser_find(mc->chan, tu); if (!cu) { command_fail(si, fault_nosuch_target, _("\2%s\2 is not on \2%s\2."), tu->nick, mc->name); return; } modestack_mode_param(chansvs.nick, mc->chan, MTYPE_ADD, 'h', CLIENT_NAME(tu)); cu->modes |= ircd->halfops_mode; if (si->c == NULL && tu != si->su) change_notify(chansvs.nick, tu, "You have been halfopped on %s by %s", mc->name, get_source_name(si)); logcommand(si, CMDLOG_DO, "HALFOP: \2%s!%s@%s\2 on \2%s\2", tu->nick, tu->user, tu->vhost, mc->name); if (!chanuser_find(mc->chan, si->su)) command_success_nodata(si, _("\2%s\2 has been halfopped on \2%s\2."), tu->nick, mc->name); }
static void cs_cmd_halfop(char *origin) { char *chan = strtok(NULL, " "); char *nick = strtok(NULL, " "); mychan_t *mc; user_t *u, *tu; chanuser_t *cu; if (!ircd->uses_halfops) { notice(chansvs.nick, origin, "Your IRC server does not support halfops."); return; } if (!chan) { notice(chansvs.nick, origin, STR_INSUFFICIENT_PARAMS, "HALFOP"); notice(chansvs.nick, origin, "Syntax: HALFOP <#channel> [nickname]"); return; } mc = mychan_find(chan); if (!mc) { notice(chansvs.nick, origin, "\2%s\2 is not registered.", chan); return; } u = user_find_named(origin); if (!chanacs_user_has_flag(mc, u, CA_HALFOP)) { notice(chansvs.nick, origin, "You are not authorized to perform this operation."); return; } if (metadata_find(mc, METADATA_CHANNEL, "private:close:closer")) { notice(chansvs.nick, origin, "\2%s\2 is closed.", chan); return; } /* figure out who we're going to halfop */ if (!nick) tu = u; else { if (!(tu = user_find_named(nick))) { notice(chansvs.nick, origin, "\2%s\2 is not online.", nick); return; } } if (is_internal_client(tu)) return; /* SECURE check; we can skip this if sender == target, because we already verified */ if ((u != tu) && (mc->flags & MC_SECURE) && !chanacs_user_has_flag(mc, tu, CA_HALFOP) && !chanacs_user_has_flag(mc, tu, CA_AUTOHALFOP)) { notice(chansvs.nick, origin, "You are not authorized to perform this operation.", mc->name); notice(chansvs.nick, origin, "\2%s\2 has the SECURE option enabled, and \2%s\2 does not have appropriate access.", mc->name, tu->nick); return; } cu = chanuser_find(mc->chan, tu); if (!cu) { notice(chansvs.nick, origin, "\2%s\2 is not on \2%s\2.", tu->nick, mc->name); return; } modestack_mode_param(chansvs.nick, chan, MTYPE_ADD, 'h', CLIENT_NAME(tu)); cu->modes |= ircd->halfops_mode; /* TODO: Add which username had access to perform the command */ if (tu != u) notice(chansvs.nick, tu->nick, "You have been halfopped on %s by %s", mc->name, origin); logcommand(chansvs.me, u, CMDLOG_SET, "%s HALFOP %s!%s@%s", mc->name, tu->nick, tu->user, tu->vhost); if (!chanuser_find(mc->chan, u)) notice(chansvs.nick, origin, "\2%s\2 has been halfopped on \2%s\2.", tu->nick, mc->name); }
static void cs_fcmd_dehalfop(char *origin, char *chan) { char *nick; mychan_t *mc; user_t *u, *tu; chanuser_t *cu; if (!ircd->uses_halfops) { notice(chansvs.nick, origin, "Your IRC server does not support halfops."); return; } mc = mychan_find(chan); if (!mc) { notice(chansvs.nick, origin, "\2%s\2 is not registered.", chan); return; } u = user_find_named(origin); if (!chanacs_user_has_flag(mc, u, CA_HALFOP)) { notice(chansvs.nick, origin, "You are not authorized to perform this operation."); return; } if (metadata_find(mc, METADATA_CHANNEL, "private:close:closer")) { notice(chansvs.nick, origin, "\2%s\2 is closed.", chan); return; } /* figure out who we're going to dehalfop */ nick = strtok(NULL, " "); do { if (!nick) tu = u; else { if (!(tu = user_find_named(nick))) { notice(chansvs.nick, origin, "\2%s\2 is not online.", nick); continue; } } if (is_internal_client(tu)) continue; cu = chanuser_find(mc->chan, tu); if (!cu) { notice(chansvs.nick, origin, "\2%s\2 is not on \2%s\2.", tu->nick, mc->name); continue; } modestack_mode_param(chansvs.nick, chan, MTYPE_DEL, 'h', CLIENT_NAME(tu)); cu->modes &= ~ircd->halfops_mode; logcommand(chansvs.me, u, CMDLOG_SET, "%s DEHALFOP %s!%s@%s", mc->name, tu->nick, tu->user, tu->vhost); } while ((nick = strtok(NULL, " ")) != NULL); }