[ic] GlobalSub can't use modules

Honest to Goodness interchange-users@interchange.redhat.com
Tue Apr 2 12:09:00 2002


I have some GlobalSubs defined in my interchange.cfg file like so:

# Include GlobalSubs.
include eg/globalsub/*.pl

I call them from my [ic] pages like this:

[perl subs=1]
my @out = silly();
return("@out");
[/perl]

When my foundation catalog delivers the pages, the correct output of
some hello-world functions is returned so I know all of this works.

In my /eg folder I have 2 perl modules, a tester and the one I'm working
on. In another directory I have "standalone" versions of these same
files. The standalone versions are stripped of subroutine braces and end
with print statements instead of a return.

The standalone versions work fine and both rely on external modules
called with "use". I can launch them with command lines like "perl
tcptest.pl" or ./sillywerd.pl because they start with the magic line
#!/usr/bin/perl.

I have only one version of perl installed on my system and the modules
that I call are installed as well. That's why everything works.

Here is the globalsub I'm working on, it's purpose is to assemble some
XML, open a socket to Canada Post, send the xml and receive a big pile
of html in return.

GlobalSub <<EOS

sub canpost {

use IO::Socket::INET;
my $server = '206.191.4.228';
my $port = 30000;

my @out = '<?xml version="1.0" ?>';
push (@out, '<eparcel>');

# ... lots of xml goes here, it is ommitted

push (@out, '</eparcel>');
push (@out, '');

my $sock = IO::Socket::INET->new(
  Proto  => "tcp",
  PeerAddr => $server,
  PeerPort => $port,
  Reuse => 1
  );
 unless ($sock) { die "cannot connect to post host" }
 $sock->autoflush(1);
 foreach $line (@out) {
   print $sock "$line\n";
 }
@out = '';
 yup: while ( <$sock> ) {
    last yup if (/END_OF_EPARCEL/);
    push (@out, $_);
}
 close $sock;
 return("@out");
}
EOS

When [ic] delivers a page where this globalsub is called, it fails with
the following error:

127.0.0.1 sWd49xo2:127.0.0.1 - [01/April/2002:14:45:47 -0500] foundation
/cgi-bin/foundation/aboutus.html Safe: Can't locate object method "new"
via package "IO::Socket::INET" (perhaps you forgot to load
"IO::Socket::INET"?) at (eval 129) line 34.

When [ic] delivers a page that relies upon the externally loaded module
called "Silly::Werder" I get the same sort of thing:

127.0.0.1 X6edu5dR:127.0.0.1 - [02/April/2002:11:35:44 -0500] foundation
/cgi-bin/foundation/aboutus.html Safe: Can't locate object method "new"
via package "Silly::Werder" (perhaps you forgot to load
"Silly::Werder"?) at (eval 130) line 5.

Sillywerd composes and delivers gibberish words and like tcptest it
works fine when run from the command line as a standalone.

It is now obvious that [ic] is unable to load any modules at run time.
So I did an "su interch" and ran the standalones from there and they
worked fine.

Looking closely at the errors it says that Safe: has reported them. Does
this mean that there is no escaping Safe:? Is there is no place in [ic]
where one can run perl without intervention? Hours spent reading the
mailing list archive would suggest that this is not so.

This is the reason why I'm using this whole GlobalSub sytem in the first
place, so I can get around Safe. Is the Safe installed on my machine
somehow set to extra stringent?

So after displaying all of this detailed context my question is:

How can I get around Safe so that I can use modules in my GlobalSub?