From 13a467bb98966810d26b6a2dd28b01820d609c27 Mon Sep 17 00:00:00 2001 From: JD Horelick Date: Thu, 25 Feb 2010 16:01:03 -0500 Subject: [PATCH] Override part one. --- include/client.h | 3 +++ modules/core/m_kick.c | 2 +- modules/core/m_message.c | 2 +- modules/m_topic.c | 2 +- src/channel.c | 8 +++++++- src/chmode.c | 2 +- src/s_user.c | 8 +++++++- 7 files changed, 21 insertions(+), 6 deletions(-) diff --git a/include/client.h b/include/client.h index 2d673cf..362ccb1 100644 --- a/include/client.h +++ b/include/client.h @@ -429,6 +429,9 @@ struct ListClient #define UMODE_OPER 0x1000 /* Operator */ #define UMODE_ADMIN 0x2000 /* Admin on server */ #define UMODE_SSLCLIENT 0x4000 /* using SSL */ +#define UMODE_OVERRIDE 0x20000 /* able to override */ + +#define IsOverride(x) ((x)->umodes & UMODE_OVERRIDE) /* overflow flags */ /* EARLIER FLAGS ARE IN s_newconf.h */ diff --git a/modules/core/m_kick.c b/modules/core/m_kick.c index 841485f..4eb2cfa 100644 --- a/modules/core/m_kick.c +++ b/modules/core/m_kick.c @@ -97,7 +97,7 @@ m_kick(struct Client *client_p, struct Client *source_p, int parc, const char *p return 0; } - if(!is_chanop(msptr)) + if(!is_chanop(msptr) && !IsOverride(source_p)) { if(MyConnect(source_p)) { diff --git a/modules/core/m_message.c b/modules/core/m_message.c index a3378f1..f855f4d 100644 --- a/modules/core/m_message.c +++ b/modules/core/m_message.c @@ -361,7 +361,7 @@ build_target_list(int p_or_n, const char *command, struct Client *client_p, msptr = find_channel_membership(chptr, source_p); - if(!IsServer(source_p) && !IsService(source_p) && !is_chanop_voiced(msptr)) + if(!IsServer(source_p) && !IsService(source_p) && !is_chanop_voiced(msptr) && !IsOverride(source_p)) { sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED), get_id(&me, source_p), diff --git a/modules/m_topic.c b/modules/m_topic.c index 3eee639..001a5e1 100644 --- a/modules/m_topic.c +++ b/modules/m_topic.c @@ -114,7 +114,7 @@ m_topic(struct Client *client_p, struct Client *source_p, int parc, const char * return 0; } - if((chptr->mode.mode & MODE_TOPICLIMIT) == 0 || is_chanop(msptr)) + if((chptr->mode.mode & MODE_TOPICLIMIT) == 0 || is_chanop(msptr) || IsOverride(source_p)) { char topic_info[USERHOST_REPLYLEN]; diff --git a/src/channel.c b/src/channel.c index d00be83..b5994d7 100644 --- a/src/channel.c +++ b/src/channel.c @@ -725,6 +725,9 @@ can_join(struct Client *source_p, struct Channel *chptr, char *key) s_assert(source_p->localClient != NULL); + if(IsOverride(source_p)) + return 0; + rb_sprintf(src_host, "%s!%s@%s", source_p->name, source_p->username, source_p->host); rb_sprintf(src_iphost, "%s!%s@%s", source_p->name, source_p->username, source_p->sockhost); if(source_p->localClient->mangledhost != NULL) @@ -847,6 +850,9 @@ can_send(struct Channel *chptr, struct Client *source_p, struct membership *mspt if(is_chanop_voiced(msptr)) return CAN_SEND_OPV; + if(IsOverride(source_p)) + return CAN_SEND_NONOP; + if(chptr->mode.mode & MODE_MODERATED) return CAN_SEND_NO; @@ -879,7 +885,7 @@ find_bannickchange_channel(struct Client *client_p) char src_host[NICKLEN + USERLEN + HOSTLEN + 6]; char src_iphost[NICKLEN + USERLEN + HOSTLEN + 6]; - if (!MyClient(client_p)) + if (!MyClient(client_p) || IsOverride(client_p)) return NULL; rb_sprintf(src_host, "%s!%s@%s", client_p->name, client_p->username, client_p->host); diff --git a/src/chmode.c b/src/chmode.c index 2319c51..c00806a 100644 --- a/src/chmode.c +++ b/src/chmode.c @@ -175,7 +175,7 @@ find_cflag_slot(void) static int get_channel_access(struct Client *source_p, struct membership *msptr) { - if(!MyClient(source_p) || is_chanop(msptr)) + if(!MyClient(source_p) || is_chanop(msptr) || IsOverride(source_p)) return CHFL_CHANOP; return CHFL_PEON; diff --git a/src/s_user.c b/src/s_user.c index 441012c..fccd29d 100644 --- a/src/s_user.c +++ b/src/s_user.c @@ -109,7 +109,7 @@ int user_modes[256] = { 0, /* m */ 0, /* n */ UMODE_OPER, /* o */ - 0, /* p */ + UMODE_OVERRIDE, /* p */ 0, /* q */ 0, /* r */ UMODE_SERVNOTICE, /* s */ @@ -1138,6 +1138,12 @@ user_mode(struct Client *client_p, struct Client *source_p, int parc, const char source_p->umodes &= ~UMODE_ADMIN; } + if(MyConnect(source_p) && (source_p->umodes & UMODE_OVERRIDE) && (!IsOperOverride(source_p))) + { + sendto_one_notice(source_p, ":*** You need oper and the override flag for +p"); + source_p->umodes &= ~UMODE_OVERRIDE; + } + /* let modules providing usermodes know that we've changed our usermode --nenolod */ hdata.client = source_p; hdata.oldumodes = setflags;