Back out chanroles.

While what chanroles are trying to accomplish is a good idea, it is
apparently unclear this is the proper way to do it. Until we figure out
the exact way we wish to do this, it should be reverted for now.
This commit is contained in:
Elizabeth Jennifer Myers 2011-07-07 21:24:14 -04:00
parent e1ee78ae30
commit 7eec45bc9d
10 changed files with 14 additions and 165 deletions

12
TODO
View file

@ -51,11 +51,11 @@
[x] Compilation date and time in server welcome message is in OS locale - looks ugly 'cause often it's not match user's codepage [x] Compilation date and time in server welcome message is in OS locale - looks ugly 'cause often it's not match user's codepage
[ ] Improvments [ ] Improvments
[ ] ircd shouldn't need bison/byacc/yacc or flex for compilation [ ] ircd shouldn't need bison/byacc/yacc or flex for compilation
[/] internally split out +o/+v "ranks" into a series of permissions. this could allow for configure-defined
special access levels, halfops, etc. (would need to match globally, somehow. extra SVINFO param?)
this is mostly done, but is a work in progress.
[x] somehow hide channel operators like ircnet can do?
this is done now that chanroles is available
[x] create chmode.h and put there all declarations of chm_* - this will make some modules clean
--- other stuff --- other stuff
[?] internally split out +o/+v "ranks" into a series of permissions. this could allow for configure-defined
special access levels, halfops, etc. (would need to match globally, somehow. extra SVINFO param?)
might be backported from shadowircd in future (chanroles planned)
[?] somehow hide channel operators like ircnet can do?
couldn't be done via extension currently - compilation-time option acceptable?
[x] create chmode.h and put there all declarations of chm_* - this will make some modules clean
[?] Move oper override server WALLOPS to global server notices? [?] Move oper override server WALLOPS to global server notices?

View file

