Double
This commit is contained in:
parent
64259f65ee
commit
e99aa72560
|
@ -1,92 +0,0 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
use Lemonldap::NG::Common::Conf;
|
||||
use Lemonldap::NG::Common::Conf::Constants;
|
||||
use Data::Dumper;
|
||||
use English qw(-no_match_vars);
|
||||
use File::Temp;
|
||||
use POSIX qw(setuid setgid);
|
||||
use strict;
|
||||
|
||||
eval {
|
||||
setgid( ( getgrnam('__APACHEGROUP__') )[2] );
|
||||
setuid( ( getpwnam('__APACHEUSER__') )[2] );
|
||||
print STDERR "Running as uid $EUID and gid $EGID\n";
|
||||
};
|
||||
|
||||
if ( $EUID == 0 ) {
|
||||
print STDERR
|
||||
"$0 must not be launched as root since local cache can be corrupted\n"
|
||||
. "Continue (y/N)? ";
|
||||
my $res = <STDIN>;
|
||||
exit 1 unless ( $res =~ /^y/i );
|
||||
}
|
||||
|
||||
my $conf = Lemonldap::NG::Common::Conf->new();
|
||||
|
||||
unless ($conf) {
|
||||
print STDERR $Lemonldap::NG::Common::Conf::msg;
|
||||
exit 1;
|
||||
}
|
||||
|
||||
my $tmp = $conf->getConf();
|
||||
delete $tmp->{reVHosts};
|
||||
delete $tmp->{cipher};
|
||||
delete $tmp->{cfgAuthor};
|
||||
delete $tmp->{cfgAuthorIP};
|
||||
delete $tmp->{cfgDate};
|
||||
$tmp = Dumper($tmp);
|
||||
my $refFile = File::Temp->new( UNLINK => 1 );
|
||||
my $editFile = File::Temp->new( UNLINK => 1 );
|
||||
print $refFile $tmp;
|
||||
print $editFile $tmp;
|
||||
close $refFile;
|
||||
close $editFile;
|
||||
|
||||
system "editor $editFile";
|
||||
|
||||
if (`diff $refFile $editFile`) {
|
||||
my $VAR1;
|
||||
my $buf;
|
||||
|
||||
# Check if the new configuration hash is valid
|
||||
open F1, $editFile->filename();
|
||||
while (<F1>) {
|
||||
$buf .= $_;
|
||||
}
|
||||
eval $buf;
|
||||
die $EVAL_ERROR if $EVAL_ERROR;
|
||||
|
||||
# Update author and date
|
||||
$VAR1->{cfgAuthor} = "lmConfigEditor";
|
||||
$VAR1->{cfgAuthorIP} = "localhost";
|
||||
$VAR1->{cfgDate} = time();
|
||||
|
||||
# Store new configuration
|
||||
my $res = $conf->saveConf($VAR1);
|
||||
if ( $res > 0 ) {
|
||||
print STDERR "Configuration $res saved\n";
|
||||
}
|
||||
else {
|
||||
print STDERR "Configuration was not saved:\n ";
|
||||
if ( $res == CONFIG_WAS_CHANGED ) {
|
||||
print STDERR "Configuration has changed\n";
|
||||
}
|
||||
elsif ( $res == DATABASE_LOCKED ) {
|
||||
print STDERR "Configuration database is or can nor be locked\n";
|
||||
}
|
||||
elsif ( $res == UPLOAD_DENIED ) {
|
||||
print STDERR "You're not authorized to save this configuration\n";
|
||||
}
|
||||
elsif ( $res == SYNTAX_ERROR ) {
|
||||
print STDERR "Syntax error in your configuration\n";
|
||||
}
|
||||
elsif ( $res == UNKNOWN_ERROR ) {
|
||||
print STDERR "Unknown error\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
print STDERR "Configuration not changed\n";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user