die "you must be root to install F*EX\n";
}
-goto INSTALL if $0 =~ /upgrade$/;
-
$fex = 'fex.rus.uni-stuttgart.de';
if (system("host $fex >/dev/null") != 0) {
die "host $fex is not resolvable - check /etc/resolv.conf\n";
}
-if (`uname` =~ /^SunOS/) {
- die "Solaris is currently not supported. "
- ."Please contact framstag\@rus.uni-stuttgart.de for details.\n";
-}
-
$opt_p = 80;
if (open $xinetd,$xinetd) {
if (/^\s*port\s*=\s*(\d+)/) {
$opt_p = $fexport = $1;
}
- if (/^\s*bind\s*=\s*([\d.]+)/) {
+ if (/^\s*bind\s*=\s*([\d.]+)$/) {
$fexip = $ip = $1;
}
}
close $xinetd;
}
+goto INSTALL if $0 =~ /upgrade$/;
+
+if (`uname` =~ /^SunOS/) {
+ die "Solaris is currently not supported. "
+ ."Please contact framstag\@rus.uni-stuttgart.de for details.\n";
+}
+
getopts('p:') or die $usage;
$arg = shift;
$ip = $arg || $fexip || 0;
}
-
# if (not $ip and open P,"ifconfig 2>/dev/null |") {
if (not $ip and open P,'host $(hostname)|') {
$guessed_ip = 0;
$ip ||= $guessed_ip;
}
-$ip =~ /^\d+\.\d+\.\d+\.\d+$/ or die $usage;
($hostname) = gethostbyaddr(gethostbyname($ip),AF_INET);
die "cannot find hostname for IP $ip\n" unless $hostname;
@FEX = getpwnam('fex') or die "no user fex\n";
$FEXHOME = $FEX[7];
+$ENV{HOME} = $FEXHOME; # needed for later eval fex.ph
die "no HOME directory for user fex\n" unless -d $FEXHOME;
+if ($FEXHOME !~ /fex/) {
+ print "HOME=$FEXHOME for user fex does not contain \"fex\"\n";
+ print "REALLY continue?! ";
+ $_ = <STDIN>;
+ exit unless /^y/i;
+}
print "Installing:\n";
+$pecl = "$FEXHOME/perl/Encode/ConfigLocal.pm";
+unless (-f $pecl) {
+ mkdir "$FEXHOME/perl";
+ mkdir "$FEXHOME/perl/Encode";
+ open $pecl,'>',$pecl or die "$0: cannot write $pecl - $!\n";
+ print {$pecl}
+ "# hack for broken Perl in SuSe and Solaris, used via \@INC in fexsrv\n",
+ "1;\n";
+ close $pecl;
+ print $pecl,"\n";
+ chownr('fex:root',"$FEXHOME/perl");
+}
+
@save = (
"lib/fex.ph",
"lib/fup.pl",
$hl = "$FEXHOME/htdocs/locale";
unless (-d $hl) { mkdir $hl or die "$0: cannot mkdir $hl - $!\n" }
-if (-d "$FEXHOME/spool") {
- warn "checking spool ...\n";
- &convert_spool;
- system "chown -R fex $spooldir/";
-} else {
- $newinstall = $FEXHOME;
- chmod 0700,$FEXHOME;
- mkdir "$FEXHOME/spool",0700 or die "cannot mkdir $FEXHOME/spool - $!\n";
- mkdir "$FEXHOME/spool/.error",0700;
- system "chown -R fex $FEXHOME/spool";
-}
-
foreach $s (@save) {
$f = "$FEXHOME/$s";
$fs = $f.'_save';
$fn = $f.'_new';
if (-e $fs) {
- system "rm -rf $fn";
+ unlink $fn;
rename $f,$fn and print "$f --> $fn\n";
rename $fs,$f and print "$fs --> $f\n";
}
}
+if (-d "$FEXHOME/spool") {
+ warn "checking $FEXHOME/spool ...\n";
+ &convert_spool;
+} else {
+ $newinstall = $FEXHOME;
+ chmod 0700,$FEXHOME;
+ mkdir "$FEXHOME/spool",0700 or die "cannot mkdir $FEXHOME/spool - $!\n";
+ mkdir "$FEXHOME/spool/.error",0700;
+}
+chownr('fex',"$FEXHOME/spool/.");
+
system(qw'perl -p -i -e',
's:href="/?FAQ.html":href="/FAQ/FAQ.html":',
"$FEXHOME/lib/fup.pl"
close $fph;
eval $conf;
-$spooldir ||= "$FEXHOME/spool";
+
+die "no \$spooldir in $fph\n" unless $spooldir;
+die "\$spooldir=$spooldir is not a directory, see $fph\n" unless -d $spooldir;
+symlink $spooldir,"$FEXHOME/spool" unless -e "$FEXHOME/spool";
+@sds1 = stat "$spooldir/.";
+@sds2 = stat "$FEXHOME/spool/.";
+if ("@sds1" ne "@sds2") {
+ die "$FEXHOME/spool is not a symbolic link to \$spooldir=$spooldir\n";
+}
$fid = "$FEXHOME/.fex/id";
$aa = "$spooldir/$admin/@";
-if ($newinstall) {
+if ($newinstall or not -s $aa) {
print "\n";
for (;;) {
print "Server hostname [$hostname] : ";
}
}
-sub mkfid {
- my $ad = dirname($aa);
- mkdir $ad;
- open $aa,'>',$aa or die "$0: cannot create $aa - $!\n";
- print {$aa} "$admin_pw\n";
- close $aa;
- my $fd = dirname($fid);
- mkdir $fd;
- rename $fid,$fid.'_save';
- open $fid,'>',$fid or die "$0: cannot create $fid - $!\n";
- print {$fid} "$hostname:$opt_p\n";
- print {$fid} "$admin\n";
- print {$fid} "$admin_pw\n";
- close $fid;
- chmod 0700,$fd;
- system "chown -R fex $fd $ad";
-}
-
open $fph,">$fph.new" or die "$0: cannot write $fph.new - $!\n";
print {$fph} $conf;
close $fph;
do $fph or die "$0: error in new $fph - $!\n";
-rename "locale/deutsch","locale/german" if -d "locale/deutsch";
-rename "locale/espanol","locale/spanish" if -d "locale/espanol";
-
if (@locales = glob "locale/*/lib/fup.pl") {
foreach (@locales) {
m{locale/(.+?)/} and $locale = $1;
if (-f "$FEXHOME/$_") {
system 'locale/translate',$locale;
- system "chown -R fex $FEXHOME/locale/$locale";
+ chownr('fex',"$FEXHOME/locale/$locale");
$hl = "$FEXHOME/htdocs/locale/$locale";
symlink "$FEXHOME/locale/$locale/htdocs",$hl unless -l $hl;
} else {
system qw(crontab -u fex fex.cron);
}
- system "chown -R fex:root $FEXHOME $FEXHOME/spool/";
- system "chmod -R go-r $FEXHOME/lib $FEXHOME/cgi-bin $FEXHOME/spool/";
+ chownr('fex:root',"$FEXHOME $FEXHOME/spool/.");
+ chmodr('go-r',"$FEXHOME/lib","$FEXHOME/cgi-bin","$FEXHOME/spool/.");
print "\n";
print "Now check configuration file $FEXHOME/lib/fex.ph and run\n";
print "(You can do this as user \"fex\")\n";
} else {
- system "chmod -R go-r $FEXHOME/lib $FEXHOME/cgi-bin";
+ chmodr('go-r',"$FEXHOME/lib","$FEXHOME/cgi-bin");
print "\n";
print "F*EX update installed.\n";
print "You MUST set in your exim4.conf:\n";
print "trusted_users = mail : uucp : fex\n";
}
+
exit;
+sub mkfid {
+ my $ad = dirname($aa);
+ mkdir $ad;
+ open $aa,'>',$aa or die "$0: cannot create $aa - $!\n";
+ print {$aa} "$admin_pw\n";
+ close $aa;
+ my $fd = dirname($fid);
+ mkdir $fd;
+ rename $fid,$fid.'_save';
+ open $fid,'>',$fid or die "$0: cannot create $fid - $!\n";
+ print {$fid} "$hostname:$opt_p\n";
+ print {$fid} "$admin\n";
+ print {$fid} "$admin_pw\n";
+ close $fid;
+ chownr('fex',$ad,$fd);
+ chmod 0700,$ad,$fd;
+}
+
+sub chownr {
+ my $user = shift;
+ local $_;
+ foreach (@_) {
+ if (m:^/*(lib|usr|home)?/*$:) {
+ die "ERROR: short path in chownr $user @_\n";
+ }
+ }
+ system qw'chown -R',$user,@_;
+}
+
+sub chmodr {
+ my $mod = shift;
+ local $_;
+ foreach (@_) {
+ if (m:^/*(lib|usr|home)?/*$:) {
+ die "ERROR: short path in chmodr $mod @_\n";
+ }
+ }
+ system qw'chmod -R',$mod,@_;
+}
sub convert_spool {
my ($f,$d,$to,$from,$link);
local $) = $FEX[3];
- local $> = $FEX[2];
+ local $> = $FEX[2];
our ($spooldir,$skeydir,$gkeydir);
$ENV{FEXLIB} = $FEXLIB = "$FEXHOME/lib";
require "$FEXLIB/fex.pp" or die "$0: cannot load $FEXLIB/fex.pp - $!\n";
+ die "no \$spooldir in $FEXLIB/fex.pp\n" unless $spooldir;
+ die "\$spooldir=$spooldir/" if $spooldir =~ m:^/*(root)?$:;
# User --> user@maildomain
if ($mdomain) {
# create new GKEYs
foreach my $gf (glob "$spooldir/*/\@GROUP/*") {
next unless -f $gf;
+ # normalize group name
+ if ($gf =~ m:(.+)/(.+):) {
+ my $gd = $1;
+ my $g1 = $2;
+ my $g2 = $2;
+ $g2 =~ s/[^\w\*%^+=:,.!-]/_/g;
+ if ($g1 ne $g2) {
+ rename "$gd/$g1","$gd/$g2" and $gf = "$gd/$g2";
+ }
+ }
$group = (split '/',$gf)[-1];
$user = (split '/',$gf)[-3];
if (open $gf,$gf) {