Inline::C + -T problem

K

kj

The following test script fails when run under -T, but runs without
error otherwise:


#!/usr/bin/perl

# VERSION 1

use Inline (Config =>
DIRECTORY => '/home/roth/berriz/local/pub/work/proj/BuildSynergizer/_Inline');

use Inline C;
use strict;

hello();

__END__
__C__
#include <stdio.h>

void hello() {
printf("hello world\n");
}


The error is:

Insecure dependency in require while running with -T switch at blib/lib/Inline.pm (autosplit into blib/lib/auto/Inline/find_temp_dir.al) line 1257, <DATA> line 1.
INIT failed--call queue aborted, <DATA> line 1.

I Googled the error message, and found a workaround, consisting of
the added Config => DIRECTORY lines shown below:


#!/usr/bin/perl

# VERSION 2

use Inline (Config =>
DIRECTORY => '/home/jones/tmp/_Inline');

use Inline C;
use strict;

hello();

__END__
__C__
#include <stdio.h>

void hello() {
printf("hello world\n");
}

The new script still fails if run under -T, but now the error now
is different:

Insecure dependency in require while running with -T switch at /usr/local/share/perl/5.10.0/Inline.pm line 498.
INIT failed--call queue aborted.

The offending line in Inline.pm (498) is "require DynaLoader;", so
I added the following untainting code at the top of the script,
but it did not get rid of this error:

#!/usr/bin/perl

# VERSION 3

BEGIN {
@INC = map { /(.*)/; $1 } @INC;
}

# etc.

I've run out of ideas.

What must one do to run Inline::C code under -T ???

TIA!

~K

P.S. I'm aware of the UNTAINT config option for Inline, but, AFAICT
enabling it would defeat the use I want to make of taint mode.
 
S

sisyphus

P.S. I'm aware of the UNTAINT config option for Inline, but, AFAICT
enabling it would defeat the use I want to make of taint mode.

It's quite likely that UNTAINT won't work, anyway. And if it does
work, it's just going to untaint things blindly - and that's not what
you (and probably anyone else) wants.

Better to avoid the Inline dependency altogether, and just write it as
a normal perl extension (which, I think, is what Ben was
recommending.) To that end, if you have all of your Inline::C
functions laid out in a file (say './functions.c') you might find
InlineX::C2XS useful. It can create the XS file, a stub .pm file, and
a Makefile.PL for you (in the current directory) with:

perl -MInlineX::C2XS -we 'c2xs("My::Mod", "My::Mod",
{WRITE_MAKEFILE_PL=>1, WRITE_PM=>1, VERSION=>0.01, SRC_LOCATION=>"./
functions.c", USING=>"ParseRegExp"});'

(USING=>"ParseRegExp" is not mandatory - it just provides much faster
parsing of the C code than the default Parse::RecDescent.)

Cheers,
Rob
 
S

sisyphus

perl -MInlineX::C2XS -we 'c2xs("My::Mod", "My::Mod", .....

Correction:

perl -MInlineX::C2XS -we 'InlineX::C2XS::c2xs("My::Mod",
"My::Mod", .....

I hope that's the only error .... (no guarantees)

Cheers,
Rob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top