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

Add help action to lemonldap-ng-cli (#588)

parent 0e949a79
......@@ -4,42 +4,47 @@ 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);
}
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 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 ("__APACHEUSER__", "__APACHEGROUP__");
&giveUpPrivileges( "www-data", "www-data" );
my $app = Lemonldap::NG::Manager::Cli->new ();
# Display usage unless command
unless (@ARGV) {
print STDERR "Usage: $0 <action> <params>\n";
print STDERR "Enter $0 help to get more information\n";
exit 1;
}
my $app = Lemonldap::NG::Manager::Cli->new();
my $ret = $app->run (@ARGV);
my $ret = $app->run(@ARGV);
exit ($ret);
exit($ret);
__END__
......
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