@ -87,7 +87,6 @@ struct membership
struct Channel *chptr; struct Channel *chptr;
struct Client *client_p; struct Client *client_p;
unsigned int flags; unsigned int flags;
unsigned int roles;
unsigned long bants; unsigned long bants;
}; };
@ -188,29 +187,11 @@ typedef int (*ExtbanFunc)(const char *data, struct Client *client_p,
#define MODE_ADD 1 #define MODE_ADD 1
#define MODE_DEL -1 #define MODE_DEL -1
/* Channel roles */
#define CHANROLE_NONE 0x000
#define CHANROLE_UNSET 0x001 /* Special value */
#define CHANROLE_KICK 0x002 /* Can kick */
#define CHANROLE_STATUS 0x004 /* Can change status modes */
#define CHANROLE_GRANT 0x008 /* Can grant (unused atm) */
#define CHANROLE_MODE 0x010 /* Can change modes */
#define CHANROLE_TOPIC 0x020 /* Can change topic */
#define CHANROLE_INHERIT 0x040 /* Role is inherited (backwards compat) */
#define CHANROLE_INITIAL (CHANROLE_KICK | CHANROLE_STATUS | CHANROLE_GRANT | CHANROLE_MODE | CHANROLE_TOPIC)
#define SecretChannel(x) ((x) && ((x)->mode.mode & MODE_SECRET)) #define SecretChannel(x) ((x) && ((x)->mode.mode & MODE_SECRET))
#define HiddenChannel(x) ((x) && ((x)->mode.mode & MODE_PRIVATE)) #define HiddenChannel(x) ((x) && ((x)->mode.mode & MODE_PRIVATE))
#define PubChannel(x) ((!x) || ((x)->mode.mode &\ #define PubChannel(x) ((!x) || ((x)->mode.mode &\
(MODE_PRIVATE | MODE_SECRET)) == 0) (MODE_PRIVATE | MODE_SECRET)) == 0)
#define HasChanRole(m, r) (((m)->roles & r) != 0)
#define SetChanRole(m, r) ((m)->roles |= r)
#define RemoveChanRole(m, r) ((m)->roles &= ~r)
#define IsChanRoleSet(m, r)
/* channel visible */ /* channel visible */
#define ShowChannel(v,c) (PubChannel(c) || IsMember((v),(c))) #define ShowChannel(v,c) (PubChannel(c) || IsMember((v),(c)))
@ -298,7 +279,7 @@ extern int match_extban(const char *banstr, struct Client *client_p, struct Chan
extern int valid_extban(const char *banstr, struct Client *client_p, struct Channel *chptr, long mode_type); extern int valid_extban(const char *banstr, struct Client *client_p, struct Channel *chptr, long mode_type);
const char * get_extban_string(void); const char * get_extban_string(void);
extern int get_channel_access(struct Client *source_p, struct membership *msptr, int role); extern int get_channel_access(struct Client *source_p, struct membership *msptr);
extern void send_channel_join(struct Channel *chptr, struct Client *client_p); extern void send_channel_join(struct Channel *chptr, struct Client *client_p);

View file

@ -65,7 +65,6 @@ TSRCS = \
m_dline.c \ m_dline.c \
m_encap.c \ m_encap.c \
m_etrace.c \ m_etrace.c \
m_grant.c \
m_help.c \ m_help.c \
m_info.c \ m_info.c \
m_invite.c \ m_invite.c \

View file

@ -97,7 +97,7 @@ m_kick(struct Client *client_p, struct Client *source_p, int parc, const char *p
return 0; return 0;
} }
if(get_channel_access(source_p, msptr, CHANROLE_KICK) < CHFL_CHANOP) if(get_channel_access(source_p, msptr) < CHFL_CHANOP)
{ {
if(MyConnect(source_p)) if(MyConnect(source_p))
{ {

View file

@ -1,112 +0,0 @@
/*
* charybdis: an advanced ircd
* m_grant: handle services grant commands
*/
#include "stdinc.h"
#include "client.h"
#include "ircd.h"
#include "numeric.h"
#include "s_serv.h"
#include "send.h"
#include "msg.h"
#include "parse.h"
#include "modules.h"
#include "s_conf.h"
#include "hash.h"
struct flag_list
{
char *name;
int flag;
};
static struct flag_list flaglist[] = {
{"kick", CHANROLE_KICK},
{"grant", CHANROLE_GRANT},
{"mode", CHANROLE_MODE},
{"topic", CHANROLE_TOPIC},
{"status", CHANROLE_STATUS},
{NULL, 0},
};
static int me_grant(struct Client *, struct Client *, int, const char **);
struct Message grant_msgtab = {
"GRANT", 0, 0, 0, MFLG_SLOW,
{mg_unreg, mg_ignore, mg_ignore, mg_ignore, {me_grant, 4}, mg_ignore}
};
mapi_clist_av1 grant_clist[] = { &grant_msgtab, NULL };
DECLARE_MODULE_AV1(grant, NULL, NULL, grant_clist, NULL, NULL, "Charybdis development team");
static void
apply_flags(struct membership *msptr, const char *flagspec, unsigned int flagmask)
{
char *s, *t, *p;
/* unset all chanroles as we're setting new ones */
msptr->roles = 0;
t = LOCAL_COPY(flagspec);
for (s = rb_strtok_r(t, " ", &p); s; s = rb_strtok_r(NULL, " ", &p))
{
const char *priv = s + 1; /* The actual priv */
struct flag_list *fl;
unsigned int flag = 0;
/* Go through the flags list... */
for(fl = flaglist; fl->name != NULL; fl++)
{
if (strcasecmp(fl->name, priv) == 0)
{
/* flagmask exists to ensure users can't give privileges they
* don't possess themselves */
if (!flagmask || (flagmask & fl->flag))
flag = fl->flag;
break;
}
}
/* Ack no flag! */
if (!flag)
continue;
if (s[0] == '-')
RemoveChanRole(msptr, flag);
else if (s[0] == '+')
SetChanRole(msptr, flag);
}
}
/*
* me_grant
*
* parv[1] = channel
* parv[2] = target UID
* parv[3] = flag spec
*/
static int
me_grant(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
struct Channel *chptr;
struct Client *target_p;
struct membership *msptr;
if (!(chptr = find_channel(parv[1])))
return 0;
if (!(target_p = find_person(parv[2])))
return 0;
/* Makes no sense to do this for non-local users */
if(!MyClient(target_p))
return 0;
if (!(msptr = find_channel_membership(chptr, target_p)))
return 0;
apply_flags(msptr, parv[3], 0);
return 0;
}

View file

@ -118,7 +118,7 @@ m_topic(struct Client *client_p, struct Client *source_p, int parc, const char *
} }
if(((chptr->mode.mode & MODE_TOPICLIMIT) == 0 || if(((chptr->mode.mode & MODE_TOPICLIMIT) == 0 ||
get_channel_access(source_p, msptr, CHANROLE_TOPIC) >= CHFL_CHANOP) && get_channel_access(source_p, msptr) >= CHFL_CHANOP) &&
(!MyClient(source_p) || (!MyClient(source_p) ||
can_send(chptr, source_p, msptr))) can_send(chptr, source_p, msptr)))
{ {

View file

@ -236,12 +236,6 @@ add_user_to_channel(struct Channel *chptr, struct Client *client_p, int flags)
msptr->client_p = client_p; msptr->client_p = client_p;
msptr->flags = flags; msptr->flags = flags;
/* Default to no chanroles until services says we're something else */
if (flags == CHFL_CHANOP)
msptr->roles = CHANROLE_INITIAL;
else
msptr->roles = CHANROLE_UNSET;
rb_dlinkAdd(msptr, &msptr->usernode, &client_p->user->channel); rb_dlinkAdd(msptr, &msptr->usernode, &client_p->user->channel);
rb_dlinkAdd(msptr, &msptr->channode, &chptr->members); rb_dlinkAdd(msptr, &msptr->channode, &chptr->members);

View file

@ -187,7 +187,7 @@ cflag_orphan(char c_)
} }
int int
get_channel_access(struct Client *source_p, struct membership *msptr, int role) get_channel_access(struct Client *source_p, struct membership *msptr)
{ {
hook_data_channel_approval moduledata; hook_data_channel_approval moduledata;
@ -201,12 +201,7 @@ get_channel_access(struct Client *source_p, struct membership *msptr, int role)
moduledata.chptr = msptr->chptr; moduledata.chptr = msptr->chptr;
moduledata.msptr = msptr; moduledata.msptr = msptr;
moduledata.target = NULL; moduledata.target = NULL;
moduledata.approved = is_chanop(msptr) ? CHFL_CHANOP : CHFL_PEON;
/* Check if they have the proper role */
if(HasChanRole(msptr, role))
moduledata.approved = CHFL_CHANOP;
else
moduledata.approved = CHFL_PEON;
call_hook(h_get_channel_access, &moduledata); call_hook(h_get_channel_access, &moduledata);
@ -903,11 +898,6 @@ chm_op(struct Client *source_p, struct Channel *chptr,
mode_changes[mode_count++].client = targ_p; mode_changes[mode_count++].client = targ_p;
mstptr->flags |= CHFL_CHANOP; mstptr->flags |= CHFL_CHANOP;
if (mstptr->roles & CHANROLE_UNSET)
{
mstptr->roles &= ~CHANROLE_UNSET;
mstptr->roles = CHANROLE_INITIAL | CHANROLE_INHERIT;
}
} }
else else
{ {
@ -928,8 +918,6 @@ chm_op(struct Client *source_p, struct Channel *chptr,
mode_changes[mode_count++].client = targ_p; mode_changes[mode_count++].client = targ_p;
mstptr->flags &= ~CHFL_CHANOP; mstptr->flags &= ~CHFL_CHANOP;
if (mstptr->roles & CHANROLE_INHERIT)
mstptr->roles = CHANROLE_UNSET;
} }
} }
@ -1212,7 +1200,7 @@ chm_forward(struct Client *source_p, struct Channel *chptr,
if(MyClient(source_p) && !(targptr->mode.mode & MODE_FREETARGET)) if(MyClient(source_p) && !(targptr->mode.mode & MODE_FREETARGET))
{ {
if((msptr = find_channel_membership(targptr, source_p)) == NULL || if((msptr = find_channel_membership(targptr, source_p)) == NULL ||
get_channel_access(source_p, msptr, CHANROLE_MODE) != CHFL_CHANOP) get_channel_access(source_p, msptr) != CHFL_CHANOP)
{ {
sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED), sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
me.name, source_p->name, targptr->chname); me.name, source_p->name, targptr->chname);
@ -1630,7 +1618,7 @@ set_channel_mode(struct Client *client_p, struct Client *source_p,
mode_limit = 0; mode_limit = 0;
mode_limit_simple = 0; mode_limit_simple = 0;
alevel = get_channel_access(source_p, msptr, CHANROLE_MODE); alevel = get_channel_access(source_p, msptr);
/* Hide connecting server on netburst -- jilles */ /* Hide connecting server on netburst -- jilles */
if (ConfigServerHide.flatten_links && IsServer(source_p) && !has_id(source_p) && !HasSentEob(source_p)) if (ConfigServerHide.flatten_links && IsServer(source_p) && !has_id(source_p) && !HasSentEob(source_p))

View file

@ -507,7 +507,7 @@ static const char * replies[] = {
/* 479 ERR_BADCHANNAME */ "%s :Illegal channel name", /* 479 ERR_BADCHANNAME */ "%s :Illegal channel name",
/* 480 ERR_THROTTLE */ ":%s 480 %s %s :Cannot join channel (+j) - throttle exceeded, try again later", /* 480 ERR_THROTTLE */ ":%s 480 %s %s :Cannot join channel (+j) - throttle exceeded, try again later",
/* 481 ERR_NOPRIVILEGES, */ ":Permission Denied - You're not an IRC operator", /* 481 ERR_NOPRIVILEGES, */ ":Permission Denied - You're not an IRC operator",
/* 482 ERR_CHANOPRIVSNEEDED, */ ":%s 482 %s %s :You're not a channel operator or have no privilege", /* 482 ERR_CHANOPRIVSNEEDED, */ ":%s 482 %s %s :You're not a channel operator",
/* 483 ERR_CANTKILLSERVER, */ ":You can't kill a server!", /* 483 ERR_CANTKILLSERVER, */ ":You can't kill a server!",
/* 484 ERR_ISCHANSERVICE */ ":%s 484 %s %s %s :Cannot kick or deop a network service", /* 484 ERR_ISCHANSERVICE */ ":%s 484 %s %s %s :Cannot kick or deop a network service",
/* 485 ERR_BANNEDNICK, */ NULL, /* 485 ERR_BANNEDNICK, */ NULL,

View file

@ -322,6 +322,5 @@ init_isupport(void)
add_isupport("TARGMAX", isupport_targmax, NULL); add_isupport("TARGMAX", isupport_targmax, NULL);
add_isupport("EXTBAN", isupport_extban, NULL); add_isupport("EXTBAN", isupport_extban, NULL);
add_isupport("WHOX", isupport_string, ""); add_isupport("WHOX", isupport_string, "");
add_isupport("CHANROLES", isupport_string, "");
add_isupport("CLIENTVER", isupport_string, "3.0"); add_isupport("CLIENTVER", isupport_string, "3.0");
} }