From 294e35cbebedbd2c861272cab8d9a5ef005eb5c4 Mon Sep 17 00:00:00 2001 From: Xavier Guimard Date: Sat, 11 Apr 2009 06:13:28 +0000 Subject: [PATCH] Error with PPolicy + CleanupHandler not launched --- build/lemonldap-ng/Makefile | 7 +++++++ .../lib/Lemonldap/NG/Common/CGI.pm | 5 ++++- .../lib/Lemonldap/NG/Common/Conf.pm | 5 +++-- .../lib/Lemonldap/NG/Handler/Simple.pm | 12 +++++------- .../lib/Lemonldap/NG/Portal/AuthLDAP.pm | 2 +- .../lib/Lemonldap/NG/Portal/_LDAP.pm | 2 +- 6 files changed, 21 insertions(+), 12 deletions(-) diff --git a/build/lemonldap-ng/Makefile b/build/lemonldap-ng/Makefile index 28c6ae807..68309887f 100644 --- a/build/lemonldap-ng/Makefile +++ b/build/lemonldap-ng/Makefile @@ -487,3 +487,10 @@ manager_clean: - $(MAKE) -C ${SRCMANAGERDIR} distclean @rm -vf manager* +debian-packages: debian-dist + mv lemonldap-ng_$(VERSION).orig.tar.gz /tmp/ + version=$(VERSION) && \ + cd /tmp/ && \ + tar xzf lemonldap-ng_$$version.orig.tar.gz && \ + cd lemonldap-ng-$$version && \ + debuild diff --git a/modules/lemonldap-ng-common/lib/Lemonldap/NG/Common/CGI.pm b/modules/lemonldap-ng-common/lib/Lemonldap/NG/Common/CGI.pm index b8bd8a03f..4bfbbff5a 100644 --- a/modules/lemonldap-ng-common/lib/Lemonldap/NG/Common/CGI.pm +++ b/modules/lemonldap-ng-common/lib/Lemonldap/NG/Common/CGI.pm @@ -174,7 +174,10 @@ sub abort { sub startSyslog { my $self = shift; return if ( $self->{_syslog} ); - eval "use Sys::Syslog; openlog('lemonldap-ng','ndelay','$self->{syslog}');"; + eval { + use Sys::Syslog; + openlog( 'lemonldap-ng', 'ndelay', '$self->{syslog}' ); + }; $self->abort( "Unable to use syslog", $@ ) if ($@); $self->{_syslog} = 1; } diff --git a/modules/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf.pm b/modules/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf.pm index 121d9ab47..fd1633e65 100644 --- a/modules/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf.pm +++ b/modules/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf.pm @@ -238,10 +238,11 @@ sub getDBConf { /^(?:exportedVars|locationRules|groups|exportedHeaders|macros|globalStorageOptions)$/ ) { - if ( $v !~ /^\$/ ) { + $conf->{$k} = {}; + if ( defined($v) and $v !~ /^\$/ ) { print STDERR "Lemonldap::NG : Warning: configuration is in old format, you've to migrate !\n"; - eval 'require Storable;require MIME::Base64;'; + eval { require Storable; require MIME::Base64; }; if ($@) { $msg = "Error : $@"; return 0; diff --git a/modules/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Simple.pm b/modules/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Simple.pm index 6f23773f7..acbb25c68 100644 --- a/modules/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Simple.pm +++ b/modules/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Simple.pm @@ -409,17 +409,11 @@ sub childInit { if ( MP() == 2 ) { Apache2::ServerUtil->server->push_handlers( PerlChildInitHandler => sub { return $class->initLocalStorage( $_[1], $_[0] ); } ); - Apache2::ServerUtil->server->push_handlers( - PerlCleanupHandler => sub { return $class->cleanLocalStorage(@_); } - ); } elsif ( MP() == 1 ) { Apache->push_handlers( PerlChildInitHandler => sub { return $class->initLocalStorage(@_); } ); - Apache->push_handlers( - PerlCleanupHandler => sub { return $class->cleanLocalStorage(@_); } - ); } 1; } @@ -863,7 +857,6 @@ sub fetchId { sub run ($$) { my $class; ( $class, $apacheRequest ) = @_; - return DECLINED unless ( $apacheRequest->is_initial_req ); my $uri = $apacheRequest->uri . ( $apacheRequest->args ? "?" . $apacheRequest->args : "" ); @@ -925,6 +918,11 @@ sub run ($$) { # Hide Lemonldap::NG cookie $class->hideCookie; + # Cleanup + $apacheRequest->push_handlers( + PerlCleanupHandler => sub { return $class->cleanLocalStorage(@_); } + ); + if ( defined( $transform->{$uri} ) ) { return &{ $transform->{$uri} }; } diff --git a/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/AuthLDAP.pm b/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/AuthLDAP.pm index aeb95d5d2..6f84f5469 100644 --- a/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/AuthLDAP.pm +++ b/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/AuthLDAP.pm @@ -21,7 +21,7 @@ use base qw(Lemonldap::NG::Portal::_WebForm); # @return Lemonldap::NG::Portal constant sub authInit { my $self = shift; - if ( $self->{portal}->{ldapPpolicyControl} and not $self->Lemonldap::NG::Portal::_LDAP::loadPP) { + if ( $self->{ldapPpolicyControl} and not $self->ldap->loadPP()) { return PE_LDAPERROR; } PE_OK; diff --git a/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_LDAP.pm b/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_LDAP.pm index a2ffaf62e..322b7dcaf 100644 --- a/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_LDAP.pm +++ b/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_LDAP.pm @@ -98,7 +98,7 @@ sub loadPP { return 1 if ($ppLoaded); # require Perl module - eval 'require Net::LDAP::Control::PasswordPolicy'; + eval {require Net::LDAP::Control::PasswordPolicy}; if ($@) { $self->lmLog( "Module Net::LDAP::Control::PasswordPolicy not found in @INC",