X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=ircd%2Fm_clearmode.c;h=81392da469942342c67b2c07f85302629874fd7f;hb=refs%2Fheads%2Fupstream;hp=360c314bc4cdb292544f0d35b5496e520e77dfdc;hpb=0cb687e356712d44c85313ce872ec13fb56483b2;p=ircu2.10.12-pk.git diff --git a/ircd/m_clearmode.c b/ircd/m_clearmode.c index 360c314..81392da 100644 --- a/ircd/m_clearmode.c +++ b/ircd/m_clearmode.c @@ -1,5 +1,5 @@ /* - * IRC - Internet Relay Chat, ircd/m_tmpl.c + * IRC - Internet Relay Chat, ircd/m_clearmode.c * Copyright (C) 1990 Jarkko Oikarinen and * University of Oulu, Computing Center * Copyright (C) 2000 Kevin L. Mitchell @@ -80,28 +80,25 @@ * note: it is guaranteed that parv[0]..parv[parc-1] are all * non-NULL pointers. */ -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ +#include "config.h" + #include "client.h" #include "channel.h" #include "hash.h" #include "ircd.h" #include "ircd_alloc.h" +#include "ircd_features.h" +#include "ircd_log.h" #include "ircd_reply.h" #include "ircd_string.h" #include "list.h" #include "msg.h" #include "numeric.h" #include "numnicks.h" +#include "s_conf.h" #include "send.h" -#include +/* #include -- Now using assert in ircd_log.h */ /* * do_clearmode(struct Client *cptr, struct Client *sptr, @@ -125,6 +122,8 @@ do_clearmode(struct Client *cptr, struct Client *sptr, struct Channel *chptr, MODE_KEY, 'k', MODE_BAN, 'b', MODE_LIMIT, 'l', + MODE_REGONLY, 'r', + MODE_DELJOINS, 'D', 0x0, 0x0 }; int *flag_p; @@ -132,13 +131,9 @@ do_clearmode(struct Client *cptr, struct Client *sptr, struct Channel *chptr, char control_buf[20]; int control_buf_i = 0; struct ModeBuf mbuf; - struct SLink *link, *next; + struct Ban *link, *next; struct Membership *member; - /* Um...yeah, like it's supposed to have any modes at all. */ - if (IsModelessChannel(chptr->chname)) - return 0; - /* Ok, so what are we supposed to get rid of? */ for (; *control; control++) { for (flag_p = flags; flag_p[0]; flag_p += 2) @@ -167,11 +162,11 @@ do_clearmode(struct Client *cptr, struct Client *sptr, struct Channel *chptr, * If we're removing the key, note that; note that we can't clear * the key until after modebuf_* are done with it */ - if (del_mode & MODE_KEY && chptr->mode.mode & MODE_KEY) - modebuf_mode_string(&mbuf, MODE_DEL | MODE_KEY, chptr->mode.key); + if (del_mode & MODE_KEY && *chptr->mode.key) + modebuf_mode_string(&mbuf, MODE_DEL | MODE_KEY, chptr->mode.key, 0); /* If we're removing the limit, note that and clear the limit */ - if (del_mode & MODE_LIMIT && chptr->mode.mode & MODE_KEY) { + if (del_mode & MODE_LIMIT && chptr->mode.limit) { modebuf_mode_uint(&mbuf, MODE_DEL | MODE_LIMIT, chptr->mode.limit); chptr->mode.limit = 0; /* not referenced, so safe */ } @@ -180,9 +175,19 @@ do_clearmode(struct Client *cptr, struct Client *sptr, struct Channel *chptr, * Go through and mark the bans for deletion; note that we can't * free them until after modebuf_* are done with them */ - if (del_mode & MODE_BAN) - for (link = chptr->banlist; link; link = link->next) - modebuf_mode_string(&mbuf, MODE_DEL | MODE_BAN, link->value.ban.banstr); + if (del_mode & MODE_BAN) { + for (link = chptr->banlist; link; link = next) { + char *bandup; + next = link->next; + + DupString(bandup, link->banstr); + modebuf_mode_string(&mbuf, MODE_DEL | MODE_BAN, /* delete ban */ + bandup, 1); + free_ban(link); + } + + chptr->banlist = 0; + } /* Deal with users on the channel */ if (del_mode & (MODE_BAN | MODE_CHANOP | MODE_VOICE)) @@ -195,13 +200,13 @@ do_clearmode(struct Client *cptr, struct Client *sptr, struct Channel *chptr, /* Drop channel operator status */ if (IsChanOp(member) && del_mode & MODE_CHANOP) { - modebuf_mode_client(&mbuf, MODE_DEL | MODE_CHANOP, member->user); + modebuf_mode_client(&mbuf, MODE_DEL | MODE_CHANOP, member->user, MAXOPLEVEL + 1); member->status &= ~CHFL_CHANOP; } /* Drop voice */ if (HasVoice(member) && del_mode & MODE_VOICE) { - modebuf_mode_client(&mbuf, MODE_DEL | MODE_VOICE, member->user); + modebuf_mode_client(&mbuf, MODE_DEL | MODE_VOICE, member->user, MAXOPLEVEL + 1); member->status &= ~CHFL_VOICE; } } @@ -213,23 +218,6 @@ do_clearmode(struct Client *cptr, struct Client *sptr, struct Channel *chptr, if (del_mode & MODE_KEY) chptr->mode.key[0] = '\0'; - /* and free the bans */ - if (del_mode & MODE_BAN) { - for (link = chptr->banlist; link; link = next) { - next = link->next; - - MyFree(link->value.ban.banstr); - MyFree(link->value.ban.who); - free_link(link); - } - - chptr->banlist = 0; - } - - /* Don't propagate CLEARMODE if it's a local channel */ - if (IsLocalChannel(chptr->chname)) - return 0; - /* Ok, build control string again */ for (flag_p = flags; flag_p[0]; flag_p += 2) if (del_mode & flag_p[0]) @@ -237,13 +225,14 @@ do_clearmode(struct Client *cptr, struct Client *sptr, struct Channel *chptr, control_buf[control_buf_i] = '\0'; + /* Log it... */ + log_write(LS_OPERMODE, L_INFO, LOG_NOSNOTICE, "%#C CLEARMODE %H %s", sptr, + chptr, control_buf); + /* Then send it */ - if (IsServer(sptr)) - sendto_serv_butone(cptr, "%s " TOK_CLEARMODE " %s %s", NumServ(sptr), - chptr->chname, control_buf); - else - sendto_serv_butone(cptr, "%s%s " TOK_CLEARMODE " %s %s", NumNick(sptr), - chptr->chname, control_buf); + if (!IsLocalChannel(chptr->chname)) + sendcmdto_serv_butone(sptr, CMD_CLEARMODE, cptr, "%H %s", chptr, + control_buf); return 0; } @@ -263,12 +252,14 @@ ms_clearmode(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) if (parc < 3) return need_more_params(sptr, "CLEARMODE"); - if (!IsPrivileged(sptr)) - return send_error_to_client(sptr, ERR_NOPRIVILEGES); + if (!IsPrivileged(sptr)) { + protocol_violation(sptr,"No privileges on source for CLEARMODE, desync?"); + return send_reply(sptr, ERR_NOPRIVILEGES); + } if (!IsChannelName(parv[1]) || IsLocalChannel(parv[1]) || !(chptr = FindChannel(parv[1]))) - return send_error_to_client(sptr, ERR_NOSUCHCHANNEL, parv[1]); + return send_reply(sptr, ERR_NOSUCHCHANNEL, parv[1]); return do_clearmode(cptr, sptr, chptr, parv[2]); } @@ -285,6 +276,11 @@ mo_clearmode(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { struct Channel *chptr; char *control = "ovpsmikbl"; /* default control string */ + const char *chname, *qreason; + int force = 0; + + if (!feature_bool(FEAT_CONFIG_OPERCMDS)) + return send_reply(sptr, ERR_DISABLED, "CLEARMODE"); if (parc < 2) return need_more_params(sptr, "CLEARMODE"); @@ -292,13 +288,26 @@ mo_clearmode(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) if (parc > 2) control = parv[2]; - clean_channelname(parv[1]); + chname = parv[1]; + if (*chname == '!') + { + chname++; + if (!HasPriv(sptr, IsLocalChannel(chname) ? + PRIV_FORCE_LOCAL_OPMODE : + PRIV_FORCE_OPMODE)) + return send_reply(sptr, ERR_NOPRIVILEGES); + force = 1; + } + + if (!HasPriv(sptr, + IsLocalChannel(chname) ? PRIV_LOCAL_OPMODE : PRIV_OPMODE)) + return send_reply(sptr, ERR_NOPRIVILEGES); - if (!IsOper(sptr) && !IsLocalChannel(parv[1])) - return send_error_to_client(sptr, ERR_NOPRIVILEGES); + if (('#' != *chname && '&' != *chname) || !(chptr = FindChannel(chname))) + return send_reply(sptr, ERR_NOSUCHCHANNEL, chname); - if (!IsChannelName(parv[1]) || !(chptr = FindChannel(parv[1]))) - return send_error_to_client(sptr, ERR_NOSUCHCHANNEL, parv[1]); + if (!force && (qreason = find_quarantine(chptr->chname))) + return send_reply(sptr, ERR_QUARANTINED, chptr->chname, qreason); return do_clearmode(cptr, sptr, chptr, control); }