X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=ircd%2Fm_mode.c;h=e85398d26646e57790efc55f261ebbaaeeb5e04f;hb=refs%2Fheads%2Fupstream;hp=f2b2f00554367953290b3de7fd54edf561cc5c70;hpb=1b4e637606464f9af948a6e87879565f9fc1b726;p=ircu2.10.12-pk.git diff --git a/ircd/m_mode.c b/ircd/m_mode.c index f2b2f00..e85398d 100644 --- a/ircd/m_mode.c +++ b/ircd/m_mode.c @@ -86,6 +86,8 @@ #include "client.h" #include "hash.h" #include "ircd.h" +#include "ircd_features.h" +#include "ircd_log.h" #include "ircd_reply.h" #include "ircd_string.h" #include "msg.h" @@ -96,7 +98,7 @@ #include "s_user.h" #include "send.h" -#include +/* #include -- Now using assert in ircd_log.h */ #include #include @@ -110,13 +112,27 @@ m_mode(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) if (parc < 2) return need_more_params(sptr, "MODE"); - clean_channelname(parv[1]); + if (!IsChannelName(parv[1]) || !(chptr = FindChannel(parv[1]))) + { + struct Client *acptr; - if (('#' != *parv[1] && '&' != *parv[1] && '+' != *parv[1]) || - !(chptr = FindChannel(parv[1]))) - return set_user_mode(cptr, sptr, parc, parv); + acptr = FindUser(parv[1]); + if (!acptr) + { + send_reply(sptr, ERR_NOSUCHCHANNEL, parv[1]); + return 0; + } + else if (sptr != acptr) + { + send_reply(sptr, ERR_USERSDONTMATCH); + return 0; + } + return set_user_mode(cptr, sptr, parc, parv, ALLOWMODES_ANY); + } - cli_flags(sptr) &= ~FLAGS_TS8; + ClrFlag(sptr, FLAG_TS8); + + member = find_member_link(chptr, sptr); if (parc < 3) { char modebuf[MODEBUFLEN]; @@ -124,31 +140,32 @@ m_mode(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) *modebuf = *parabuf = '\0'; modebuf[1] = '\0'; - channel_modes(sptr, modebuf, parabuf, chptr); + channel_modes(sptr, modebuf, parabuf, sizeof(parabuf), chptr, member); send_reply(sptr, RPL_CHANNELMODEIS, chptr->chname, modebuf, parabuf); send_reply(sptr, RPL_CREATIONTIME, chptr->chname, chptr->creationtime); return 0; } - if (!(member = find_member_link(chptr, sptr)) || !IsChanOp(member)) { + if (!member || !IsChanOp(member)) { if (IsLocalChannel(chptr->chname) && HasPriv(sptr, PRIV_MODE_LCHAN)) { modebuf_init(&mbuf, sptr, cptr, chptr, (MODEBUF_DEST_CHANNEL | /* Send mode to channel */ MODEBUF_DEST_HACK4)); /* Send HACK(4) notice */ mode_parse(&mbuf, cptr, sptr, chptr, parc - 2, parv + 2, (MODE_PARSE_SET | /* Set the mode */ - MODE_PARSE_FORCE)); /* Force it to take */ + MODE_PARSE_FORCE), /* Force it to take */ + member); return modebuf_flush(&mbuf); } else mode_parse(0, cptr, sptr, chptr, parc - 2, parv + 2, - (member ? MODE_PARSE_NOTOPER : MODE_PARSE_NOTMEMBER)); + (member ? MODE_PARSE_NOTOPER : MODE_PARSE_NOTMEMBER), member); return 0; } modebuf_init(&mbuf, sptr, cptr, chptr, (MODEBUF_DEST_CHANNEL | /* Send mode to channel */ MODEBUF_DEST_SERVER)); /* Send mode to servers */ - mode_parse(&mbuf, cptr, sptr, chptr, parc - 2, parv + 2, MODE_PARSE_SET); + mode_parse(&mbuf, cptr, sptr, chptr, parc - 2, parv + 2, MODE_PARSE_SET, member); return modebuf_flush(&mbuf); } @@ -165,10 +182,26 @@ ms_mode(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) if (IsLocalChannel(parv[1])) return 0; - if (('#' != *parv[1] && '+' != *parv[1])|| !(chptr = FindChannel(parv[1]))) - return set_user_mode(cptr, sptr, parc, parv); + if (!(chptr = FindChannel(parv[1]))) + { + struct Client *acptr; + + acptr = FindUser(parv[1]); + if (!acptr) + { + return 0; + } + else if (sptr != acptr) + { + sendwallto_group_butone(&me, WALL_WALLOPS, 0, + "MODE for User %s from %s!%s", parv[1], + cli_name(cptr), cli_name(sptr)); + return 0; + } + return set_user_mode(cptr, sptr, parc, parv, ALLOWMODES_ANY); + } - cli_flags(sptr) &= ~FLAGS_TS8; + ClrFlag(sptr, FLAG_TS8); if (IsServer(sptr)) { if (find_conf_byhost(cli_confs(cptr), cli_name(sptr), CONF_UWORLD)) @@ -176,16 +209,24 @@ ms_mode(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) (MODEBUF_DEST_CHANNEL | /* Send mode to clients */ MODEBUF_DEST_SERVER | /* Send mode to servers */ MODEBUF_DEST_HACK4)); /* Send a HACK(4) message */ - else + else if (!feature_bool(FEAT_OPLEVELS)) modebuf_init(&mbuf, sptr, cptr, chptr, (MODEBUF_DEST_CHANNEL | /* Send mode to clients */ MODEBUF_DEST_SERVER | /* Send mode to servers */ MODEBUF_DEST_HACK3)); /* Send a HACK(3) message */ + else + /* Servers need to be able to op people who join using the Apass + * or upass, as well as people joining a zannel, therefore we do + * not generate HACK3 when oplevels are on. */ + modebuf_init(&mbuf, sptr, cptr, chptr, + (MODEBUF_DEST_CHANNEL | /* Send mode to clients */ + MODEBUF_DEST_SERVER)); /* Send mode to servers */ mode_parse(&mbuf, cptr, sptr, chptr, parc - 2, parv + 2, (MODE_PARSE_SET | /* Set the mode */ MODE_PARSE_STRICT | /* Interpret it strictly */ - MODE_PARSE_FORCE)); /* And force it to be accepted */ + MODE_PARSE_FORCE), /* And force it to be accepted */ + NULL); } else { if (!(member = find_member_link(chptr, sptr)) || !IsChanOp(member)) { modebuf_init(&mbuf, sptr, cptr, chptr, @@ -195,7 +236,8 @@ ms_mode(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) MODEBUF_DEST_BOUNCE)); /* And bounce the MODE */ mode_parse(&mbuf, cptr, sptr, chptr, parc - 2, parv + 2, (MODE_PARSE_STRICT | /* Interpret it strictly */ - MODE_PARSE_BOUNCE)); /* And bounce the MODE */ + MODE_PARSE_BOUNCE), /* And bounce the MODE */ + member); } else { modebuf_init(&mbuf, sptr, cptr, chptr, (MODEBUF_DEST_CHANNEL | /* Send mode to clients */ @@ -203,7 +245,8 @@ ms_mode(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) mode_parse(&mbuf, cptr, sptr, chptr, parc - 2, parv + 2, (MODE_PARSE_SET | /* Set the mode */ MODE_PARSE_STRICT | /* Interpret it strictly */ - MODE_PARSE_FORCE)); /* And force it to be accepted */ + MODE_PARSE_FORCE), /* And force it to be accepted */ + member); } }