2007-04-29 16:36:57 +02:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
2008-11-17 17:59:56 +01:00
|
|
|
use Lemonldap::NG::Common::Conf;
|
|
|
|
use Lemonldap::NG::Common::Conf::Constants;
|
2007-04-29 16:36:57 +02:00
|
|
|
use Data::Dumper;
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
our $refFile = `mktemp`;
|
|
|
|
our $editFile = `mktemp`;
|
|
|
|
|
|
|
|
chomp $refFile;
|
|
|
|
chomp $editFile;
|
|
|
|
|
2008-12-22 18:49:36 +01:00
|
|
|
my $conf = Lemonldap::NG::Common::Conf->new();
|
2007-04-29 16:36:57 +02:00
|
|
|
|
|
|
|
open F1, ">$refFile" or quit($!);
|
|
|
|
open F2, ">$editFile" or quit($!);
|
2009-09-23 14:42:34 +02:00
|
|
|
my $tmp = $conf->getConf();
|
|
|
|
delete $tmp->{reVHosts};
|
|
|
|
delete $tmp->{cipher};
|
|
|
|
$tmp = Dumper($tmp);
|
2007-04-29 16:36:57 +02:00
|
|
|
print F1 $tmp;
|
|
|
|
print F2 $tmp;
|
|
|
|
close F1;
|
|
|
|
close F2;
|
|
|
|
|
|
|
|
system "editor $editFile";
|
|
|
|
|
|
|
|
if(`diff $refFile $editFile`) {
|
|
|
|
my $VAR1;
|
|
|
|
my $buf;
|
|
|
|
open F1, $editFile;
|
|
|
|
while(<F1>) {
|
|
|
|
$buf .= $_;
|
|
|
|
}
|
|
|
|
eval $buf;
|
|
|
|
quit($@) if($@);
|
|
|
|
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";
|
|
|
|
}
|
|
|
|
|
|
|
|
unlink $editFile;
|
|
|
|
unlink $refFile;
|
|
|
|
|
|
|
|
sub quit {
|
|
|
|
unlink $editFile;
|
|
|
|
unlink $refFile;
|
|
|
|
print STDERR "$_[0]\n";
|
|
|
|
exit 1;
|
|
|
|
}
|