After some deliberation we have decided that if modtab is enabled

then it should be possible to steal the moderation.
This commit is contained in:
Mike Belopuhov 2014-03-06 16:27:45 +01:00
parent 3fdebb84a9
commit f3c60e6c62
3 changed files with 14 additions and 9 deletions

14
cmd.c
View File

@ -302,8 +302,8 @@ icb_cmd_pass(struct icb_session *is, char *arg)
struct icb_session *s;
char whom[ICB_MAXNICKLEN];
if (!ig->mod) { /* if there is no mod, let anyone grab it */
if (icb_pass(ig, ig->mod, is) < 0)
if (!ig->mod) { /* if there is no mod, try grabbing it */
if (icb_modpermit(is, 0) && icb_pass(ig, ig->mod, is) < 0)
icb_error(is, "Acquiring group moderation failed.");
} else if (icb_ismod(ig, is)) {
if (strlen(arg) == 0) {
@ -320,8 +320,16 @@ icb_cmd_pass(struct icb_session *is, char *arg)
icb_status(is, STATUS_NOTIFY, "No such user");
return;
}
if (icb_pass(ig, ig->mod, s) < 0)
if (icb_modpermit(s, 0) && icb_pass(ig, ig->mod, s) < 0)
icb_error(s, "Acquiring group moderation failed.");
} else {
/*
* if group is moderated and we're not the moderator,
* but modtab is enabled, then check the permission
* and pass moderation if successful.
*/
if (icb_modpermit(is, 1) && icb_pass(ig, ig->mod, is) < 0)
icb_error(is, "Acquiring group moderation failed.");
}
}

7
icb.c
View File

@ -36,7 +36,6 @@ void icb_command(struct icb_session *, char *, char *);
void icb_groupmsg(struct icb_session *, char *);
void icb_login(struct icb_session *, char *, char *, char *);
int icb_dowho(struct icb_session *, struct icb_group *);
int icb_modpermit(struct icb_session *);
char *icb_nextfield(char **);
/*
@ -546,12 +545,12 @@ icb_ismod(struct icb_group *ig, struct icb_session *is)
* been populated
*/
int
icb_modpermit(struct icb_session *is)
icb_modpermit(struct icb_session *is, int enforce)
{
extern char modtab[ICB_MTABLEN][ICB_MAXNICKLEN];
extern int modtabcnt;
if (modtabcnt == 0 ||
if ((enforce ? 0 : modtabcnt == 0) ||
bsearch(is->nick, modtab, modtabcnt, ICB_MAXNICKLEN,
(int (*)(const void *, const void *))strcmp))
return (1);
@ -572,8 +571,6 @@ icb_pass(struct icb_group *ig, struct icb_session *from,
return (-1);
if (!from && !to)
return (-1);
if (to && !icb_modpermit(to))
return (-1);
ig->mod = to;
if (to)
icb_status(to, STATUS_NOTIFY, "%s just passed you moderation"

2
icb.h
View File

@ -128,7 +128,7 @@ void icb_error(struct icb_session *, const char *, ...);
void icb_init(struct icbd_callbacks *);
void icb_input(struct icb_session *);
inline int icb_ismod(struct icb_group *, struct icb_session *);
int icb_modpermit(struct icb_session *);
int icb_modpermit(struct icb_session *, int);
int icb_pass(struct icb_group *, struct icb_session *,
struct icb_session *);
void icb_privmsg(struct icb_session *, char *, char *);