From b3b2ed9780cba27094b31440e8c2fee12cc3dd45 Mon Sep 17 00:00:00 2001 From: "B.Greenham" Date: Sat, 27 Feb 2010 21:27:05 -0500 Subject: [PATCH] Add can_kick_deop() and use it in m_kick. --- include/channel.h | 1 + modules/core/m_kick.c | 2 +- src/channel.c | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/include/channel.h b/include/channel.h index 22b7e70..4252b2a 100644 --- a/include/channel.h +++ b/include/channel.h @@ -229,6 +229,7 @@ extern struct membership *find_channel_membership(struct Channel *, struct Clien extern const char *find_channel_status(struct membership *msptr, int combine); extern int is_any_op(struct membership *msptr); extern int is_chanop_voiced(struct membership *msptr); +extern int can_kick_deop(struct membership *source, struct membership *target); extern void add_user_to_channel(struct Channel *, struct Client *, int flags); extern void remove_user_from_channel(struct membership *); extern void remove_user_from_channels(struct Client *); diff --git a/modules/core/m_kick.c b/modules/core/m_kick.c index 4eb2cfa..368c715 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) && !IsOverride(source_p)) + if(!can_kick_deop(msptr, find_channel_membership(chptr, client_p)) && !IsOverride(source_p)) { if(MyConnect(source_p)) { diff --git a/src/channel.c b/src/channel.c index 0fd0f03..c3e8cd9 100644 --- a/src/channel.c +++ b/src/channel.c @@ -226,6 +226,22 @@ is_chanop_voiced(struct membership *msptr) return 0; } +/* can_kick_deop() + * + * input - two memeberships + * output - 1 if the first memebership can kick/deop the second, 0 elsewise + * side effects - + */ +int +can_kick_deop(struct membership *source, struct membership *target) +{ + /* This does not do much yet. That will change when +ah is in. */ + if(!is_any_op(source)) + return 0; + else + return 1; +} + /* add_user_to_channel() * * input - channel to add client to, client to add, channel flags