summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfukachan <fukachan>2003-11-16 23:49:12 +0000
committerfukachan <fukachan>2003-11-16 23:49:12 +0000
commit3450217990e04522a5f69f53b0317188dad0bc72 (patch)
tree903e0a990e6450a7b4af201154ca2a7fc9b6983f
parentcb3702f59776c96e315fe25cd95e782df0387280 (diff)
downloadfml8-3450217990e04522a5f69f53b0317188dad0bc72.tar.gz
fml8-3450217990e04522a5f69f53b0317188dad0bc72.tar.bz2
fml8-3450217990e04522a5f69f53b0317188dad0bc72.zip
validate arguments
-rw-r--r--fml/lib/FML/Command/Admin/newdomain.pm27
-rw-r--r--fml/lib/FML/Command/Admin/rmdomain.pm15
2 files changed, 33 insertions, 9 deletions
diff --git a/fml/lib/FML/Command/Admin/newdomain.pm b/fml/lib/FML/Command/Admin/newdomain.pm
index f5e8b0a2..2ca56a8e 100644
--- a/fml/lib/FML/Command/Admin/newdomain.pm
+++ b/fml/lib/FML/Command/Admin/newdomain.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: newdomain.pm,v 1.2 2003/11/16 11:53:18 fukachan Exp $
+# $FML: newdomain.pm,v 1.3 2003/11/16 12:23:47 fukachan Exp $
#
package FML::Command::Admin::newdomain;
@@ -58,10 +58,27 @@ sub process
my $canon_argv = $command_args->{ canon_argv };
my $domain = $canon_argv->{ ml_name };
my $prefix = $canon_argv->{ options }->[ 0 ];
-
- use FML::HomeDir::Prefix;
- my $ml_home_prefix = new FML::HomeDir::Prefix $curproc;
- $ml_home_prefix->add($domain, $prefix);
+ my $error = '';
+
+ if ($domain && $prefix) {
+ use FML::HomeDir::Prefix;
+ my $ml_home_prefix = new FML::HomeDir::Prefix $curproc;
+ $ml_home_prefix->add($domain, $prefix);
+ }
+ elsif ($domain && (! $prefix)) {
+ $error = "ml_home_prefix unspecified";
+ }
+ elsif ((! $domain) && $prefix) {
+ $error = "domain unspecified";
+ }
+ else {
+ $error = "no argument";
+ }
+
+ if ($error) {
+ $curproc->logerror($error);
+ croak($error);
+ }
}
diff --git a/fml/lib/FML/Command/Admin/rmdomain.pm b/fml/lib/FML/Command/Admin/rmdomain.pm
index 6955e4ab..aa8d083c 100644
--- a/fml/lib/FML/Command/Admin/rmdomain.pm
+++ b/fml/lib/FML/Command/Admin/rmdomain.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: rmdomain.pm,v 1.2 2003/11/16 11:53:18 fukachan Exp $
+# $FML: rmdomain.pm,v 1.3 2003/11/16 12:23:47 fukachan Exp $
#
package FML::Command::Admin::rmdomain;
@@ -58,9 +58,16 @@ sub process
my $canon_argv = $command_args->{ canon_argv };
my $domain = $canon_argv->{ ml_name };
- use FML::HomeDir::Prefix;
- my $ml_home_prefix = new FML::HomeDir::Prefix $curproc;
- $ml_home_prefix->delete($domain);
+ if ($domain) {
+ use FML::HomeDir::Prefix;
+ my $ml_home_prefix = new FML::HomeDir::Prefix $curproc;
+ $ml_home_prefix->delete($domain);
+ }
+ else {
+ my $error = 'no argument';
+ $curproc->logerror($error);
+ croak($error);
+ }
}