LEMONLDAP::NG :

* UTF8 support in Manager
		* Beginning of Debian-like installation for other distributions
This commit is contained in:
Xavier Guimard 2008-06-13 14:35:50 +00:00
parent e1b8027ccd
commit 6d66965b7a
12 changed files with 119 additions and 100 deletions

View File

@ -1,7 +1,7 @@
<VirtualHost *> <VirtualHost *>
ServerName protected.example.com ServerName protected.example.com
PerlRequire /var/lib/lemonldap-ng/handler/MyHandler.pm
PerlRequire /var/lib/lemonldap-ng/handler/MyHandler.pm
# Area protection # Area protection
PerlHeaderParserHandler My::Package PerlHeaderParserHandler My::Package
@ -15,9 +15,12 @@
PerlHeaderParserHandler My::Package->refresh PerlHeaderParserHandler My::Package->refresh
</Location> </Location>
# Optional interception of the logout URL => single logout # Uncomment this to activate status module
# if not done in configuration interface #<Location /status>
<Location /logout> # Order deny,allow
PerlHeaderParserHandler My::Package->logout # Deny from all
</Location> # Allow from 127.0.0.0/8
# PerlHeaderParserHandler My::Package->status
#</Location>
</VirtualHost> </VirtualHost>

View File

@ -1,8 +1,8 @@
PerlOptions +GlobalRequest PerlOptions +GlobalRequest
<VirtualHost *> <VirtualHost *>
ServerName protected.example.com ServerName protected.example.com
PerlRequire /var/lib/lemonldap-ng/handler/MyHandler.pm PerlRequire /var/lib/lemonldap-ng/handler/MyHandler.pm
# Area protection # Area protection
PerlHeaderParserHandler My::Package PerlHeaderParserHandler My::Package
@ -16,9 +16,12 @@ PerlOptions +GlobalRequest
PerlHeaderParserHandler My::Package->refresh PerlHeaderParserHandler My::Package->refresh
</Location> </Location>
# Optional interception of the logout URL => single logout # Uncomment this to activate status module
# if not done in configuration interface #<Location /status>
<Location /logout> # Order deny,allow
PerlHeaderParserHandler My::Package->logout # Deny from all
</Location> # Allow from 127.0.0.0/8
# PerlHeaderParserHandler My::Package->status
#</Location>
</VirtualHost> </VirtualHost>

View File

