Commit 7b8f6703 authored by Clément OUDOT's avatar Clément OUDOT
Browse files

Import lemonldap-ng-cli into Manager module (#588)

parent 5e36b3bc
......@@ -238,16 +238,21 @@ install_bin: install_conf_dir
${SRCCOMMONDIR}/scripts/convertConfig \
${SRCCOMMONDIR}/scripts/lmMigrateConfFiles2ini \
${SRCMANAGERDIR}/example/scripts/lmConfigEditor \
${SRCMANAGERDIR}/example/scripts/lemonldap-ng-cli \
$(RBINDIR)
@if [ ! "$(APACHEUSER)" ]; then \
$(PERL) -i -pe 's#__APACHEUSER__#nobody#g;' $(RBINDIR)/lmConfigEditor; \
$(PERL) -i -pe 's#__APACHEUSER__#nobody#g;' $(RBINDIR)/lemonldap-ng-cli; \
else \
$(PERL) -i -pe 's#__APACHEUSER__#$(APACHEUSER)#g;' $(RBINDIR)/lmConfigEditor; \
$(PERL) -i -pe 's#__APACHEUSER__#$(APACHEUSER)#g;' $(RBINDIR)/lemonldap-ng-cli; \
fi
@if [ ! "$(APACHEGROUP)" ]; then \
$(PERL) -i -pe 's#__APACHEGROUP__#nobody#g;' $(RBINDIR)/lmConfigEditor; \
$(PERL) -i -pe 's#__APACHEGROUP__#nobody#g;' $(RBINDIR)/lemonldap-ng-cli; \
else \
$(PERL) -i -pe 's#__APACHEGROUP__#$(APACHEGROUP)#g;' $(RBINDIR)/lmConfigEditor; \
$(PERL) -i -pe 's#__APACHEGROUP__#$(APACHEGROUP)#g;' $(RBINDIR)/lemonldap-ng-cli; \
fi
@chmod +x $(RBINDIR)/*
......@@ -631,6 +636,7 @@ debian-diff:
@$(DIFF) lemonldap-ng-manager/example/sessions.pl $(DIFFPREFIX)/var/lib/lemonldap-ng/manager/sessions.pl ||true
@$(DIFF) lemonldap-ng-manager/example/notifications.pl $(DIFFPREFIX)/var/lib/lemonldap-ng/manager/notifications.pl ||true
@$(DIFF) --ignore-matching-lines='set.*get.*\[2\]' lemonldap-ng-manager/example/scripts/lmConfigEditor $(DIFFPREFIX)/usr/share/lemonldap-ng/bin/lmConfigEditor ||true
@$(DIFF) --ignore-matching-lines='giveUpPrivileges' lemonldap-ng-manager/example/scripts/lemonldap-ng-cli $(DIFFPREFIX)/usr/share/lemonldap-ng/bin/lemonldap-ng-cli ||true
@for i in $(MANAGERSKINS); do \
$(DIFF) -x 'jquery*' lemonldap-ng-manager/example/skins/$$i $(DIFFPREFIX)/usr/share/lemonldap-ng/manager-skins/$$i; \
done ||true
......@@ -667,6 +673,7 @@ default-diff:
@$(DIFF) lemonldap-ng-manager/example/sessions.pl $(LMPREFIX)/htdocs/manager/sessions.pl ||true
@$(DIFF) lemonldap-ng-manager/example/notifications.pl $(LMPREFIX)/htdocs/manager/notifications.pl ||true
@$(DIFF) --ignore-matching-lines='set.*get.*\[2\]' lemonldap-ng-manager/example/scripts/lmConfigEditor $(LMPREFIX)/bin/lmConfigEditor ||true
@$(DIFF) --ignore-matching-lines='giveUpPrivileges' lemonldap-ng-manager/example/scripts/lemonldap-ng-cli $(LMPREFIX)/bin/lemonldap-ng-cli ||true
tidy: clean
find lemon*/ -type f \( -name '*.pm' -or -name '*.pl' -or -name '*.t' \) -print -exec perltidy -b {} \;
......
......@@ -180,7 +180,7 @@ sub getConf {
}
# Convert old option useXForwardedForIP into trustedProxies
if ( $r->{useXForwardedForIP} == 1 ) {
if ( defined $r->{useXForwardedForIP} and $r->{useXForwardedForIP} == 1 ) {
$r->{trustedProxies} = '*';
}
return $r;
......
......@@ -4,6 +4,7 @@ example/mrtg/lmng-mrtg
example/mrtg/mrtg.cfg.example
example/notfound.html
example/notifications.pl
example/scripts/lemonldap-ng-cli
example/scripts/lmConfigEditor
example/sessions.pl
example/skins/default/css/accordion.css
......@@ -91,6 +92,7 @@ example/skins/default/ui-lightness/jquery-ui-1.8.6.custom.css
lib/Lemonldap/NG/Manager.pm
lib/Lemonldap/NG/Manager/_i18n.pm
lib/Lemonldap/NG/Manager/_Struct.pm
lib/Lemonldap/NG/Manager/Cli.pm
lib/Lemonldap/NG/Manager/Downloader.pm
lib/Lemonldap/NG/Manager/Notifications.pm
lib/Lemonldap/NG/Manager/Request.pm
......
#!/usr/bin/perl -w
use Lemonldap::NG::Manager::Cli;
use POSIX;
use strict;
sub giveUpPrivileges
{
my ($user, $group) = @_;
if (not defined ($user))
{
$user = "nobody";
}
if (not defined ($group))
{
$group = "nobody";
}
# become $user:$group and give up root privileges
POSIX::setgid ((getgrnam ($group))[2]);
POSIX::setuid ((getpwnam ($user))[2]);
# if we are still root
if ($> == 0)
{
# ask the user to continue or abort
print STDERR "$0 must not be launchezd as root since local cache can be corrupted.\n";
print STDERR "Continue (y/N)? ";
my $res = <STDIN>;
exit 1 unless ($res =~ /^y/i);
}
}
&giveUpPrivileges ("__APACHEUSER__", "__APACHEGROUP__");
my $app = Lemonldap::NG::Manager::Cli->new ();
my $ret = $app->run (@ARGV);
exit ($ret);
__END__
=head1 NAME
=encoding utf8
lemonldap-ng-cli - Command Line Interface to edit LemonLDAP::NG configuration.
=head1 SYNOPSIS
Set/get variables in the configuration:
lemonldap-ng-cli set <variable> <value>
lemonldap-ng-cli unset <variable>
lemonldap-ng-cli get <variable>
Define macros:
lemonldap-ng-cli set-macro <macro name> <perl expression>
lemonldap-ng-cli unset-macro <macro name>
lemonldap-ng-cli get-macro <macro name>
Modify application list:
lemonldap-ng-cli apps-set-cat <cat id> <cat name>
lemonldap-ng-cli apps-get-cat <cat id>
lemonldap-ng-cli apps-add <app id> <cat id>
lemonldap-ng-cli apps-set-uri <app id> <app uri>
lemonldap-ng-cli apps-set-name <app id> <app name>
lemonldap-ng-cli apps-set-desc <app id> <app description>
lemonldap-ng-cli apps-set-logo <app id> <logo>
lemonldap-ng-cli apps-set-display <app id> <app display>
lemonldap-ng-cli apps-get <app id>
lemonldap-ng-cli apps-rm <app id>
Manage rules:
lemonldap-ng-cli rules-set <virtual host> <expr> <rule>
lemonldap-ng-cli rules-unset <virtual host> <expr>
lemonldap-ng-cli rules-get <virtual host>
Manage exported variables:
lemonldap-ng-cli export-var <key> <value>
lemonldap-ng-cli unexport-var <key>
lemonldap-ng-cli get-exported-vars
Manage exported headers:
lemonldap-ng-cli export-header <virtual host> <HTTP header> <perl expression>
lemonldap-ng-cli unexport-header <virtual host> <HTTP header>
lemonldap-ng-cli get-exported-headers <virtual host>
Manage virtual hosts:
lemonldap-ng-cli vhost-add <virtual host uri>
lemonldap-ng-cli vhost-del <virtual host>
lemonldap-ng-cli vhost-set-port <virtual host> <port>
lemonldap-ng-cli vhost-set-https <virtual host> <value>
lemonldap-ng-cli vhost-set-maintenance <virtual host> <value>
lemonldap-ng-cli vhost-list
Global Storage:
lemonldap-ng-cli global-storage
lemonldap-ng-cli global-storage-set-dir <path>
lemonldap-ng-cli global-storage-set-lockdir <path>
Reload URLs:
lemonldap-ng-cli reload-urls
lemonldap-ng-cli reload-url-add <vhost> <url>
lemonldap-ng-cli reload-url-del <vhost>
=head1 DESCRIPTION
lemonldap-ng-cli allow user to edit the configuration of Lemonldap::NG via the
command line.
=head1 SEE ALSO
L<Lemonldap::NG::Cli>, L<http://lemonldap-ng.org/>
=head1 AUTHOR
David Delassus E<lt>david.jose.delassus@gmail.comE<gt>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2012, by David Delassus
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.10.0 or,
at your option, any later version of Perl 5 you may have available.
=cut
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment