add C wrapper for setuid
This commit is contained in:
parent
68529bfc2c
commit
5832e6a7eb
|
@ -0,0 +1,37 @@
|
||||||
|
# HOWTO Centos
|
||||||
|
|
||||||
|
Install dependencies:
|
||||||
|
|
||||||
|
# yum install perl-devel 'perl(ExtUtils::Embed)'
|
||||||
|
|
||||||
|
Compile the wrapper:
|
||||||
|
|
||||||
|
# gcc -o cwrapper_perl cwrapper_perl.c `perl -MExtUtils::Embed -e ccopts -e ldopts`
|
||||||
|
|
||||||
|
Create a fatpack: https://github.com/centreon/centreon-plugins/blob/master/docs/en/user/guide.rst#can-i-have-one-standalone-perl-file-
|
||||||
|
|
||||||
|
Comment following lines in the end of fatpack file:
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
# Not perl embedded compliant at all
|
||||||
|
#use FindBin;
|
||||||
|
#use lib "$FindBin::Bin";
|
||||||
|
# use lib '/usr/lib/nagios/plugins/';
|
||||||
|
|
||||||
|
use centreon::plugins::script;
|
||||||
|
|
||||||
|
centreon::plugins::script->new()->run();
|
||||||
|
|
||||||
|
Set setuid right:
|
||||||
|
|
||||||
|
# chown root:root cwrapper_perl
|
||||||
|
# chmod 4775 cwrapper_perl
|
||||||
|
|
||||||
|
Test it:
|
||||||
|
|
||||||
|
$ cwrapper_perl centreon_protocol_udp.pl --plugin --mode=connection --hostname=10.30.2.65 --port=161
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
#include <EXTERN.h>
|
||||||
|
#include <perl.h>
|
||||||
|
|
||||||
|
static PerlInterpreter *my_perl;
|
||||||
|
static void xs_init (pTHX);
|
||||||
|
|
||||||
|
EXTERN_C void boot_DynaLoader (pTHX_ CV* cv);
|
||||||
|
EXTERN_C void xs_init(pTHX)
|
||||||
|
{
|
||||||
|
char *file = __FILE__;
|
||||||
|
/* DynaLoader is a special case */
|
||||||
|
newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main (int argc, char **argv, char **env)
|
||||||
|
{
|
||||||
|
PERL_SYS_INIT3(&argc, &argv, &env);
|
||||||
|
my_perl = perl_alloc();
|
||||||
|
perl_construct(my_perl);
|
||||||
|
PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
|
||||||
|
perl_parse(my_perl, xs_init, argc, argv, (char **)NULL);
|
||||||
|
perl_run(my_perl);
|
||||||
|
perl_destruct(my_perl);
|
||||||
|
perl_free(my_perl);
|
||||||
|
PERL_SYS_TERM();
|
||||||
|
}
|
Loading…
Reference in New Issue