pissircd/src/modules/chanmodes/halfop.c
Bram Matthys f169a3cf77
Fix channel ops unable to -h someone, even though they could +h.
Reported by Jaka in https://bugs.unrealircd.org/view.php?id=6077 and
Valware and buayadarat in https://bugs.unrealircd.org/view.php?id=6078

This commit also makes the halfop rules for +h/-h match the ones in U5:

Previously in 6.0.0 - 6.0.2 it was:
* halfops can set +h on others
* halfops cannot set -h on others
* halfops can set -h on themselves

Now in 6.0.3+ it matches 5.x behavior again:
* halfops cannot set -h or +h on others
* halfops can set -h on themselves
2022-03-18 07:26:53 +01:00

88 lines
2.1 KiB
C

/*
* Channel Mode +h
* (C) Copyright 2021 Syzop and the UnrealIRCd team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 1, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "unrealircd.h"
ModuleHeader MOD_HEADER
= {
"chanmodes/halfop",
"6.0",
"Channel Mode +h",
"UnrealIRCd Team",
"unrealircd-6",
};
/* Forward declarations */
int cmode_halfop_is_ok(Client *client, Channel *channel, char mode, const char *para, int type, int what);
MOD_INIT()
{
CmodeInfo creq;
ModDataInfo mreq;
MARK_AS_OFFICIAL_MODULE(modinfo);
memset(&creq, 0, sizeof(creq));
creq.paracount = 1;
creq.is_ok = cmode_halfop_is_ok;
creq.letter = 'h';
creq.prefix = '%';
creq.sjoin_prefix = '%';
creq.rank = RANK_HALFOP;
creq.unset_with_param = 1;
creq.type = CMODE_MEMBER;
CmodeAdd(modinfo->handle, creq, NULL);
return MOD_SUCCESS;
}
MOD_LOAD()
{
return MOD_SUCCESS;
}
MOD_UNLOAD()
{
return MOD_SUCCESS;
}
int cmode_halfop_is_ok(Client *client, Channel *channel, char mode, const char *param, int type, int what)
{
if ((type == EXCHK_ACCESS) || (type == EXCHK_ACCESS_ERR))
{
Client *target = find_user(param, NULL);
if ((what == MODE_DEL) && (target == client))
{
/* User may always remove their own modes */
return EX_ALLOW;
}
if (check_channel_access(client, channel, "oaq"))
{
/* Permitted for +oaq */
return EX_ALLOW;
}
if (type == EXCHK_ACCESS_ERR)
sendnumeric(client, ERR_CHANOPRIVSNEEDED, channel->name);
return EX_DENY;
}
/* fallthrough -- should not be used */
return EX_DENY;
}