]>
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
;
46 chanservstdmessage(sender
, QM_NOTENOUGHPARAMS
, "giveowner");
50 /* You need to either be +n or have the relevant override... */
51 if (!(cip
=cs_checkaccess(sender
, cargv
[0], CA_OWNERPRIV
,
52 NULL
, "giveowner", QPRIV_CHANGECHANLEV
, 0)))
55 rcp
=cip
->exts
[chanservext
];
57 if (!(target
=findreguser(sender
, cargv
[1])))
58 return CMD_ERROR
; /* If there was an error, findreguser will have sent a message saying why.. */
60 rcup
=findreguseronchannel(rcp
, target
);
62 /* Can't promote if already owner */
63 if (rcup
&& (rcup
->flags
& QCUFLAG_OWNER
)) {
64 chanservstdmessage(sender
,QM_GIVEOWNERALREADYOWNER
,target
->username
,cip
->name
->content
);
68 /* You can only promote a master */
69 if (!rcup
|| !(rcup
->flags
& QCUFLAG_MASTER
)) {
70 chanservstdmessage(sender
,QM_GIVEOWNERNOTMASTER
,target
->username
,cip
->name
->content
);
75 sprintf(hashstr
,"%u.%u.%u",rcp
->ID
,target
->ID
,rup
->ID
);
76 thehash
=irc_crc32(hashstr
);
78 sprintf(hashstr
,"%x",thehash
);
81 chanservstdmessage(sender
,QM_GIVEOWNERNEEDHASH
,cip
->name
->content
,target
->username
,
82 cip
->name
->content
,target
->username
,hashstr
);
86 if (ircd_strcmp(cargv
[2], hashstr
)) {
87 chanservstdmessage(sender
,QM_GIVEOWNERWRONGHASH
,target
->username
,
92 /* OK, hash matches, do it. */
93 oldflags
= rcup
->flags
;
94 rcup
->flags
|= QCUFLAG_OWNER
;
95 rcup
->changetime
=time(NULL
);
99 args
[2]=(void *)oldflags
;
101 triggerhook(HOOK_CHANSERV_CHANLEVMOD
, args
);
103 chanservstdmessage(sender
,QM_DONE
);
105 strcpy(flagbuf
,printflags(oldflags
,rcuflags
));
106 cs_log(sender
,"GIVEOWNER %s #%s (%s -> %s)",cip
->name
->content
,rcup
->user
->username
,
107 flagbuf
,printflags(rcup
->flags
,rcuflags
));
109 csdb_chanlevhistory_insert(rcp
, sender
, rcup
->user
, oldflags
, rcup
->flags
);
110 csdb_updatechanuser(rcup
);