]>
jfr.im git - irc/quakenet/newserv.git/blob - chanserv/chancmds/giveowner.c
3 * CMDLEVEL: QCMD_AUTHED
5 * CMDDESC: Gives total control over a channel to another user.
6 * CMDFUNC: csc_dogiveowner
7 * CMDPROTO: int csc_dogiveowner(void *source, int cargc, char **cargv);
8 * CMDHELP: Usage: GIVEOWNER <channel> <user> [<code>]
9 * CMDHELP: Gives complete control (+n flag) to the named user on the channel. The new owner
10 * CMDHELP: will have full control over the channel, including the ability to remove the
11 * CMDHELP: existing owner(s). As a precaution the named user must already have master (+m)
12 * CMDHELP: access on the channel. Use this command with extreme caution. Where:
13 * CMDHELP: channel - channel to use
14 * CMDHELP: user - user to give owner to, either a nickname on the network or #accountname.
15 * CMDHELP: code - a unique code used to authorize the operation. If the code is not
16 * CMDHELP: supplied, the appropriate code will be provided together with a
17 * CMDHELP: warning about the dangers of this command. If the wrong code is
18 * CMDHELP: entered owner access will not be granted.
19 * CMDHELP: GIVEOWNER requires owner (+n) access on the named channel.
22 #include "../chanserv.h"
23 #include "../../nick/nick.h"
24 #include "../../lib/flags.h"
25 #include "../../lib/irc_string.h"
26 #include "../../channel/channel.h"
27 #include "../../parser/parser.h"
28 #include "../../irc/irc.h"
29 #include "../../localuser/localuserchannel.h"
33 int csc_dogiveowner(void *source
, int cargc
, char **cargv
) {
38 reguser
*rup
=getreguserfromnick(sender
), *target
;
45 chanservstdmessage(sender
, QM_NOTENOUGHPARAMS
, "giveowner");
49 /* You need to either be +n or have the relevant override... */
50 if (!(cip
=cs_checkaccess(sender
, cargv
[0], CA_OWNERPRIV
,
51 NULL
, "giveowner", QPRIV_CHANGECHANLEV
, 0)))
54 rcp
=cip
->exts
[chanservext
];
56 if (!(target
=findreguser(sender
, cargv
[1])))
57 return CMD_ERROR
; /* If there was an error, findreguser will have sent a message saying why.. */
59 rcup
=findreguseronchannel(rcp
, target
);
61 /* Can't promote if already owner */
62 if (rcup
&& (rcup
->flags
& QCUFLAG_OWNER
)) {
63 chanservstdmessage(sender
,QM_GIVEOWNERALREADYOWNER
,target
->username
,cip
->name
->content
);
67 /* You can only promote a master */
68 if (!rcup
|| !(rcup
->flags
& QCUFLAG_MASTER
)) {
69 chanservstdmessage(sender
,QM_GIVEOWNERNOTMASTER
,target
->username
,cip
->name
->content
);
74 sprintf(hashstr
,"%u.%u.%u",rcp
->ID
,target
->ID
,rup
->ID
);
75 thehash
=crc32(hashstr
);
77 sprintf(hashstr
,"%x",thehash
);
80 chanservstdmessage(sender
,QM_GIVEOWNERNEEDHASH
,cip
->name
->content
,target
->username
,
81 cip
->name
->content
,target
->username
,hashstr
);
85 if (ircd_strcmp(cargv
[2], hashstr
)) {
86 chanservstdmessage(sender
,QM_GIVEOWNERWRONGHASH
,target
->username
,
91 /* OK, hash matches, do it. */
92 oldflags
= rcup
->flags
;
93 rcup
->flags
|= QCUFLAG_OWNER
;
95 chanservstdmessage(sender
,QM_DONE
);
97 strcpy(flagbuf
,printflags(oldflags
,rcuflags
));
98 cs_log(sender
,"GIVEOWNER %s #%s (%s -> %s)",cip
->name
->content
,rcup
->user
->username
,
99 flagbuf
,printflags(rcup
->flags
,rcuflags
));
101 csdb_chanlevhistory_insert(rcp
, sender
, rcup
->user
, oldflags
, rcup
->flags
);
102 csdb_updatechanuser(rcup
);