]>
jfr.im git - irc/quakenet/newserv.git/blob - chanserv/chanservprivs.c
fd38ff2f66b7c43c11231106827bca4454840100
4 #include "../nick/nick.h"
5 #include "../lib/irc_string.h"
9 int cs_privcheck(int privnum
, nick
*np
) {
13 rup
=getreguserfromnick(np
);
16 case QPRIV_SUSPENDBYPASS
:
17 case QPRIV_VIEWCHANFLAGS
:
18 case QPRIV_VIEWFULLCHANLEV
:
19 case QPRIV_VIEWFULLWHOIS
:
20 case QPRIV_VIEWCHANMODES
:
21 case QPRIV_VIEWAUTOLIMIT
:
22 case QPRIV_VIEWBANTIMER
:
23 case QPRIV_VIEWUSERFLAGS
:
24 case QPRIV_VIEWCHANSUSPENSION
:
25 return (rup
&& UHasHelperPriv(rup
));
27 case QPRIV_VIEWCOMMENTS
:
29 case QPRIV_CHANGECHANLEV
:
30 case QPRIV_CHANGECHANFLAGS
:
31 case QPRIV_CHANGECHANMODES
:
32 case QPRIV_CHANGEAUTOLIMIT
:
33 case QPRIV_CHANGEBANTIMER
:
34 case QPRIV_CHANGEUSERFLAGS
:
35 case QPRIV_VIEWSUSPENDEDBY
:
36 return (np
&& rup
&& IsOper(np
) && UHasOperPriv(rup
));
38 default: /* By default opers can override anything */
39 return (np
&& rup
&& IsOper(np
) && UHasOperPriv(rup
));
43 /* Generic access check function.
44 * Note that the chanindex is returned for success, this
45 * can be used to avoid duplicate hash lookups */
47 chanindex
*cs_checkaccess(nick
*np
, const char *chan
, unsigned int flags
,
48 chanindex
*cip
, const char *cmdname
, int priv
, int quiet
) {
49 reguser
*rup
=getreguserfromnick(np
);
51 regchanuser
*rcup
=NULL
;
54 if ((flags
& CA_AUTHED
) && !rup
)
57 if (!cip
&& !(cip
=findchanindex(chan
))) {
58 if (!quiet
) chanservstdmessage(np
, QM_UNKNOWNCHAN
, chan
);
62 if (!(rcp
=cip
->exts
[chanservext
]) ||
63 (CIsSuspended(rcp
) && !cs_privcheck(QPRIV_SUSPENDBYPASS
, np
))) {
64 if (!quiet
) chanservstdmessage(np
, QM_UNKNOWNCHAN
, cip
->name
->content
);
69 rcup
=findreguseronchannel(rcp
, rup
);
71 if (!cs_privcheck(priv
,np
)) {
72 if ((flags
& CA_VOICEPRIV
) &&
73 !(rcp
&& (CIsVoiceAll(rcp
)) &&
74 !(cip
->channel
&& (nickbanned_visible(np
, cip
->channel
) || IsInviteOnly(cip
->channel
)))) &&
75 !(rcup
&& (CUHasVoicePriv(rcup
)))) {
76 if (!quiet
) chanservstdmessage(np
, QM_NOACCESSONCHAN
, cip
->name
->content
, cmdname
);
80 if ((flags
& CA_NEEDKNOWN
) && !rup
) {
81 if (!quiet
) chanservstdmessage(np
, QM_NOACCESSONCHAN
, cip
->name
->content
, cmdname
);
85 if ((flags
& CA_NEEDKNOWN
) && (!rcup
|| !CUKnown(rcup
))) {
86 if (!quiet
) chanservstdmessage(np
, QM_NOACCESSONCHAN
, cip
->name
->content
, cmdname
);
90 if (((flags
& CA_OPPRIV
) && !CUHasOpPriv(rcup
)) ||
91 ((flags
& CA_MASTERPRIV
) && !CUHasMasterPriv(rcup
)) ||
92 ((flags
& CA_OWNERPRIV
) && !CUIsOwner(rcup
)) ||
93 ((flags
& CA_TOPICPRIV
) && !CUHasTopicPriv(rcup
))) {
94 if (!quiet
) chanservstdmessage(np
, QM_NOACCESSONCHAN
, cip
->name
->content
, cmdname
);
99 if ((flags
& CA_ONCHANREQ
) && !(cip
->channel
)) {
100 if (!quiet
) chanservstdmessage(np
, QM_NOTONCHAN
, cip
->name
->content
);
105 lp
=getnumerichandlefromchanhash(cip
->channel
->users
, np
->numeric
);
107 if ((flags
& CA_ONCHANREQ
) && !lp
) {
108 if (!quiet
) chanservstdmessage(np
, QM_NOTONCHAN
, cip
->name
->content
);
112 if ((flags
& CA_OPPED
) && !(*lp
& CUMODE_OP
)) {
113 if (!quiet
) chanservstdmessage(np
, QM_NOTOPPED
, cip
->name
->content
);
117 if ((flags
& CA_DEOPPED
) && (*lp
& CUMODE_OP
)) {
118 if (!quiet
) chanservstdmessage(np
, QM_ALREADYOPPED
, cip
->name
->content
);
122 if ((flags
& CA_VOICED
) && !(*lp
& CUMODE_VOICE
)) {
123 if (!quiet
) chanservstdmessage(np
, QM_NOTVOICED
, cip
->name
->content
);
127 if ((flags
& CA_DEVOICED
) && (*lp
& CUMODE_VOICE
)) {
128 if (!quiet
) chanservstdmessage(np
, QM_ALREADYVOICED
, cip
->name
->content
);
132 if ((flags
& CA_OFFCHAN
) && lp
) {
133 if (!quiet
) chanservstdmessage(np
, QM_ALREADYONCHAN
, cip
->name
->content
);