Check conf. timestamp to reload (#2508)
This commit is contained in:
parent
96dbbd9ad4
commit
0f40e2d1bb
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 <num> : set new configuration number (requires -force 1)
|
||||
- nohistory : do not increment configuration number (requires -force 1)
|
||||
- sep <char> : separator of hierarchical values (by default: /)
|
||||
- iniFile <file> : path to an alternate lemonldap-ng.ini file
|
||||
- iniFile <file> : 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<http://lemonldap-ng.org/>
|
|||
|
||||
=over
|
||||
|
||||
=item David Coutateur, E<lt>david.jose.delassus@gmail.comE<gt>
|
||||
=item Clement Oudot, E<lt>clement@oodo.netE<gt>
|
||||
|
||||
=item Clement Oudot, E<lt>clem.oudot@gmail.comE<gt>
|
||||
=item Xavier Guimard, E<lt>yadd@debian.orgE<gt>
|
||||
|
||||
=item Xavier Guimard, E<lt>x.guimard@free.frE<gt>
|
||||
=item Maxime Besson, E<lt>maxime.besson@worteks.comE<gt>
|
||||
|
||||
=item Christophe Maudoux, E<lt>chrmdx@gmail.comE<gt>
|
||||
|
||||
=back
|
||||
|
||||
|
@ -205,7 +220,7 @@ L<https://gitlab.ow2.org/lemonldap-ng/lemonldap-ng/issues>
|
|||
=head1 DOWNLOAD
|
||||
|
||||
Lemonldap::NG is available at
|
||||
L<http://forge.objectweb.org/project/showfiles.php?group_id=274>
|
||||
L<https://release.ow2.org/lemonldap/>
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 ($@);
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in New Issue