LEMONLDAP::NG : little new utility: command-line configuration editor

This commit is contained in:
Xavier Guimard 2007-04-29 14:36:57 +00:00
parent ef4b7876b6
commit cd0cf7e840
8 changed files with 94 additions and 5 deletions

View File

@ -1,5 +1,5 @@
debian/tmp/usr/share/perl5/Lemonldap/NG/Manager/Conf*
debian/tmp/usr/share/man/man3/Lemonldap::NG::Manager::Conf*
debian/tmp/usr/share/man/man1/lmConfig_File2MySQL.1p
debian/tmp/usr/bin/lmConfig_File2MySQL
debian/tmp/usr/bin/lmConfig*
example/conf /var/lib/lemonldap-ng/

View File

@ -3,8 +3,8 @@
. /usr/share/debconf/confmodule
if [ "$1" = "configure" ]
if [ "$1" == "configure" ]
then
chown -R www-data /usr/share/doc/lemonldap-ng/examples/conf
chown -R www-data /var/lib/lemonldap-ng/conf
fi

View File

@ -1,5 +1,15 @@
Revision history for Perl extension Lemonldap::NG::Manager.
0.64 Sun Apr 29 16:18:31 2007
- File permissions fix to 0640 in File.pm
- Multiple configuration in the same server is now possible
- LDAP help in english
- LDAPS documentation
- Javascript control (an XML id can not start with a number)
- whatToTrace parameter in configuration interface
- Fix tree bug when an hash ref is not defined
- More tests
0.61 Thu Mar 29 21:45:44 2007
- configuration is checked before saving

View File

@ -48,6 +48,7 @@ example/lemonldap-ng-manager.js
example/lmConfig.mysql
example/index.pl
example/scripts/lmSessionDump
example/scripts/lmConfigEditor
example/soapserver.pl
lib/Lemonldap/NG/Manager.pm
lib/Lemonldap/NG/Manager/Apache/Session/SOAP.pm

View File

@ -0,0 +1,75 @@
#!/usr/bin/perl
use Lemonldap::NG::Manager::Conf;
use Lemonldap::NG::Manager::Conf::Constants;
use Data::Dumper;
use strict;
our $refFile = `mktemp`;
our $editFile = `mktemp`;
chomp $refFile;
chomp $editFile;
my $conf = Lemonldap::NG::Manager::Conf->new(
{
type => 'File',
dirName => '__CONFDIR__',
}
);
open F1, ">$refFile" or quit($!);
open F2, ">$editFile" or quit($!);
my $tmp = Dumper($conf->getConf);
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;
}

View File

@ -16,7 +16,7 @@ use MIME::Base64;
our @ISA = qw(Lemonldap::NG::Manager::Base);
our $VERSION = '0.63';
our $VERSION = '0.64';
sub new {
my ( $class, $args ) = @_;

View File

@ -195,7 +195,7 @@ getConf returns all (C<select * from lmConfig>).
=back
=item B<saveConf>: stores the Lemonldap::NG configuration passed in argument
=item * B<saveConf>: stores the Lemonldap::NG configuration passed in argument
(hash reference). it returns the number of the new configuration.
=back

View File

@ -60,6 +60,8 @@ sub unlock {
sub store {
my ( $self, $fields ) = @_;
my $mask = umask;
umask ( oct ( '0027' ) );
unless( open FILE, '>' . $self->{dirName} . "/lmConf-" . $fields->{cfgNum} ) {
print STDERR "Open file failed: $!";
$self->unlock;
@ -69,6 +71,7 @@ sub store {
print FILE "$k\n\t$v\n\n";
}
close FILE;
umask( $mask );
$self->unlock;
return $fields->{cfgNum};
}