]>
jfr.im git - irc/quakenet/newserv.git/blob - chanserv/chanservprivs.c
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 return (rup
&& UHasHelperPriv(rup
));
26 case QPRIV_VIEWCOMMENTS
:
28 case QPRIV_CHANGECHANLEV
:
29 case QPRIV_CHANGECHANFLAGS
:
30 case QPRIV_CHANGECHANMODES
:
31 case QPRIV_CHANGEAUTOLIMIT
:
32 case QPRIV_CHANGEBANTIMER
:
33 case QPRIV_CHANGEUSERFLAGS
:
34 return (np
&& rup
&& IsOper(np
) && UHasOperPriv(rup
));
41 /* Generic access check function.
42 * Note that the chanindex is returned for success, this
43 * can be used to avoid duplicate hash lookups */
45 chanindex
*cs_checkaccess(nick
*np
, const char *chan
, unsigned int flags
,
46 chanindex
*cip
, const char *cmdname
, int priv
, int quiet
) {
47 reguser
*rup
=getreguserfromnick(np
);
49 regchanuser
*rcup
=NULL
;
52 if ((flags
& CA_AUTHED
) && !rup
)
55 if (!cip
&& !(cip
=findchanindex(chan
))) {
56 if (!quiet
) chanservstdmessage(np
, QM_UNKNOWNCHAN
, chan
);
60 if (!(rcp
=cip
->exts
[chanservext
]) ||
61 (CIsSuspended(rcp
) && !cs_privcheck(QPRIV_SUSPENDBYPASS
, np
))) {
62 if (!quiet
) chanservstdmessage(np
, QM_UNKNOWNCHAN
, cip
->name
->content
);
67 rcup
=findreguseronchannel(rcp
, rup
);
69 if (!priv
|| !cs_privcheck(priv
,np
)) {
70 if ((flags
& CA_VOICEPRIV
) &&
71 !(rcp
&& (CIsVoiceAll(rcp
)) &&
72 !(cip
->channel
&& (nickbanned(np
, cip
->channel
) || IsInviteOnly(cip
->channel
)))) &&
73 !(rcup
&& (CUHasVoicePriv(rcup
)))) {
74 if (!quiet
) chanservstdmessage(np
, QM_NOACCESSONCHAN
, cip
->name
->content
, cmdname
);
78 if ((flags
& CA_NEEDKNOWN
) && !rup
) {
79 if (!quiet
) chanservstdmessage(np
, QM_NOACCESSONCHAN
, cip
->name
->content
, cmdname
);
83 if ((flags
& CA_NEEDKNOWN
) && (!rcup
|| !CUKnown(rcup
))) {
84 if (!quiet
) chanservstdmessage(np
, QM_NOACCESSONCHAN
, cip
->name
->content
, cmdname
);
88 if (((flags
& CA_OPPRIV
) && !CUHasOpPriv(rcup
)) ||
89 ((flags
& CA_MASTERPRIV
) && !CUHasMasterPriv(rcup
)) ||
90 ((flags
& CA_OWNERPRIV
) && !CUIsOwner(rcup
)) ||
91 ((flags
& CA_TOPICPRIV
) && !CUHasTopicPriv(rcup
))) {
92 if (!quiet
) chanservstdmessage(np
, QM_NOACCESSONCHAN
, cip
->name
->content
, cmdname
);
97 if ((flags
& CA_ONCHANREQ
) && !(cip
->channel
)) {
98 if (!quiet
) chanservstdmessage(np
, QM_NOTONCHAN
, cip
->name
->content
);
103 lp
=getnumerichandlefromchanhash(cip
->channel
->users
, np
->numeric
);
105 if ((flags
& CA_ONCHANREQ
) && !lp
) {
106 if (!quiet
) chanservstdmessage(np
, QM_NOTONCHAN
, cip
->name
->content
);
110 if ((flags
& CA_OPPED
) && !(*lp
& CUMODE_OP
)) {
111 if (!quiet
) chanservstdmessage(np
, QM_NOTOPPED
, cip
->name
->content
);
115 if ((flags
& CA_DEOPPED
) && (*lp
& CUMODE_OP
)) {
116 if (!quiet
) chanservstdmessage(np
, QM_ALREADYOPPED
, cip
->name
->content
);
120 if ((flags
& CA_VOICED
) && !(*lp
& CUMODE_VOICE
)) {
121 if (!quiet
) chanservstdmessage(np
, QM_NOTVOICED
, cip
->name
->content
);
125 if ((flags
& CA_DEVOICED
) && (*lp
& CUMODE_VOICE
)) {
126 if (!quiet
) chanservstdmessage(np
, QM_ALREADYVOICED
, cip
->name
->content
);
130 if ((flags
& CA_OFFCHAN
) && lp
) {
131 if (!quiet
) chanservstdmessage(np
, QM_ALREADYONCHAN
, cip
->name
->content
);