summaryrefslogtreecommitdiff
path: root/fml
diff options
context:
space:
mode:
authorfukachan <fukachan>2002-04-26 10:29:12 +0000
committerfukachan <fukachan>2002-04-26 10:29:12 +0000
commitf18acdd8a89b4557c57abb57f0424ac2c0eac5b7 (patch)
tree7efe500bd484613e4077bfa5f2700217daf09574 /fml
parenta76f5a85c06a87869719aae460b42e6d2fdb4d80 (diff)
downloadfml8-f18acdd8a89b4557c57abb57f0424ac2c0eac5b7.tar.gz
fml8-f18acdd8a89b4557c57abb57f0424ac2c0eac5b7.tar.bz2
fml8-f18acdd8a89b4557c57abb57f0424ac2c0eac5b7.zip
permit_commands_for_stranger works
Diffstat (limited to 'fml')
-rw-r--r--fml/lib/FML/Command/DataCheck.pm38
-rw-r--r--fml/lib/FML/Process/Command.pm5
-rw-r--r--fml/lib/FML/Process/Kernel.pm9
3 files changed, 47 insertions, 5 deletions
diff --git a/fml/lib/FML/Command/DataCheck.pm b/fml/lib/FML/Command/DataCheck.pm
index 00d1d2e6..9799e3cd 100644
--- a/fml/lib/FML/Command/DataCheck.pm
+++ b/fml/lib/FML/Command/DataCheck.pm
@@ -4,7 +4,7 @@
# All rights reserved. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
#
-# $FML$
+# $FML: DataCheck.pm,v 1.1 2002/04/26 09:20:17 fukachan Exp $
#
package FML::Command::DataCheck;
@@ -112,6 +112,42 @@ sub find_special_keyword
}
+# Descriptions: check message of the current process
+# whether it contais keyword e.g. "confirm".
+# Arguments: OBJ($self) OBJ($curproc) ARRAY_REF($ra_data)
+# Side Effects: none
+# Return Value: NUM( 1 or )
+sub find_commands_for_stranger
+{
+ my ($self, $curproc) = @_;
+ my $config = $curproc->{ config };
+ my $commands = $config->get_as_array_ref('commands_for_stranger');
+ my $body = $curproc->{ incoming_message }->{ body };
+ my $msg = $body->find_first_plaintext_message();
+ my (@body) = split(/\n/, $msg->message_text );
+ my $comname = '';
+
+ LINE:
+ for my $buf (@body) {
+ ($comname) = $self->parse_command_buffer( $buf );
+ next LINE unless defined($comname) && $comname;
+
+ # $comname matches one of $commands_for_stranger ?
+ COMMAND:
+ for my $proc (@$commands) {
+ next COMMAND unless defined($proc) && $proc;
+
+ return 1 if $comname eq $proc;
+ }
+ };
+
+ my $data = $self->find_special_keyword($curproc, \@body);
+ return 1 if $data->{ confirm_keyword };
+
+ return 0;
+}
+
+
# Descriptions: clean up the given string and return a cleaned one.
# For example, "# ls uja " -> "ls uja"
# Arguments: OBJ($self) STR($s)
diff --git a/fml/lib/FML/Process/Command.pm b/fml/lib/FML/Process/Command.pm
index 67f55a01..ad92e900 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.50 2002/04/25 04:15:21 fukachan Exp $
+# $FML: Command.pm,v 1.51 2002/04/26 09:20:17 fukachan Exp $
#
package FML::Process::Command;
@@ -139,7 +139,7 @@ sub run
}
else {
my $reason = $pcb->get("check_restrictions", "deny_reason");
- if ($reason eq 'reject_system_accounts') {
+ if (defined($reason) && ($reason eq 'reject_system_accounts')) {
$curproc->reply_message_nl("error.system_accounts",
"deny request from system accounts");
}
@@ -152,6 +152,7 @@ sub run
my $msg = $curproc->{ incoming_message }->{ message };
$curproc->reply_message( $msg );
+ unless (defined $reason) { $reason = 'unknown';}
Log("deny command. reason=$reason");
}
}
diff --git a/fml/lib/FML/Process/Kernel.pm b/fml/lib/FML/Process/Kernel.pm
index e0c8dd59..299d1352 100644
--- a/fml/lib/FML/Process/Kernel.pm
+++ b/fml/lib/FML/Process/Kernel.pm
@@ -4,7 +4,7 @@
# All rights reserved. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
#
-# $FML: Kernel.pm,v 1.87 2002/04/23 14:10:33 fukachan Exp $
+# $FML: Kernel.pm,v 1.88 2002/04/26 09:19:35 fukachan Exp $
#
package FML::Process::Kernel;
@@ -538,7 +538,12 @@ sub _check_restrictions
}
}
elsif ($rule eq 'permit_commands_for_stranger') {
- return 0;
+ use FML::Command::DataCheck;
+ my $check = new FML::Command::DataCheck;
+ if ($check->find_commands_for_stranger($curproc)) {
+ Log("$rule matched. accepted.");
+ return 1;
+ }
}
elsif ($rule eq 'reject') {
$pcb->set("check_restrictions", "deny_reason", $rule);