diff --git a/doc/sources/admin/changesessionbackend.rst b/doc/sources/admin/changesessionbackend.rst index d14c4e2f6..90c1e4e90 100644 --- a/doc/sources/admin/changesessionbackend.rst +++ b/doc/sources/admin/changesessionbackend.rst @@ -46,6 +46,7 @@ Options: - ``-c``: job configuration file (mandatory) - ``-r oldkey=newkey``: rename session keys during conversion (optional, can be given multiple times) +- ``-x key``: remove session keys during conversion (optional, can be given multiple times) - ``-i``: ignore errors. By default errors will stop the script execution - ``-d``: print debugging output diff --git a/lemonldap-ng-common/scripts/convertSessions b/lemonldap-ng-common/scripts/convertSessions index 9ba895895..66e1465a4 100755 --- a/lemonldap-ng-common/scripts/convertSessions +++ b/lemonldap-ng-common/scripts/convertSessions @@ -16,18 +16,20 @@ use strict; use Getopt::Long; use Pod::Usage; -our $VERSION = "2.0.6"; +our $VERSION = "2.0.12"; # Options # -d: debug mode # -c: configuration file -# -r: configuration file +# -r: rename attributes # -i: ignore errors +# -x: exclude attributes my $debug; my $config_file; my $ignore_errors; my %rename; +my @exclude; my $help; my $nb_converted = 0; my $nb_error = 0; @@ -38,6 +40,7 @@ GetOptions( 'config|c=s' => \$config_file, 'ignore-errors|i' => \$ignore_errors, 'rename|r=s' => \%rename, + 'exclude|x=s' => \@exclude, ) or pod2usage(2); pod2usage( -exitval => 1, @@ -133,6 +136,16 @@ Lemonldap::NG::Common::Apache::Session->get_key_from_all_sessions( } } + if (@exclude) { + for my $excludekey (@exclude) { + if ( $entry->{$excludekey} ) { + print "Exclude $excludekey in session $id\n" + if $debug; + delete $entry->{$excludekey}; + } + } + } + print "Processing session $id\n" if $debug; my $s = Lemonldap::NG::Common::Session->new( { storageModule => $backendTo->{backend},