summaryrefslogtreecommitdiff
path: root/fml/lib/FML/Command
diff options
context:
space:
mode:
authorfukachan <fukachan>2002-04-30 16:17:14 +0000
committerfukachan <fukachan>2002-04-30 16:17:14 +0000
commit447aaa3e12889e6f7c828b0667e2970bef7256c8 (patch)
tree5bff7d63d408c1efdc930aa92c01accd398a6e50 /fml/lib/FML/Command
parent964e21a169f27932c7593f42a2118ea9fe77958e (diff)
downloadfml8-447aaa3e12889e6f7c828b0667e2970bef7256c8.tar.gz
fml8-447aaa3e12889e6f7c828b0667e2970bef7256c8.tar.bz2
fml8-447aaa3e12889e6f7c828b0667e2970bef7256c8.zip
add prototype for diagnostics
Diffstat (limited to 'fml/lib/FML/Command')
-rw-r--r--fml/lib/FML/Command/Admin/check.pm190
1 files changed, 190 insertions, 0 deletions
diff --git a/fml/lib/FML/Command/Admin/check.pm b/fml/lib/FML/Command/Admin/check.pm
new file mode 100644
index 00000000..d1271290
--- /dev/null
+++ b/fml/lib/FML/Command/Admin/check.pm
@@ -0,0 +1,190 @@
+#-*- perl -*-
+#
+# Copyright (C) 2002 Ken'ichi Fukamachi
+# All rights reserved. This program is free software; you can
+# redistribute it and/or modify it under the same terms as Perl itself.
+#
+# $FML: check.pm,v 1.4 2002/04/07 05:01:33 fukachan Exp $
+#
+
+package FML::Command::Admin::check;
+use strict;
+use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD);
+use Carp;
+use FML::Log qw(Log LogWarn LogError);
+
+
+=head1 NAME
+
+FML::Command::Admin::check - checknostic
+
+=head1 SYNOPSIS
+
+See C<FML::Command> for more detaicheck.
+
+=head1 DESCRIPTION
+
+show user check(s).
+
+=cut
+
+
+# Descriptions: standard constructor
+# Arguments: OBJ($self)
+# Side Effects: none
+# Return Value: OBJ
+sub new
+{
+ my ($self) = @_;
+ my ($type) = ref($self) || $self;
+ my $me = {};
+ return bless $me, $type;
+}
+
+
+# Descriptions: need lock or not
+# Arguments: none
+# Side Effects: none
+# Return Value: NUM( 1 or 0)
+sub need_lock { 0;}
+
+my @rules = qw(
+ check_spool_dir
+ check_html_archive_dir
+ );
+
+
+# Descriptions: checknostics
+# Arguments: OBJ($self) OBJ($curproc) HASH_REF($command_args)
+# Side Effects: none
+# Return Value: none
+sub process
+{
+ my ($self, $curproc, $command_args) = @_;
+ my $config = $curproc->{ config };
+
+ for my $rule (@rules) {
+ $self->$rule($curproc, $command_args);
+ }
+}
+
+
+# Descriptions: check spool permission
+# Arguments: OBJ($self) OBJ($curproc) HASH_REF($command_args)
+# Side Effects: fix permission
+# Return Value: none
+sub check_spool_dir
+{
+ my ($self, $curproc, $command_args) = @_;
+ my $config = $curproc->{ config };
+ my $spool_dir = $config->{ spool_dir };
+
+ #
+ # 1. $spool_dir exists ?
+ #
+ print "spool_dir exists ? ... ";
+ if (-d $spool_dir) {
+ print "ok\n";
+ }
+ else {
+ print "fail. not exist\n";
+ -d $spool_dir || midir($spool_dir, 0700);
+ print " created $spool_dir\n";
+ }
+
+ #
+ # 2. $spool_dir permission should be 0700.
+ #
+ print "spool_dir permission ... ";
+ print _is_700($spool_dir) ? "ok" : "fail";
+ printf " (0%o)\n", _dir_mode($spool_dir);
+}
+
+
+
+# Descriptions: check html_archive permission
+# Arguments: OBJ($self) OBJ($curproc) HASH_REF($command_args)
+# Side Effects: fix permission
+# Return Value: none
+sub check_html_archive_dir
+{
+ my ($self, $curproc, $command_args) = @_;
+ my $config = $curproc->{ config };
+ my $html_dir = $config->{ html_archive_dir };
+
+ print "html_archive_dir ... ";
+ print _is_755($html_dir) ? "ok" : "fail";
+ printf " (0%o)\n", _dir_mode($html_dir);
+}
+
+
+sub _dir_mode
+{
+ my ($dir) = @_;
+ my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
+ $atime,$mtime,$ctime,$blksize,$blocks) = stat($dir);
+
+ return ($mode & 0777);
+}
+
+
+sub _is_700
+{
+ my ($dir) = @_;
+ my $mode = _dir_mode($dir);
+
+ my $smode = sprintf("%o", $mode);
+ return ($smode eq '700' ? 1 : 0);
+}
+
+
+sub _is_770
+{
+ my ($dir) = @_;
+ my $mode = _dir_mode($dir);
+
+ my $smode = sprintf("%o", $mode);
+ return ($smode eq '770' ? 1 : 0);
+}
+
+
+sub _is_777
+{
+ my ($dir) = @_;
+ my $mode = _dir_mode($dir);
+
+ my $smode = sprintf("%o", $mode);
+ return ($smode eq '777' ? 1 : 0);
+}
+
+
+sub _is_755
+{
+ my ($dir) = @_;
+ my $mode = _dir_mode($dir);
+
+ my $smode = sprintf("%o", $mode);
+ return ($smode eq '755' ? 1 : 0);
+}
+
+
+=head1 AUTHOR
+
+Ken'ichi Fukamachi
+
+=head1 COPYRIGHT
+
+Copyright (C) 2002 Ken'ichi Fukamachi
+
+All rights reserved. This program is free software; you can
+redistribute it and/or modify it under the same terms as Perl itself.
+
+=head1 HISTORY
+
+FML::Command::Admin::check appeared in fml5 mailing check driver package.
+See C<http://www.fml.org/> for more detaicheck.
+
+=cut
+
+
+1;