diff --git a/e2e-tests/custom.pm b/e2e-tests/custom.pm index a58794f0e..6174730aa 100644 --- a/e2e-tests/custom.pm +++ b/e2e-tests/custom.pm @@ -17,7 +17,7 @@ sub accessToTrace { my $params = $hash->{params}; my $session = $hash->{session}; - return "$custom alias $params->[0]_$params->[1]:$session->{groups} with $session->{$params->[2]}"; + return "$custom alias $params->[0]_$params->[1]:$session->{groups} ($session->{$params->[2]})"; } 1; diff --git a/e2e-tests/lmConf-1.json b/e2e-tests/lmConf-1.json index cc40fcc93..56dab1a9f 100644 --- a/e2e-tests/lmConf-1.json +++ b/e2e-tests/lmConf-1.json @@ -171,7 +171,7 @@ "vhostHttps": -1, "vhostAliases": "", "vhostServiceTokenTTL": -1, - "vhostAccessToTrace": "My::accessToTrace, Doctor, Who","vhostType":"Main" + "vhostAccessToTrace": "My::accessToTrace, Doctor, Who, _whatToTrace","vhostType":"Main" } }, "loginHistoryEnabled": 1, diff --git a/lemonldap-ng-common/scripts/lemonldap-ng-cli b/lemonldap-ng-common/scripts/lemonldap-ng-cli index e8fc87e8a..176d54b3e 100755 --- a/lemonldap-ng-common/scripts/lemonldap-ng-cli +++ b/lemonldap-ng-common/scripts/lemonldap-ng-cli @@ -65,8 +65,9 @@ Options: - safe <0|1> : fail in case the requested configuration is invalid - force <0|1> : allow overwrite of existing config number - cfgNum : set new configuration number (requires -force 1) + - nohistory : do not increment configuration number (requires -force 1) - sep : separator of hierarchical values (by default: /) - - iniFile : path to an alternate lemonldap-ng.ini file + - iniFile : path to an alternative lemonldap-ng.ini file See Lemonldap::NG::Manager::Cli(3) for more }; @@ -170,13 +171,25 @@ Allows you to set the log message that will be displayed in the manager The configuration change will be aborted if it contains errors (default: 0) +=item -force + +Allows you to force overwriting an existing configuration (default: 0) + =item -cfgNum Choose a particular configuration number (default: latest) -=item -force +=item -nohistory -Allows you to force overwriting an existing configuration (default: 0) +Allows you to keep current configuration number + +=item -sep + +Allows you to define hierarchical separator + +=item -iniFile + +Allows you to set an alternative ini file =back @@ -189,11 +202,13 @@ L =over -=item David Coutateur, Edavid.jose.delassus@gmail.comE +=item Clement Oudot, Eclement@oodo.netE -=item Clement Oudot, Eclem.oudot@gmail.comE +=item Xavier Guimard, Eyadd@debian.orgE -=item Xavier Guimard, Ex.guimard@free.frE +=item Maxime Besson, Emaxime.besson@worteks.comE + +=item Christophe Maudoux, Echrmdx@gmail.comE =back @@ -205,7 +220,7 @@ L =head1 DOWNLOAD Lemonldap::NG is available at -L +L =head1 COPYRIGHT AND LICENSE diff --git a/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Main/Reload.pm b/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Main/Reload.pm index c7804796d..cfb24ab58 100644 --- a/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Main/Reload.pm +++ b/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Main/Reload.pm @@ -1,6 +1,6 @@ package Lemonldap::NG::Handler::Main::Reload; -our $VERSION = '2.0.10'; +our $VERSION = '2.0.12'; package Lemonldap::NG::Handler::Main; @@ -59,9 +59,16 @@ sub checkConf { } $Lemonldap::NG::Common::Conf::msg = ''; - if ( $force or !$class->cfgNum or $class->cfgNum != $conf->{cfgNum} ) { + if ( $force + or !$class->cfgNum + or !$class->cfgDate + or $class->cfgNum != $conf->{cfgNum} + or $class->cfgDate != $conf->{cfgDate} ) + { $class->logger->debug("Get configuration $conf->{cfgNum}"); - unless ( $class->cfgNum( $conf->{cfgNum} ) ) { + unless ( $class->cfgNum( $conf->{cfgNum} ) + && $class->cfgDate( $conf->{cfgDate} ) ) + { $class->logger->error('No configuration available'); return 0; } @@ -80,7 +87,7 @@ sub checkConf { } } } - $class->checkTime($conf->{checkTime}) if ( $conf->{checkTime} ); + $class->checkTime( $conf->{checkTime} ) if $conf->{checkTime}; $class->lastCheck( time() ); $class->logger->debug("$class: configuration is up to date"); return 1; diff --git a/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Main/SharedVariables.pm b/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Main/SharedVariables.pm index 67906127e..24a65fd1c 100644 --- a/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Main/SharedVariables.pm +++ b/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Main/SharedVariables.pm @@ -1,8 +1,8 @@ package Lemonldap::NG::Handler::Main::SharedVariables; -our $VERSION = '2.0.0'; +our $VERSION = '2.0.12'; -# Since handler has no instances but only static classes, this module provides +# Since handler has no instance but only static classes, this module provides # classes properties with accessors package Lemonldap::NG::Handler::Main; @@ -14,6 +14,7 @@ BEGIN { our $_tshv = { tsv => {}, cfgNum => 0, + cfgDate => 0, lastCheck => 0, checkTime => 600, confAcc => {}, @@ -30,7 +31,7 @@ BEGIN { foreach ( keys %$_tshv ) { eval " sub $_ { my \$v = \$_[1]; - \$_tshv->{$_} = \$v if(defined \$v); + \$_tshv->{$_} = \$v if (defined \$v); return \$_tshv->{$_}; }"; die $@ if ($@); @@ -41,7 +42,7 @@ BEGIN { foreach ( keys %$_v ) { eval " sub $_ { my \$v = \$_[1]; - \$_v->{$_} = \$v if(\$v); + \$_v->{$_} = \$v if (\$v); return \$_v->{$_}; }"; die $@ if ($@); diff --git a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Cli.pm b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Cli.pm index f8bb665dc..0faa5aaff 100644 --- a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Cli.pm +++ b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Cli.pm @@ -7,7 +7,7 @@ use Data::Dumper; use JSON; use Lemonldap::NG::Common::Conf::ReConstants; -our $VERSION = '2.0.10'; +our $VERSION = '2.0.12'; $Data::Dumper::Useperl = 1; extends('Lemonldap::NG::Manager::Cli::Lib'); @@ -29,6 +29,7 @@ has format => ( is => 'rw', isa => 'Str', default => "%-25s | %-25s | %-25s" ); has yes => ( is => 'rw', isa => 'Bool', default => 0 ); has safe => ( is => 'rw', isa => 'Bool', default => 0 ); has force => ( is => 'rw', isa => 'Bool', default => 0 ); +has nohistory => ( is => 'rw', isa => 'Bool', default => 0 ); has logger => ( is => 'ro', lazy => 1, builder => sub { $_[0]->mgr->logger } ); has userLogger => ( is => 'ro', lazy => 1, builder => sub { $_[0]->mgr->userLogger } ); @@ -355,7 +356,7 @@ sub rollback { or die $Lemonldap::NG::Common::Conf::msg; $conf->{cfgNum} = $lastCfg; - $conf->{cfgAuthor} = scalar( getpwuid $< ) . '(command-line-interface)'; + $conf->{cfgAuthor} = scalar( getpwuid $< ) . ' (command-line-interface)'; chomp $conf->{cfgAuthor}; $conf->{cfgAuthorIP} = '127.0.0.1'; $conf->{cfgDate} = time; @@ -416,8 +417,7 @@ sub _setKey { sub _save { my ( $self, $new ) = @_; require Lemonldap::NG::Manager::Conf::Parser; - my $parser = Lemonldap::NG::Manager::Conf::Parser->new( - { + my $parser = Lemonldap::NG::Manager::Conf::Parser->new( { newConf => $new, refConf => $self->mgr->hLoadedPlugins->{conf}->currentConf, req => $self->req @@ -433,6 +433,7 @@ sub _save { print STDERR "$msg\n"; } } + my $saveParams = { force => $self->force }; if ( $self->force and $self->cfgNum ) { $self->logger->debug( "CLI: cfgNum forced with " . $self->cfgNum ); @@ -440,6 +441,15 @@ sub _save { $saveParams->{cfgNum} = $self->cfgNum; $saveParams->{cfgNumFixed} = 1; } + if ( $self->force and $self->nohistory ) { + my $lastCfg = $self->mgr->confAcc->lastCfg; + $self->logger->debug( + "CLI: No history required. cfgNum forced with " . $lastCfg ); + print STDERR "No history required. cfgNum forced with ", $lastCfg; + $saveParams->{cfgNum} = $lastCfg; + $saveParams->{cfgNumFixed} = 1; + } + $new->{cfgAuthor} = scalar( getpwuid $< ) . '(command-line-interface)'; chomp $new->{cfgAuthor}; $new->{cfgAuthorIP} = '127.0.0.1'; diff --git a/lemonldap-ng-manager/scripts/lmConfigEditor b/lemonldap-ng-manager/scripts/lmConfigEditor old mode 100644 new mode 100755 diff --git a/lemonldap-ng-manager/t/16-cli.t b/lemonldap-ng-manager/t/16-cli.t index a8ea73514..f4723fba2 100644 --- a/lemonldap-ng-manager/t/16-cli.t +++ b/lemonldap-ng-manager/t/16-cli.t @@ -4,7 +4,7 @@ use JSON; use strict; require 't/test-lib.pm'; -my $tests = 17; +my $tests = 18; use_ok('Lemonldap::NG::Common::Cli'); use_ok('Lemonldap::NG::Manager::Cli'); @@ -77,6 +77,14 @@ combined_like( '"Force cfgNum" OK' ); +# Test 'set' command with nohistory +@cmd = qw(-yes 1 -force 1 -nohistory 1 set cookieName test); +combined_like( + sub { llclient->run(@cmd) }, + qr#cfgNum forced with 6#s, + '"Force cfgNum" OK' +); + # Test 'info' command with force @cmd = qw(info); combined_like(