summaryrefslogtreecommitdiff
path: root/fml/lib
diff options
context:
space:
mode:
authorfukachan <fukachan>2002-02-23 11:02:17 +0000
committerfukachan <fukachan>2002-02-23 11:02:17 +0000
commit0f4bba7a5b102505e2ffbfbaa1cad42ac376d083 (patch)
treecc3ae711739e52996ff85bb5e555c35da46c9131 /fml/lib
parent02d0774808609d69427fc601dae4a9fa27e127bf (diff)
downloadfml8-0f4bba7a5b102505e2ffbfbaa1cad42ac376d083.tar.gz
fml8-0f4bba7a5b102505e2ffbfbaa1cad42ac376d083.tar.bz2
fml8-0f4bba7a5b102505e2ffbfbaa1cad42ac376d083.zip
validate if the requested admin command is permited or not.
define $available_commands_for_privileged_user rename $available_commands -> $available_commands_for_user
Diffstat (limited to 'fml/lib')
-rw-r--r--fml/lib/FML/Process/Command.pm18
1 files changed, 15 insertions, 3 deletions
diff --git a/fml/lib/FML/Process/Command.pm b/fml/lib/FML/Process/Command.pm
index a3769166..47d04df6 100644
--- a/fml/lib/FML/Process/Command.pm
+++ b/fml/lib/FML/Process/Command.pm
@@ -3,7 +3,7 @@
# Copyright (C) 2000,2001,2002 Ken'ichi Fukamachi
# All rights reserved.
#
-# $FML: Command.pm,v 1.34 2002/02/17 09:14:41 fukachan Exp $
+# $FML: Command.pm,v 1.35 2002/02/17 13:51:49 fukachan Exp $
#
package FML::Process::Command;
@@ -235,6 +235,7 @@ sub _can_accpet_command
my $config = $curproc->{ config };
my $cred = $curproc->{ credential }; # user credential
my $prompt = $config->{ command_prompt } || '>>>';
+ my $mode = $opts->{ mode };
my $comname = $opts->{ comname };
my $command = $opts->{ command };
@@ -249,7 +250,7 @@ sub _can_accpet_command
}
# 2. use of this command is allowed in FML::Config or not ?
- unless ($config->has_attribute("available_commands", $comname)) {
+ unless ($config->has_attribute("available_commands_for_$mode", $comname)) {
$curproc->reply_message("\n$prompt $command");
$curproc->reply_message_nl('command.not_command',
"not command, ignored.");
@@ -373,6 +374,16 @@ sub _evaluate_command
Log("try $comname <$command>");
$command =~ s/^.*$comname/admin $comname/;
+
+ my $opts = {
+ mode => 'privileged_user',
+ comname => $comname,
+ command => $command };
+ unless ($curproc->_can_accpet_command($args, $opts)) {
+ # no, we do not accept this command.
+ Log("invalid command = $command");
+ next COMMAND;
+ }
}
# Case: commands except for 'admin' nor "confirm" reply message.
# check whether we need to accpet this command ?
@@ -381,7 +392,8 @@ sub _evaluate_command
# validate general command except for confirmation
# if $id is 1, this message must be confirmation reply.
else {
- my $opts = { comname => $comname, command => $command };
+ my $opts = {
+ mode => 'user', comname => $comname, command => $command };
unless ($curproc->_can_accpet_command($args, $opts)) {
# no, we do not accept this command.
Log("invalid command = $command");