Total rewrite of lemonldap-ng-cli (#649)

This commit is contained in:
Sandro Cazzaniga 2013-11-26 07:54:10 +00:00
parent db5b4e8a95
commit ea288b09c2
3 changed files with 713 additions and 1498 deletions

View File

@ -1,5 +1,4 @@
#!/usr/bin/perl -w
use Lemonldap::NG::Manager::Cli;
use POSIX qw(setuid setgid);
use strict;
@ -7,13 +6,8 @@ use strict;
sub giveUpPrivileges {
my ( $user, $group ) = @_;
if ( not defined($user) ) {
$user = "nobody";
}
if ( not defined($group) ) {
$group = "nobody";
}
$user = "nobody" unless defined($user);
$group = "nobody" unless defined($user);
# become $user:$group and give up root privileges
setgid( ( getgrnam($group) )[2] );
@ -21,28 +15,31 @@ sub giveUpPrivileges {
# if we are still root
if ( $> == 0 ) {
# ask the user to continue or abort
print STDERR
"$0 must not be launched as root since local cache can be corrupted.\n";
print STDERR "$0 must not be launched as root since local cache can be corrupted.\n";
print STDERR "Continue (y/N)? ";
my $res = <STDIN>;
exit 1 unless ( $res =~ /^y/i );
}
}
&giveUpPrivileges( "www-data", "www-data" );
## main program
# Display usage unless command
unless (@ARGV) {
if (!@ARGV) {
print STDERR "Usage: $0 <action> <params>\n";
print STDERR "Enter $0 help to get more information\n";
exit 1;
exit 1;
}
my $app = Lemonldap::NG::Manager::Cli->new();
giveUpPrivileges( "www-data", "www-data" );
my $ret = $app->run(@ARGV);
my ($cli, $action, $method, $ret);
$cli = new Lemonldap::NG::Manager::Cli;
$action = shift(@ARGV);
$method = $cli->determineMethod($action);
@ARGV ? $cli->run($method, @ARGV) : $cli->run($method);
$ret = $cli->saveConf();
exit($ret);
@ -134,10 +131,12 @@ L<Lemonldap::NG::Cli>, L<http://lemonldap-ng.org/>
=head1 AUTHOR
David Delassus E<lt>david.jose.delassus@gmail.comE<gt>
laterSandro Cazzaniga E<lt>cazzaniga.sandro@gmail.comE<gt>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2012, by David Delassus
Copyright (C) 2013, by Sandro Cazzaniga
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,

File diff suppressed because it is too large Load Diff

View File

@ -8,10 +8,5 @@ use strict;
# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.
SKIP: {
eval { require feature; };
skip
"Perl feature non available, so lemonldap-ng-cli will not be useable", 1
if ($@);
use_ok('Lemonldap::NG::Manager::Cli');
}
use_ok('Lemonldap::NG::Manager::Cli');