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

parent db5b4e8a
#!/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 ($cli, $action, $method, $ret);
$cli = new Lemonldap::NG::Manager::Cli;
$action = shift(@ARGV);
$method = $cli->determineMethod($action);
my $ret = $app->run(@ARGV);
@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,
......
......@@ -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');
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