@ -1,2 +1,2 @@
debian/tmp/var/lib/lemonldap-ng/handler/* debian/tmp/var/lib/lemonldap-ng/handler/*
debian/handler-apache*.conf debian/tmp/var/lib/lemonldap-ng/apache*-protected-area.conf

View File

@ -3,16 +3,13 @@
. /usr/share/debconf/confmodule . /usr/share/debconf/confmodule
EXAMPLEHANDLERFILE=/usr/share/doc/liblemonldap-ng-handler-perl/examples/MyHandler.pm EXAMPLEHANDLERFILE=/usr/share/doc/liblemonldap-ng-handler-perl/examples/MyHandler-Debian.pm
HANDLERFILE=/var/lib/lemonldap-ng/handler/MyHandler.pm HANDLERFILE=/var/lib/lemonldap-ng/handler/MyHandler.pm
SESSIONSDIR=/var/lib/lemonldap-ng/sessions SESSIONSDIR=/var/lib/lemonldap-ng/sessions
if [ "$1" == "configure" ] if [ "$1" == "configure" ]
then then
[ -e $HANDLERFILE ] || \ [ -e $HANDLERFILE ] || cp $EXAMPLEHANDLERFILE $HANDLERFILE
perl -000 -pe 's/(configStorage\s*=>\s*){[^}]+}/$1\$Lemonldap::NG::Conf::configStorage/;
s#^use#\nrequire "/usr/share/lemonldap-ng/configStorage.pm";\nuse#m;' \
$EXAMPLEHANDLERFILE >$HANDLERFILE
chmod 770 $SESSIONSDIR chmod 770 $SESSIONSDIR
chmod 770 $SESSIONSDIR/lock chmod 770 $SESSIONSDIR/lock
chown -R www-data.www-data $SESSIONSDIR chown -R www-data.www-data $SESSIONSDIR

View File

@ -3,16 +3,12 @@
. /usr/share/debconf/confmodule . /usr/share/debconf/confmodule
EXAMPLEMANAGERFILE=/usr/share/doc/liblemonldap-ng-manager-perl/examples/index.pl EXAMPLEMANAGERFILE=/usr/share/doc/liblemonldap-ng-manager-perl/examples/index-Debian.pl
MANAGERFILE=/var/lib/lemonldap-ng/manager/index.pl MANAGERFILE=/var/lib/lemonldap-ng/manager/index.pl
if [ "$1" == "configure" ] if [ "$1" == "configure" ]
then then
[ -e $MANAGERFILE ] || \ [ -e $MANAGERFILE ] || cp $EXAMPLEMANAGERFILE $MANAGERFILE
perl -000 -pe 's/(configStorage\s*=>\s*){[^}]+}/$1\$Lemonldap::NG::Conf::configStorage/;
s#^use#\nrequire "/usr/share/lemonldap-ng/configStorage.pm";\nuse#m;
s#(applyConfFile\s*=>\s*)(['"'"'"]).*?\2#$1$2/etc/lemonldap-ng/apply.conf$2#' \
$EXAMPLEMANAGERFILE >$MANAGERFILE
chmod +x $MANAGERFILE chmod +x $MANAGERFILE
chgrp www-data /etc/lemonldap-ng/apply.conf chgrp www-data /etc/lemonldap-ng/apply.conf
chmod 640 /etc/lemonldap-ng/apply.conf chmod 640 /etc/lemonldap-ng/apply.conf

View File

@ -3,29 +3,17 @@
. /usr/share/debconf/confmodule . /usr/share/debconf/confmodule
LAEXAMPLEPORTALFILE=/usr/share/doc/liblemonldap-ng-portal-perl/examples/liberty-alliance-sp-portal/index.pl LAEXAMPLEPORTALFILE=/usr/share/doc/liblemonldap-ng-portal-perl/examples/liberty-alliance-sp-portal/index-Debian.pl
LAPORTALFILE=/var/lib/lemonldap-ng/liberty-alliance-sp-portal/index.pl LAPORTALFILE=/var/lib/lemonldap-ng/liberty-alliance-sp-portal/index.pl
EXAMPLEPORTALFILE=/usr/share/doc/liblemonldap-ng-portal-perl/examples/index_skin.pl EXAMPLEPORTALFILE=/usr/share/doc/liblemonldap-ng-portal-perl/examples/index_skin-Debian.pl
PORTALFILE=/var/lib/lemonldap-ng/portal/index.pl PORTALFILE=/var/lib/lemonldap-ng/portal/index.pl
CLEANERFILE=/usr/share/lemonldap-ng/bin/purgeCentralCache
SESSIONSDIR=/var/lib/lemonldap-ng/sessions SESSIONSDIR=/var/lib/lemonldap-ng/sessions
if [ "$1" == "configure" ] if [ "$1" == "configure" ]
then then
[ -e $LAPORTALFILE ] || \ [ -e $LAPORTALFILE ] || cp $LAEXAMPLEPORTALFILE $LAPORTALFILE
perl -000 -pe 's/(configStorage\s*=>\s*){[^}]+}/$1\$Lemonldap::NG::Conf::configStorage/; [ -e $PORTALFILE ] || cp $EXAMPLEPORTALFILE $PORTALFILE
s#^use#\nrequire "/usr/share/lemonldap-ng/configStorage.pm";\nuse#m;' \
$LAEXAMPLEPORTALFILE >$LAPORTALFILE
[ -e $PORTALFILE ] || \
perl -000 -pe 's/(configStorage\s*=>\s*){[^}]+}/$1\$Lemonldap::NG::Conf::configStorage/;
s#^use#\nrequire "/usr/share/lemonldap-ng/configStorage.pm";\nuse#m;' \
$EXAMPLEPORTALFILE >$PORTALFILE
[ -e $CLEANERFILE ] || \
perl -i -000 -pe 's/(configStorage\s*=>\s*){[^}]+}/$1\$Lemonldap::NG::Conf::configStorage/;
s#^use#\nrequire "/usr/share/lemonldap-ng/configStorage.pm";\nuse#m;' \
$CLEANERFILE
chmod +x $PORTALFILE chmod +x $PORTALFILE
chmod +x $CLEANERFILE
chmod +x $LAPORTALFILE chmod +x $LAPORTALFILE
chmod 770 $SESSIONSDIR chmod 770 $SESSIONSDIR
chmod 770 $SESSIONSDIR/lock chmod 770 $SESSIONSDIR/lock

View File

@ -11,6 +11,8 @@
export PERL_MM_USE_DEFAULT=1 export PERL_MM_USE_DEFAULT=1
LM_ROOT=/var/lib/lemonldap-ng/
DEB_TMP_LM_ROOT=debian/tmp$(LM_ROOT)
configure: configure-stamp configure: configure-stamp
configure-stamp: configure-stamp:
@ -51,33 +53,47 @@ install: build
$(MAKE) test $(MAKE) test
$(MAKE) install DESTDIR=$(CURDIR)/debian/tmp PREFIX=/usr $(MAKE) install DESTDIR=$(CURDIR)/debian/tmp PREFIX=/usr
$(MAKE) example \ $(MAKE) example \
EXAMPLEDIRBUILD=debian/tmp/var/lib/lemonldap-ng/ \ EXAMPLEDIRBUILD=$(DEB_TMP_LM_ROOT) \
EXAMPLEDIR=/var/lib/lemonldap-ng/ \ EXAMPLEDIR=$(LM_ROOT) \
EXAMPLECONFDIR=/var/lib/lemonldap-ng/conf/ \ EXAMPLECONFDIR=$(LM_ROOT)conf/ \
EXAMPLELASPDIRBUILD=debian/tmp/var/lib/lemonldap-ng/liberty-alliance-sp-portal/ \ EXAMPLELASPDIRBUILD=$(DEB_TMP_LM_ROOT)liberty-alliance-sp-portal/ \
EXAMPLELASPDIR=/var/lib/lemonldap-ng/liberty-alliance-sp-portal/ EXAMPLELASPDIR=$(LM_ROOT)liberty-alliance-sp-portal/
cp debian/tmp/var/lib/lemonldap-ng/handler/MyHandler.pm debian/tmp/var/lib/lemonldap-ng/handler/MyHandler-Debian.pm
mv debian/tmp/var/lib/lemonldap-ng/index.pl debian/tmp/var/lib/lemonldap-ng/test.pl
mv debian/tmp/var/lib/lemonldap-ng/handler/lmH-apache.conf debian/tmp/var/lib/lemonldap-ng/apache-protected-area.conf
mv debian/tmp/var/lib/lemonldap-ng/handler/lmH-apache2.conf debian/tmp/var/lib/lemonldap-ng/apache2-protected-area.conf
perl -000 -i -pe 's/(new\s*\(\s*){[^}]+}/$$1\$$Lemonldap::NG::Conf::configStorage/; s#^use#\nrequire "/usr/share/lemonldap-ng/configStorage.pm";\nuse#m;' \
debian/tmp/var/lib/lemonldap-ng/manager/scripts/lmConfigEditor \
debian/tmp/var/lib/lemonldap-ng/handler/MyHandler-Debian.pm \
debian/tmp/var/lib/lemonldap-ng/portal/scripts/purgeCentralCache
# Debian example files
cp $(DEB_TMP_LM_ROOT)handler/MyHandler.pm $(DEB_TMP_LM_ROOT)handler/MyHandler-Debian.pm
cp $(DEB_TMP_LM_ROOT)portal/index.pl $(DEB_TMP_LM_ROOT)portal/index-Debian.pl
cp $(DEB_TMP_LM_ROOT)portal/index_skin.pl $(DEB_TMP_LM_ROOT)portal/index_skin-Debian.pl
cp $(DEB_TMP_LM_ROOT)liberty-alliance-sp-portal/index.pl $(DEB_TMP_LM_ROOT)liberty-alliance-sp-portal/index-Debian.pl
cp $(DEB_TMP_LM_ROOT)manager/index.pl $(DEB_TMP_LM_ROOT)manager/index-Debian.pl
mv $(DEB_TMP_LM_ROOT)index.pl $(DEB_TMP_LM_ROOT)test.pl
mv $(DEB_TMP_LM_ROOT)handler/lmH-apache.conf $(DEB_TMP_LM_ROOT)apache-protected-area.conf
mv $(DEB_TMP_LM_ROOT)handler/lmH-apache2.conf $(DEB_TMP_LM_ROOT)apache2-protected-area.conf
perl -i -pe 's#__DIR__/?#'/var/lib/lemonldap-ng'#g;s#__CONFDIR__/?#'$(LM_ROOT)conf'#g;' \
$(DEB_TMP_LM_ROOT)apache*-protected-area.conf
# System to use /etc/lemonldap-ng/storage.conf instead of setting
# manually the configStorage parameter
perl -000 -i -pe 's/(Lemonldap::NG::Manager::Conf.*new\s*\(\s*){[^}]+}/$$1\$$Lemonldap::NG::Conf::configStorage/; s#^use#\nrequire "/usr/share/lemonldap-ng/configStorage.pm";\nuse#m;' \
$(DEB_TMP_LM_ROOT)manager/scripts/lmConfigEditor \
$(DEB_TMP_LM_ROOT)portal/scripts/purgeCentralCache
perl -000 -i -pe 's/(configStorage\s*=>\s*){[^}]+}/$$1\$$Lemonldap::NG::Conf::configStorage/; s#^use#\nrequire "/usr/share/lemonldap-ng/configStorage.pm";\nuse#m;' \
$(DEB_TMP_LM_ROOT)handler/MyHandler-Debian.pm \
$(DEB_TMP_LM_ROOT)manager/index-Debian.pl \
$(DEB_TMP_LM_ROOT)portal/index-Debian.pl \
$(DEB_TMP_LM_ROOT)portal/index_skin-Debian.pl \
$(DEB_TMP_LM_ROOT)liberty-alliance-sp-portal/index-Debian.pl
# Build architecture-independent files here. # Build architecture-independent files here.
binary-indep: build install binary-indep: build install
dh_testdir dh_testdir
dh_testroot dh_testroot
dh_installchangelogs changelog dh_installchangelogs changelog
dh_installdocs dh_installdocs
mkdir debian/tmp/var/lib/lemonldap-ng/protected mkdir $(DEB_TMP_LM_ROOT)protected
cp _example/index.pl debian/tmp/var/lib/lemonldap-ng/protected
find debian/tmp/var/lib/lemonldap-ng -type f -perm /111 -exec chmod -x {} \; find debian/tmp/var/lib/lemonldap-ng -type f -perm /111 -exec chmod -x {} \;
chmod +x debian/tmp/var/lib/lemonldap-ng/manager/scripts/lmConfigEditor chmod +x $(DEB_TMP_LM_ROOT)manager/scripts/lmConfigEditor
find debian/tmp/var/lib/lemonldap-ng -type f -name *.pl -exec chmod +x {} \; find debian/tmp/var/lib/lemonldap-ng -type f -name *.pl -exec chmod +x {} \;
dh_installexamples dh_installexamples
find debian/lemonldap-ng -type f -exec perl -i -pe 's#__DIR__/?#'/var/lib/lemonldap-ng'#g;s#__CONFDIR__/?#'/var/lib/lemonldap-ng/conf'#g;' {} \;
dh_install dh_install
chmod +x debian/liblemonldap-ng-portal-perl/usr/share/lemonldap-ng/bin/purgeCentralCache chmod +x debian/liblemonldap-ng-portal-perl/usr/share/lemonldap-ng/bin/purgeCentralCache
# dh_installmenu # dh_installmenu

View File

@ -2,7 +2,12 @@
ServerName test.example.com ServerName test.example.com
PerlRequire __DIR__/handler/MyHandler.pm PerlRequire __DIR__/handler/MyHandler.pm
# Area protection
PerlHeaderParserHandler My::Package PerlHeaderParserHandler My::Package
# Configuration reload mechanism (only 1 per physical server is
# needed): choose your URL to avoid restarting Apache when
# configuration change
<Location /reload> <Location /reload>
Order deny,allow Order deny,allow
Deny from all Deny from all

View File

@ -1,38 +1,43 @@
PerlOptions +GlobalRequest PerlOptions +GlobalRequest
<VirtualHost 127.0.0.3:*> <VirtualHost 127.0.0.3:*>
ServerName test.example.com ServerName test.example.com
PerlRequire __DIR__/handler/MyHandler.pm PerlRequire __DIR__/handler/MyHandler.pm
PerlHeaderParserHandler My::Package # Area protection
<Location /reload> PerlHeaderParserHandler My::Package
Order deny,allow
Deny from all # Configuration reload mechanism (only 1 per physical server is
Allow from 127.0.0.0/8 # needed): choose your URL to avoid restarting Apache when
PerlHeaderParserHandler My::Package->refresh # configuration change
</Location> <Location /reload>
Order deny,allow
Deny from all
Allow from 127.0.0.0/8
PerlHeaderParserHandler My::Package->refresh
</Location>
# Uncomment this to activate status module # Uncomment this to activate status module
#<Location /status> #<Location /status>
# Order deny,allow # Order deny,allow
# Deny from all # Deny from all
# Allow from 127.0.0.0/8 # Allow from 127.0.0.0/8
# PerlHeaderParserHandler My::Package->status # PerlHeaderParserHandler My::Package->status
#</Location> #</Location>
# Just to make example running (index.pl display authenticated user) # Just to make example running (index.pl display authenticated user)
DocumentRoot __DIR__ DocumentRoot __DIR__
<Directory __DIR__> <Directory __DIR__>
Order allow,deny Order allow,deny
Allow from all Allow from all
Options +ExecCGI Options +ExecCGI
</Directory> </Directory>
<Files *.pl> <Files *.pl>
SetHandler perl-script SetHandler perl-script
PerlResponseHandler ModPerl::Registry PerlResponseHandler ModPerl::Registry
</Files> </Files>
<IfModule mod_dir.c> <IfModule mod_dir.c>
DirectoryIndex index.pl index.html DirectoryIndex index.pl index.html
</IfModule> </IfModule>
</VirtualHost> </VirtualHost>

View File

@ -102,7 +102,7 @@ sub print_libjs {
sub print_lmjs { sub print_lmjs {
my $self = shift; my $self = shift;
print $self->header_public( $ENV{SCRIPT_FILENAME}, print $self->header_public( $ENV{SCRIPT_FILENAME},
-type => 'text/javascript' ); -type => 'text/javascript; charset=utf8' );
$self->javascript; $self->javascript;
} }
@ -136,7 +136,7 @@ sub print_delete {
# Configuration download subroutines # Configuration download subroutines
sub print_conf { sub print_conf {
my $self = shift; my $self = shift;
print $self->header( -type => "text/xml", '-Cache-Control' => 'private' ); print $self->header( -type => "text/xml; charset=utf8", '-Cache-Control' => 'private' );
$self->printXmlConf( { cfgNum => $self->param('cfgNum'), } ); $self->printXmlConf( { cfgNum => $self->param('cfgNum'), } );
exit; exit;
} }
@ -157,6 +157,7 @@ sub printXmlConf {
KeyAttr => { item => 'id', username => 'name' }, KeyAttr => { item => 'id', username => 'name' },
NoIndent => 1, NoIndent => 1,
NoSort => 0, NoSort => 0,
XMLDecl => '<?xml version="1.0" encoding="UTF-8"?>',
); );
} }
@ -349,7 +350,7 @@ sub xmlField {
sub print_upload { sub print_upload {
my $self = shift; my $self = shift;
my $datas = shift; my $datas = shift;
print $self->header( -type => "text/javascript" ); print $self->header( -type => "text/javascript; charset=utf8" );
my $r = Lemonldap::NG::Manager::_Response->new(); my $r = Lemonldap::NG::Manager::_Response->new();
my $tmp = $self->upload( $datas, $r ); my $tmp = $self->upload( $datas, $r );
if ( $tmp == 0 ) { if ( $tmp == 0 ) {

View File

@ -74,17 +74,21 @@ EOT
sub javascript { sub javascript {
my $self = shift; my $self = shift;
Lemonldap::NG::Manager::_i18n::import( $ENV{HTTP_ACCEPT_LANGUAGE} ) unless(__PACKAGE__->can('txt_newVirtualHost')); Lemonldap::NG::Manager::_i18n::import( $ENV{HTTP_ACCEPT_LANGUAGE} )
unless ( __PACKAGE__->can('txt_newVirtualHost') );
my %text; my %text;
foreach(qw(newVirtualHost newMacro newGroup newVar newGSOpt saveConf foreach (
qw(newVirtualHost newMacro newGroup newVar newGSOpt saveConf
deleteNode locationRules unableToSave confSaved saveFailure deleteNode locationRules unableToSave confSaved saveFailure
newRule newHeader httpHeaders waitingResult unknownError newRule newHeader httpHeaders waitingResult unknownError
configurationWasChanged configLoaded warningConfNotApplied configurationWasChanged configLoaded warningConfNotApplied
applyConf prevConf lastConf nextConf deleteVirtualHost applyConf prevConf lastConf nextConf deleteVirtualHost
areYouSure syntaxError deleteConf confirmDeleteConf areYouSure syntaxError deleteConf confirmDeleteConf
invalidVirtualHostName)) { invalidVirtualHostName)
)
{
$text{$_} = &{"txt_$_"}; $text{$_} = &{"txt_$_"};
$text{$_} =~s/'/\\'/g; $text{$_} =~ s/'/\\'/g;
} }
print qq# print qq#
function loadConf(n) { function loadConf(n) {
@ -209,7 +213,7 @@ function onNodeSelect(nodeId) {
+button('$text{lastConf}','lastConf',nodeId) +button('$text{lastConf}','lastConf',nodeId)
+button('$text{deleteConf}','deleteConf',nodeId); +button('$text{deleteConf}','deleteConf',nodeId);
#; #;
if( $self->{applyConfFile} ) { if ( $self->{applyConfFile} ) {
print "but+=button('$text{applyConf}','applyConf',nodeId);"; print "but+=button('$text{applyConf}','applyConf',nodeId);";
} }
print qq# print qq#
@ -410,19 +414,20 @@ sub start_html {
$args{'-style'} = { -src => [ $args{'-style'} ] } $args{'-style'} = { -src => [ $args{'-style'} ] }
if ( $args{'-style'} and !ref( $args{'-style'} ) ); if ( $args{'-style'} and !ref( $args{'-style'} ) );
unshift @{ $args{'-style'}->{'-src'} }, "$ENV{SCRIPT_NAME}?lmQuery=css"; unshift @{ $args{'-style'}->{'-src'} }, "$ENV{SCRIPT_NAME}?lmQuery=css";
$args{'-title'} ||= 'Lemonldap::NG Configuration'; $args{'-title'} ||= 'Lemonldap::NG Configuration';
$args{'-encoding'} ||= 'utf8';
$self->CGI::start_html(%args); $self->CGI::start_html(%args);
} }
sub main { sub main {
Lemonldap::NG::Manager::_i18n::import( $ENV{HTTP_ACCEPT_LANGUAGE} ) unless(__PACKAGE__->can('txt_field')); Lemonldap::NG::Manager::_i18n::import( $ENV{HTTP_ACCEPT_LANGUAGE} )
unless ( __PACKAGE__->can('txt_field') );
my %text; my %text;
foreach(qw(field value)) { foreach (qw(field value)) {
$text{$_} = &{"txt_$_"}; $text{$_} = &{"txt_$_"};
$text{$_} =~s/'/\\'/g; $text{$_} =~ s/'/\\'/g;
} }
# Lemonldap::Manager javascripts; # Lemonldap::Manager javascripts;
print print
qq#<script type="text/javascript" src="$ENV{SCRIPT_NAME}?lmQuery=libjs"></script>\n#; qq#<script type="text/javascript" src="$ENV{SCRIPT_NAME}?lmQuery=libjs"></script>\n#;

View File

@ -77,7 +77,7 @@ $p->{search} = sub { PE_OK };
$p->{setSessionInfo} = sub { PE_OK }; $p->{setSessionInfo} = sub { PE_OK };
$p->{unbind} = sub { PE_OK }; $p->{unbind} = sub { PE_OK };
$p->{store} = sub { PE_OK }; $p->{store} = sub { PE_OK };
ok( $p->process == PE_OK , 'User OK' ); ok( $p->process, 'User OK' );
# Cookie test # Cookie test
$p->{id} = 1; $p->{id} = 1;