/usr/share/lemonldap-ng/bin/lemonldap-ng-cli is in liblemonldap-ng-manager-perl 1.3.3-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | #!/usr/bin/perl -w
use Lemonldap::NG::Manager::Cli;
use POSIX qw(setuid setgid);
use strict;
sub giveUpPrivileges {
my ( $user, $group ) = @_;
$user = "nobody" unless defined($user);
$group = "nobody" unless defined($group);
# become $user:$group and give up root privileges
setgid( ( getgrnam($group) )[2] );
setuid( ( getpwnam($user) )[2] );
# if we are still root
if ( $> == 0 ) {
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 );
}
}
## main program
if ( !@ARGV ) {
print STDERR "Usage: $0 <action> <params>\n";
print STDERR "- help: list available actions\n";
print STDERR "- info: view current configuration information\n";
exit 1;
}
giveUpPrivileges( "www-data", "www-data" );
my ( $cli, $action, $method, $ret );
$cli = new Lemonldap::NG::Manager::Cli;
# Do not increment configuration by default
$cli->{confAccess}->{cfgNumFixed} = 1;
$action = shift(@ARGV);
$method = $cli->determineMethod($action);
unless ( $cli->can($method) ) {
print STDERR "Action $action unknown\n";
print STDERR "Enter $0 help to get more information\n";
exit 1;
}
# The config is stored in ASCII
foreach(@ARGV){ utf8::decode $_; }
binmode(STDOUT, ':utf8');
@ARGV ? $cli->run( $method, @ARGV ) : $cli->run($method);
# Display error if any
if ( $cli->getError() ) {
print $cli->getError() . "\n";
exit 1;
}
# Save configuration if modified
if ( $cli->{confModified} ) {
$ret = $cli->saveConf();
print "Configuration $ret saved\n";
}
exit 0;
__END__
=head1 NAME
=encoding utf8
lemonldap-ng-cli - Command Line Interface to edit LemonLDAP::NG configuration.
=head1 SYNOPSIS
Do lemonldap-ng-cli help to get list of all commands
=head1 DESCRIPTION
lemonldap-ng-cli allow user to edit the configuration of LemonLDAP::NG via the
command line.
=head1 SEE ALSO
L<Lemonldap::NG::Manager::Cli>, L<http://lemonldap-ng.org/>
=head1 AUTHOR
David Delassus E<lt>david.jose.delassus@gmail.comE<gt>
Sandro Cazzaniga E<lt>cazzaniga.sandro@gmail.comE<gt>
Clement Oudot E<lt>clem.oudot@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,
at your option, any later version of Perl 5 you may have available.
=cut
|