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

View File

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

View File

@ -1,2 +1,2 @@
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
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
SESSIONSDIR=/var/lib/lemonldap-ng/sessions
if [ "$1" == "configure" ]
then
[ -e $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
[ -e $HANDLERFILE ] || cp $EXAMPLEHANDLERFILE $HANDLERFILE
chmod 770 $SESSIONSDIR
chmod 770 $SESSIONSDIR/lock
chown -R www-data.www-data $SESSIONSDIR

View File

@ -3,16 +3,12 @@
. /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
if [ "$1" == "configure" ]
then
[ -e $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
[ -e $MANAGERFILE ] || cp $EXAMPLEMANAGERFILE $MANAGERFILE
chmod +x $MANAGERFILE
chgrp www-data /etc/lemonldap-ng/apply.conf
chmod 640 /etc/lemonldap-ng/apply.conf

View File

@ -3,29 +3,17 @@
. /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
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
CLEANERFILE=/usr/share/lemonldap-ng/bin/purgeCentralCache
SESSIONSDIR=/var/lib/lemonldap-ng/sessions
if [ "$1" == "configure" ]
then
[ -e $LAPORTALFILE ] || \
perl -000 -pe 's/(configStorage\s*=>\s*){[^}]+}/$1\$Lemonldap::NG::Conf::configStorage/;
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
[ -e $LAPORTALFILE ] || cp $LAEXAMPLEPORTALFILE $LAPORTALFILE
[ -e $PORTALFILE ] || cp $EXAMPLEPORTALFILE $PORTALFILE
chmod +x $PORTALFILE
chmod +x $CLEANERFILE
chmod +x $LAPORTALFILE
chmod 770 $SESSIONSDIR
chmod 770 $SESSIONSDIR/lock

View File

@ -11,6 +11,8 @@
export PERL_MM_USE_DEFAULT=1
LM_ROOT=/var/lib/lemonldap-ng/
DEB_TMP_LM_ROOT=debian/tmp$(LM_ROOT)
configure: configure-stamp
configure-stamp:
@ -51,33 +53,47 @@ install: build
$(MAKE) test
$(MAKE) install DESTDIR=$(CURDIR)/debian/tmp PREFIX=/usr
$(MAKE) example \
EXAMPLEDIRBUILD=debian/tmp/var/lib/lemonldap-ng/ \
EXAMPLEDIR=/var/lib/lemonldap-ng/ \
EXAMPLECONFDIR=/var/lib/lemonldap-ng/conf/ \
EXAMPLELASPDIRBUILD=debian/tmp/var/lib/lemonldap-ng/liberty-alliance-sp-portal/ \
EXAMPLELASPDIR=/var/lib/lemonldap-ng/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
EXAMPLEDIRBUILD=$(DEB_TMP_LM_ROOT) \
EXAMPLEDIR=$(LM_ROOT) \
EXAMPLECONFDIR=$(LM_ROOT)conf/ \
EXAMPLELASPDIRBUILD=$(DEB_TMP_LM_ROOT)liberty-alliance-sp-portal/ \
EXAMPLELASPDIR=$(LM_ROOT)liberty-alliance-sp-portal/
# 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.
binary-indep: build install
dh_testdir
dh_testroot
dh_installchangelogs changelog
dh_installdocs
mkdir debian/tmp/var/lib/lemonldap-ng/protected
cp _example/index.pl debian/tmp/var/lib/lemonldap-ng/protected
mkdir $(DEB_TMP_LM_ROOT)protected
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 {} \;
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
chmod +x debian/liblemonldap-ng-portal-perl/usr/share/lemonldap-ng/bin/purgeCentralCache
# dh_installmenu

View File

@ -2,7 +2,12 @@
ServerName test.example.com
PerlRequire __DIR__/handler/MyHandler.pm
# Area protection
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>
Order deny,allow
Deny from all

View File

@ -1,38 +1,43 @@
PerlOptions +GlobalRequest
<VirtualHost 127.0.0.3:*>
ServerName test.example.com
PerlRequire __DIR__/handler/MyHandler.pm
PerlHeaderParserHandler My::Package
<Location /reload>
Order deny,allow
Deny from all
Allow from 127.0.0.0/8
PerlHeaderParserHandler My::Package->refresh
</Location>
ServerName test.example.com
PerlRequire __DIR__/handler/MyHandler.pm
# Area protection
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>
Order deny,allow
Deny from all
Allow from 127.0.0.0/8
PerlHeaderParserHandler My::Package->refresh
</Location>
# Uncomment this to activate status module
#<Location /status>
# Order deny,allow
# Deny from all
# Allow from 127.0.0.0/8
# PerlHeaderParserHandler My::Package->status
#</Location>
#<Location /status>
# Order deny,allow
# Deny from all
# Allow from 127.0.0.0/8
# PerlHeaderParserHandler My::Package->status
#</Location>
# Just to make example running (index.pl display authenticated user)
DocumentRoot __DIR__
<Directory __DIR__>
Order allow,deny
Allow from all
Options +ExecCGI
</Directory>
<Files *.pl>
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
</Files>
# Just to make example running (index.pl display authenticated user)
DocumentRoot __DIR__
<Directory __DIR__>
Order allow,deny
Allow from all
Options +ExecCGI
</Directory>
<Files *.pl>
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
</Files>
<IfModule mod_dir.c>
DirectoryIndex index.pl index.html
</IfModule>
<IfModule mod_dir.c>
DirectoryIndex index.pl index.html
</IfModule>
</VirtualHost>

View File

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

View File

@ -74,17 +74,21 @@ EOT
sub javascript {
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;
foreach(qw(newVirtualHost newMacro newGroup newVar newGSOpt saveConf
foreach (
qw(newVirtualHost newMacro newGroup newVar newGSOpt saveConf
deleteNode locationRules unableToSave confSaved saveFailure
newRule newHeader httpHeaders waitingResult unknownError
configurationWasChanged configLoaded warningConfNotApplied
applyConf prevConf lastConf nextConf deleteVirtualHost
areYouSure syntaxError deleteConf confirmDeleteConf
invalidVirtualHostName)) {
invalidVirtualHostName)
)
{
$text{$_} = &{"txt_$_"};
$text{$_} =~s/'/\\'/g;
$text{$_} =~ s/'/\\'/g;
}
print qq#
function loadConf(n) {
@ -209,7 +213,7 @@ function onNodeSelect(nodeId) {
+button('$text{lastConf}','lastConf',nodeId)
+button('$text{deleteConf}','deleteConf',nodeId);
#;
if( $self->{applyConfFile} ) {
if ( $self->{applyConfFile} ) {
print "but+=button('$text{applyConf}','applyConf',nodeId);";
}
print qq#
@ -410,19 +414,20 @@ sub start_html {
$args{'-style'} = { -src => [ $args{'-style'} ] }
if ( $args{'-style'} and !ref( $args{'-style'} ) );
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);
}
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;
foreach(qw(field value)) {
foreach (qw(field value)) {
$text{$_} = &{"txt_$_"};
$text{$_} =~s/'/\\'/g;
$text{$_} =~ s/'/\\'/g;
}
# Lemonldap::Manager javascripts;
print
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->{unbind} = sub { PE_OK };
$p->{store} = sub { PE_OK };
ok( $p->process == PE_OK , 'User OK' );
ok( $p->process, 'User OK' );
# Cookie test
$p->{id} = 1;