[srvx-commits] CVS: services/src modcmd.c,1.2,1.3
Brought to you by:
entrope
|
From: Zoot <zo...@us...> - 2002-07-30 21:04:38
|
Update of /cvsroot/srvx/services/src
In directory usw-pr-cvs1:/tmp/cvs-serv24452/src
Modified Files:
modcmd.c
Log Message:
Merge command permissions with those up the template chain, rather than checking them recursively. This fixes a bug that caused error messages to be reported multiple times.
Index: modcmd.c
===================================================================
RCS file: /cvsroot/srvx/services/src/modcmd.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** modcmd.c 30 Jul 2002 19:26:46 -0000 1.2
--- modcmd.c 30 Jul 2002 21:04:35 -0000 1.3
***************
*** 301,327 ****
int
! svccmd_can_invoke(struct userNode *user, struct userNode *bot, struct svccmd *cmd, struct chanNode *channel, unsigned int argc, unsigned int server_qualified) {
/* This is kind of a lame hack, but it is actually simpler than
* having the permission check vary based on the command itself,
* or having a more generic rule system. */
! unsigned int flags = cmd->command->flags | cmd->flags;
unsigned int res = (MODCMD_EXECUTE|MODCMD_LOG_COMMAND);
unsigned int uData_checked = 0;
struct userData *uData = NULL;
! if (!cmd) return 0;
! if (cmd->command->min_argc > argc) {
! send_message(user, bot, MSG_MISSING_PARAMS, cmd->name);
goto refuse;
}
! if (cmd->template) {
! res = svccmd_can_invoke(user, bot, cmd->template, channel, argc, server_qualified);
! flags = cmd->command->flags;
! goto flagcheck;
}
! if (cmd->min_opserv_level > 0) {
! if (!oper_has_access(user, bot, cmd->min_opserv_level, 0)) goto refuse;
}
! if (cmd->req_account_flags || cmd->deny_account_flags) {
if (!user->handle_info) {
send_message(user, bot, MSG_AUTHENTICATE);
--- 301,338 ----
int
! svccmd_can_invoke(struct userNode *user, struct userNode *bot, struct svccmd *base_cmd, struct chanNode *channel, unsigned int argc, unsigned int server_qualified) {
/* This is kind of a lame hack, but it is actually simpler than
* having the permission check vary based on the command itself,
* or having a more generic rule system. */
! unsigned int flags = base_cmd->command->flags | base_cmd->flags;
unsigned int res = (MODCMD_EXECUTE|MODCMD_LOG_COMMAND);
unsigned int uData_checked = 0;
struct userData *uData = NULL;
+ struct svccmd cmd, *cmd2;
! if (!base_cmd) return 0;
! if (base_cmd->command->min_argc > argc) {
! send_message(user, bot, MSG_MISSING_PARAMS, base_cmd->name);
goto refuse;
}
!
! memcpy(&cmd, base_cmd, sizeof(*base_cmd));
! for(cmd2 = base_cmd->template; cmd2; cmd2 = cmd2->template)
! {
! cmd.flags |= cmd2->flags;
! cmd.req_account_flags |= cmd2->req_account_flags;
! cmd.deny_account_flags |= cmd2->deny_account_flags;
! if(cmd2->min_opserv_level > cmd.min_opserv_level) {
! cmd.min_opserv_level = cmd2->min_opserv_level;
! }
! if(cmd2->min_channel_access > cmd.min_channel_access) {
! cmd.min_channel_access = cmd2->min_channel_access;
! }
}
!
! if (cmd.min_opserv_level > 0) {
! if (!oper_has_access(user, bot, cmd.min_opserv_level, 0)) goto refuse;
}
! if (cmd.req_account_flags || cmd.deny_account_flags) {
if (!user->handle_info) {
send_message(user, bot, MSG_AUTHENTICATE);
***************
*** 329,347 ****
}
/* Do we want separate or different messages here? */
! if ((cmd->req_account_flags & ~user->handle_info->flags)
! || (cmd->deny_account_flags & user->handle_info->flags)) {
! send_message(user, bot, MSG_COMMAND_PRIVILEGED, cmd->name);
goto refuse;
}
}
! if (cmd->min_channel_access > ulNone) flags |= MODCMD_REQUIRE_CHANUSER;
- flagcheck:
if (flags & MODCMD_DISABLED) {
! send_message(user, bot, MSG_COMMAND_DISABLED, cmd->name);
goto refuse;
}
if ((flags & MODCMD_REQUIRE_QUALIFIED) && !server_qualified) {
! send_message(user, bot, "You $bMUST$b \"/msg $S@$s %s\" (not just $S) for that command.", cmd->name);
goto refuse;
}
--- 340,357 ----
}
/* Do we want separate or different messages here? */
! if ((cmd.req_account_flags & ~user->handle_info->flags)
! || (cmd.deny_account_flags & user->handle_info->flags)) {
! send_message(user, bot, MSG_COMMAND_PRIVILEGED, cmd.name);
goto refuse;
}
}
! if (cmd.min_channel_access > ulNone) flags |= MODCMD_REQUIRE_CHANUSER;
if (flags & MODCMD_DISABLED) {
! send_message(user, bot, MSG_COMMAND_DISABLED, cmd.name);
goto refuse;
}
if ((flags & MODCMD_REQUIRE_QUALIFIED) && !server_qualified) {
! send_message(user, bot, "You $bMUST$b \"/msg $S@$s %s\" (not just $S) for that command.", cmd.name);
goto refuse;
}
***************
*** 372,376 ****
send_message(user, bot, "You lack access to $b%s$b.", channel->name);
goto refuse;
! } else if (uData->access < cmd->min_channel_access) {
send_message(user, bot, "You lack sufficient access to $b%s$b to use this command.", channel->name);
goto refuse;
--- 382,386 ----
send_message(user, bot, "You lack access to $b%s$b.", channel->name);
goto refuse;
! } else if (uData->access < cmd.min_channel_access) {
send_message(user, bot, "You lack sufficient access to $b%s$b to use this command.", channel->name);
goto refuse;
|