Thread: [srvx-commits] CVS: services/src modcmd.c,1.49,1.50
Brought to you by:
entrope
|
From: Entrope <en...@us...> - 2003-01-25 00:50:31
|
Update of /cvsroot/srvx/services/src
In directory sc8-pr-cvs1:/tmp/cvs-serv20373/src
Modified Files:
modcmd.c
Log Message:
honor channel suspensions
check effective flags for masks, not plain flags
Index: modcmd.c
===================================================================
RCS file: /cvsroot/srvx/services/src/modcmd.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -C2 -r1.49 -r1.50
*** modcmd.c 21 Jan 2003 00:56:27 -0000 1.49
--- modcmd.c 25 Jan 2003 00:50:26 -0000 1.50
***************
*** 37,40 ****
--- 37,41 ----
#define MCMSG_ACCOUNT_SUSPENDED "Your account has been suspended."
#define MCMSG_CHAN_NOT_REGISTERED "%s has not been registered with $C."
+ #define MCMSG_CHAN_SUSPENDED "$b$C$b access to $b%s$b has been temporarily suspended."
#define MCMSG_NO_CHANNEL_ACCESS "You lack access to %s."
#define MCMSG_LOW_CHANNEL_ACCESS "You lack sufficient access in %s to use this command."
***************
*** 458,461 ****
--- 459,465 ----
if (noisy) send_message(user, bot, MCMSG_CHAN_NOT_REGISTERED, channel->name);
return 0;
+ } else if (IsSuspended(channel->channel_info)) {
+ if (noisy) send_message(user, bot, MCMSG_CHAN_SUSPENDED, channel->name);
+ return 0;
}
}
***************
*** 592,596 ****
svccmd_invoke_argv(struct userNode *user, struct service *service, struct chanNode *channel, unsigned int argc, unsigned char *argv[], unsigned int server_qualified) {
struct svccmd *cmd;
! unsigned int cmd_arg, perms, pos;
char logbuf[2*MAXLEN];
--- 596,600 ----
svccmd_invoke_argv(struct userNode *user, struct service *service, struct chanNode *channel, unsigned int argc, unsigned char *argv[], unsigned int server_qualified) {
struct svccmd *cmd;
! unsigned int cmd_arg, perms, pos, flags;
char logbuf[2*MAXLEN];
***************
*** 601,605 ****
return 0;
}
! if(!isalnum(*argv[cmd_arg])) {
/* Silently ignore stuff that doesn't begin with a letter or number. */
return 0;
--- 605,609 ----
return 0;
}
! if (!isalnum(*argv[cmd_arg])) {
/* Silently ignore stuff that doesn't begin with a letter or number. */
return 0;
***************
*** 610,613 ****
--- 614,618 ----
return 0;
}
+ flags = cmd->effective_flags;
/* If they put a channel name first, check if the command allows
* it. If so, swap it with the command name.
***************
*** 616,624 ****
unsigned char *tmp;
/* Complain if we're not supposed to accept the channel. */
! if (!(cmd->flags & MODCMD_ACCEPT_CHANNEL)) {
send_message(user, service->bot, MCMSG_NO_CHANNEL_BEFORE);
return 0;
}
! if (!(cmd->flags & MODCMD_ACCEPT_PCHANNEL)
&& (argv[0][0] == '+')) {
send_message(user, service->bot, MCMSG_NO_PLUS_CHANNEL);
--- 621,629 ----
unsigned char *tmp;
/* Complain if we're not supposed to accept the channel. */
! if (!(flags & MODCMD_ACCEPT_CHANNEL)) {
send_message(user, service->bot, MCMSG_NO_CHANNEL_BEFORE);
return 0;
}
! if (!(flags & MODCMD_ACCEPT_PCHANNEL)
&& (argv[0][0] == '+')) {
send_message(user, service->bot, MCMSG_NO_PLUS_CHANNEL);
***************
*** 635,641 ****
*/
if ((argc > 1)
! && (cmd->flags & MODCMD_ACCEPT_CHANNEL)
&& IsChannelName(argv[1])
! && ((argv[1][0] != '+') || (cmd->flags & MODCMD_ACCEPT_PCHANNEL))
&& (channel = dict_find(channels, argv[1], NULL))) {
argv[1] = argv[0];
--- 640,646 ----
*/
if ((argc > 1)
! && (flags & MODCMD_ACCEPT_CHANNEL)
&& IsChannelName(argv[1])
! && ((argv[1][0] != '+') || (flags & MODCMD_ACCEPT_PCHANNEL))
&& (channel = dict_find(channels, argv[1], NULL))) {
argv[1] = argv[0];
***************
*** 659,665 ****
* expanded. */
if ((argc > 1)
! && (cmd->flags & MODCMD_ACCEPT_CHANNEL)
&& IsChannelName(argv[1])
! && ((argv[1][0] != '+') || (cmd->flags & MODCMD_ACCEPT_PCHANNEL))
&& (channel = dict_find(channels, argv[1], NULL))) {
argv[1] = argv[0];
--- 664,670 ----
* expanded. */
if ((argc > 1)
! && (flags & MODCMD_ACCEPT_CHANNEL)
&& IsChannelName(argv[1])
! && ((argv[1][0] != '+') || (flags & MODCMD_ACCEPT_PCHANNEL))
&& (channel = dict_find(channels, argv[1], NULL))) {
argv[1] = argv[0];
***************
*** 670,674 ****
/* Figure out what actions we should do for it.. */
! if (cmd_arg && (cmd->flags & MODCMD_TOY)) {
/* Do not let user manually specify a channel. */
channel = NULL;
--- 675,679 ----
/* Figure out what actions we should do for it.. */
! if (cmd_arg && (flags & MODCMD_TOY)) {
/* Do not let user manually specify a channel. */
channel = NULL;
***************
*** 687,691 ****
if (perms & ACTION_NOCHANNEL) channel = NULL;
pos = 0;
! if (!(cmd->flags & MODCMD_NO_LOG)) {
/* We reassemble the input line here. This lets services do
* clever things like replace passwords in argv[] with "****"
--- 692,696 ----
if (perms & ACTION_NOCHANNEL) channel = NULL;
pos = 0;
! if (!(flags & MODCMD_NO_LOG)) {
/* We reassemble the input line here. This lets services do
* clever things like replace passwords in argv[] with "****"
***************
*** 694,698 ****
if (channel) pos += sprintf(logbuf+pos, "(%s) ", channel->name);
pos += sprintf(logbuf+pos, "[%s", user->nick);
! if (cmd->flags & MODCMD_LOG_HOSTMASK) {
pos += sprintf(logbuf+pos, "!%s@%s/%ld.%ld.%ld.%ld", user->ident, user->hostname, (user->ip >> 24) & 255, (user->ip >> 16) & 255, (user->ip >> 8) & 255, user->ip & 255);
}
--- 699,703 ----
if (channel) pos += sprintf(logbuf+pos, "(%s) ", channel->name);
pos += sprintf(logbuf+pos, "[%s", user->nick);
! if (flags & MODCMD_LOG_HOSTMASK) {
pos += sprintf(logbuf+pos, "!%s@%s/%ld.%ld.%ld.%ld", user->ident, user->hostname, (user->ip >> 24) & 255, (user->ip >> 16) & 255, (user->ip >> 8) & 255, user->ip & 255);
}
***************
*** 706,710 ****
}
if (!cmd->command->func(user, channel, argc, argv, cmd)) return 0;
! if (!(cmd->flags & MODCMD_NO_LOG)) {
/* Unsplit argv after running the function to get the benefit
* of any mangling/hiding done by the commands. */
--- 711,715 ----
}
if (!cmd->command->func(user, channel, argc, argv, cmd)) return 0;
! if (!(flags & MODCMD_NO_LOG)) {
/* Unsplit argv after running the function to get the benefit
* of any mangling/hiding done by the commands. */
|