Try to change gid/uid when possible (#921)

This commit is contained in:
Xavier Guimard 2016-02-26 06:41:38 +00:00
parent cfeea8ec79
commit 6eed020081
2 changed files with 10 additions and 4 deletions

View File

@ -466,14 +466,14 @@ install_bin: install_conf_dir
${SRCCOMMONDIR}/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)/lmConfigEditor $(RBINDIR)/lemonldap-ng-cli; \
else \
$(PERL) -i -pe 's#__APACHEUSER__#$(APACHEUSER)#g;' $(RBINDIR)/lmConfigEditor; \
$(PERL) -i -pe 's#__APACHEUSER__#$(APACHEUSER)#g;' $(RBINDIR)/lmConfigEditor $(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)/lmConfigEditor $(RBINDIR)/lemonldap-ng-cli; \
else \
$(PERL) -i -pe 's#__APACHEGROUP__#$(APACHEGROUP)#g;' $(RBINDIR)/lmConfigEditor; \
$(PERL) -i -pe 's#__APACHEGROUP__#$(APACHEGROUP)#g;' $(RBINDIR)/lmConfigEditor $(RBINDIR)/lemonldap-ng-cli; \
fi
@chmod +x $(RBINDIR)/*

View File

@ -2,9 +2,15 @@
use warnings;
use strict;
use POSIX;
my $action;
eval {
POSIX::setgid( scalar( getgrnam('__APACHEGROUP__') ) );
POSIX::setuid( scalar( getpwnam('__APACHEUSER__') ) );
};
for ( my $i = 0 ; $i < @ARGV ; $i++ ) {
if ( $ARGV[$i] =~ /^-/ ) {
$i++;