Mail-IspMailGate
view release on metacpan or search on metacpan
lib/Mail/IspMailGate/Install.pm view on Meta::CPAN
# 72555 Metzingen
# Germany
#
# Email: joe@ispsoft.de
# Phone: +49 7123 14887
#
#
# Version history: 05-Sep-1999 Initial version (Jochen)
#
############################################################################
use strict;
use File::Path ();
use File::Find ();
use File::Copy ();
use File::Spec ();
use ExtUtils::MakeMaker ();
use Exporter ();
use Getopt::Long ();
use Cwd();
package Mail::IspMailGate::Install;
use vars qw($VERSION @ISA @EXPORT $config);
$VERSION = '1.1013';
@ISA = qw(Exporter);
@EXPORT = qw(Install);
sub Install {
my $self = shift;
require Mail::IspMailGate::Config;
my $inc_path = $INC{'Mail/IspMailGate/Config.pm'};
if (!$self) {
$self = $Mail::IspMailGate::Config::config;
}
my $tmp_dir = $self->{'tmp_dir'};
my $created = ! -d $tmp_dir;
if ($created) {
File::Path::mkpath($tmp_dir, 0, 0700);
}
my($dev,$ino,$mode,$nlink,$uid,$gid) = stat $tmp_dir;
my $tuid = $self->{'mail_user'};
if ($tuid !~ /^\d+$/) {
$tuid = getpwnam($tuid)
or die "Failed to determine UID of $self->{'mail_user'}}.\n",
"Check mail_user in $inc_path.\n";
}
my $tgid = $self->{'mail_group'};
if ($tgid !~ /^\d+$/) {
$tgid = getgrnam($tgid)
or die "Failed to determine GID of $self->{'mail_group'}.\n",
"Check mail_group in $inc_path.\n";
}
if ($gid != $tgid || $uid != $tuid) {
if ($created) {
chown $tuid, $tgid, $tmp_dir;
} else {
die "Directory $tmp_dir doesn't have user $self->{'mail_user'}\n",
"or group $self->{'mail_group'}. Please fix that or change\n",
"mail_user and mail_group in $inc_path.\n",
"and reinstall.\n";
}
}
if ($mode & 07777 != 0700) {
die "Directory $tmp_dir has insecure permissions. Please change",
"that to -rwx------ and reinstall.\n";
}
$self;
}
sub Prompt {
my($self, $query, $default) = @_;
$main::prompt ? ExtUtils::MakeMaker::prompt($query, $default) : $default;
}
sub new {
my $proto = shift; my $file = shift;
$proto ||= "Mail::IspMailGate::Install";
$file ||= "lib/Mail/IspMailGate/Config.pm";
my $cfg = ref($proto) ? $proto : eval {
require Mail::IspMailGate::Config;
$Mail::IspMailGate::Config::config;
} || {};
bless($cfg, (ref($proto) || $proto));
my %opt;
Getopt::Long::GetOptions(\%opt, "tar-path=s", "sendmail-path=s",
"gzip-path=s", "unzip-path=s", "unarj-path=s",
"lha-path=s", "antivir-path=s", "pgp-path=s",
"tmp-dir=s", "unix-sock=s", "pid-file=s",
"facility=s", "mail-user=s", "mail-group=s",
"domain=s", "postmaster=s", "mail-host=s",
"my-mail=s");
$config ||= -f $file;
$cfg->{'VERSION'} = $VERSION;
my $query_path = sub {
my @args;
if (ref($_[0]) eq 'ARRAY') {
push(@args, shift())
}
my $prog = (@_ > 1) ? shift() : $_[0];
push(@args, @_);
my $spath;
if (ref($prog)) {
$spath = $prog;
$prog = shift;
}
my $var = $prog . "_path";
if (exists($opt{$prog . "-path"})) {
$cfg->{$var} = $opt{$prog . "-path"};
} elsif ($config || !defined($cfg->{$var})) {
( run in 1.253 second using v1.01-cache-2.11-cpan-71847e10f99 )