Dinky7
asked on
module exporting/importing problem
THis is from the apache error log when i try and run the script.
"makerandom" is not exported by the Crypt::Random module at /usr/local/share/perl/5.6. 1/Crypt/Ra ndom/Gener ator.pm line 12
"makerandom_itv" is not exported by the Crypt::Random module at /usr/local/share/perl/5.6. 1/Crypt/Ra ndom/Gener ator.pm line 12
"makerandom_octet" is not exported by the Crypt::Random module at /usr/local/share/perl/5.6. 1/Crypt/Ra ndom/Gener ator.pm line 12
[Thu Nov 16 11:52:58 2006] [error] Can't continue after import errors at /usr/local/share/perl/5.6. 1/Crypt/Ra ndom/Gener ator.pm line 12
BEGIN failed--compilation aborted at /usr/local/share/perl/5.6. 1/Crypt/Ra ndom/Gener ator.pm line 12.
Compilation failed in require at /usr/local/share/perl/5.6. 1/Crypt/Ra ndom.pm line 18.
BEGIN failed--compilation aborted at /usr/local/share/perl/5.6. 1/Crypt/Ra ndom.pm line 18.
Compilation failed in require at /usr/local/share/perl/5.6. 1/Crypt/DS A.pm line 7.
BEGIN failed--compilation aborted at /usr/local/share/perl/5.6. 1/Crypt/DS A.pm line 7.
Compilation failed in require at /usr/local/share/perl/5.6. 1/Crypt/Op enPGP/Key/ Secret/DSA .pm line 31.
its saying that the the module Crypt::Random isn't exporting makerandom... etc but i have looked at the file and it is.
from the error log i can deduce this Crypt/OpenPGP/Key/Secret/D SA.pm imports Crypt/DSA.pm, which imports Crypt/Random.pm, which imports Crypt/Random/Generator.pm, WHICH IN TURN imports Crypt/Random.pm.
So what think is happening is that Crypt/Random/Generator.pm is loaded and then tries to load Crypt/Random.pm which tries to load Crypt/Random/Generator.pm but get stuck cause its waiting for Crypt/Random.pm to load. SO it can't load or something.
I don't know perl that well so i don't know if this situation is possible but heres the twist. On another machine where all these modules are the same there is no problem!
both machines have the same @INC paths etc. I don't know what else to look for.
Any clues or leads that i could look into would be appreciated
Thanks
"makerandom" is not exported by the Crypt::Random module at /usr/local/share/perl/5.6.
"makerandom_itv" is not exported by the Crypt::Random module at /usr/local/share/perl/5.6.
"makerandom_octet" is not exported by the Crypt::Random module at /usr/local/share/perl/5.6.
[Thu Nov 16 11:52:58 2006] [error] Can't continue after import errors at /usr/local/share/perl/5.6.
BEGIN failed--compilation aborted at /usr/local/share/perl/5.6.
Compilation failed in require at /usr/local/share/perl/5.6.
BEGIN failed--compilation aborted at /usr/local/share/perl/5.6.
Compilation failed in require at /usr/local/share/perl/5.6.
BEGIN failed--compilation aborted at /usr/local/share/perl/5.6.
Compilation failed in require at /usr/local/share/perl/5.6.
its saying that the the module Crypt::Random isn't exporting makerandom... etc but i have looked at the file and it is.
from the error log i can deduce this Crypt/OpenPGP/Key/Secret/D
So what think is happening is that Crypt/Random/Generator.pm is loaded and then tries to load Crypt/Random.pm which tries to load Crypt/Random/Generator.pm but get stuck cause its waiting for Crypt/Random.pm to load. SO it can't load or something.
I don't know perl that well so i don't know if this situation is possible but heres the twist. On another machine where all these modules are the same there is no problem!
both machines have the same @INC paths etc. I don't know what else to look for.
Any clues or leads that i could look into would be appreciated
Thanks
ASKER
Here are the headers to the modules:
package Crypt::Random::Generator;
use Crypt::Random qw(makerandom makerandom_itv makerandom_octet);
use Carp;
------------------
package Crypt::Random;
require Exporter;
use vars qw($VERSION @EXPORT_OK);
use Math::Pari qw(PARI floor Mod pari2pv pari2num lift);
use Carp;
use Data::Dumper;
use Class::Loader;
use Crypt::Random::Generator;
*import = \&Exporter::import;
@EXPORT_OK = qw( makerandom makerandom_itv makerandom_octet );
package Crypt::Random::Generator;
use Crypt::Random qw(makerandom makerandom_itv makerandom_octet);
use Carp;
------------------
package Crypt::Random;
require Exporter;
use vars qw($VERSION @EXPORT_OK);
use Math::Pari qw(PARI floor Mod pari2pv pari2num lift);
use Carp;
use Data::Dumper;
use Class::Loader;
use Crypt::Random::Generator;
*import = \&Exporter::import;
@EXPORT_OK = qw( makerandom makerandom_itv makerandom_octet );
ASKER
by headers i mean the head of the scripts :)
Yes, those are the headers to the modules, but how are you loading the modules in *your* script -- the one that generates the error when it runs?
ASKER
to be honest i can't give you to answer that you want because i haven't been able to find it myself (I didn't write the script i'm just trying to fix a problem *sigh*)
as i noted earlier:
Crypt/OpenPGP/Key/Secret/D SA.pm imports Crypt/DSA.pm, which imports Crypt/Random.pm, which imports Crypt/Random/Generator.pm, WHICH IN TURN imports Crypt/Random.pm.
each of these modules use 'use' or 'require' to load the modules.
in the scripts that i'm looking at i can't seem to find where it loads Crypt/OpenPGP/Key/Secret/D SA.pm to start off with.
All i can see so far is that my script loads Crypt::OpenPGP and the error occurs when a call is made to the Crypt::OpenPGP->sign method.
from there on I have tried to trace where that call goes and have not been able to find any scripts or modules that loads Crypt/OpenPGP/Key/Secret/D SA.pm (which in turn loads everything else)
Please note that all the Crypt:: modules should be independant because as i stated that on another box where all these modules are the same (the ones i've managed to trace, so i could be missing some) and it works on that box.
This doesn't seem to be very helpful lol. If theres any other information that may help you let me know.
Thanks
as i noted earlier:
Crypt/OpenPGP/Key/Secret/D
each of these modules use 'use' or 'require' to load the modules.
in the scripts that i'm looking at i can't seem to find where it loads Crypt/OpenPGP/Key/Secret/D
All i can see so far is that my script loads Crypt::OpenPGP and the error occurs when a call is made to the Crypt::OpenPGP->sign method.
from there on I have tried to trace where that call goes and have not been able to find any scripts or modules that loads Crypt/OpenPGP/Key/Secret/D
Please note that all the Crypt:: modules should be independant because as i stated that on another box where all these modules are the same (the ones i've managed to trace, so i could be missing some) and it works on that box.
This doesn't seem to be very helpful lol. If theres any other information that may help you let me know.
Thanks
Two things:
>> All i can see so far is that my script loads Crypt::OpenPGP and the error occurs when a call is made to the Crypt::OpenPGP->sign method.
What is the "my script" you're referring to in the above sentence? These errors are being stored in Apache's log, so I assume it's a CGI script. Before we think about blaming well-used and stable modules for the errors, I think we should look closely at the CGI script that's initiating the whole cascade. Can we see this CGI script?
>> Please note that all the Crypt:: modules should be independant because as i stated that on another box where all these modules are the same (the ones i've managed to trace, so i could be missing some) and it works on that box.
I would definately re-install the modules on the problem machine. Something may have been corrupted, so I would un-install the existing modules, and then re-install the latest versions. To uninstall a module, see http://www.cpan.org/misc/cpan-faq.html#How_delete_Perl_modules.
I'd also generate a list of installed modules from the machine that works, and compare it to a list generated on a machine giving you trouble (see http://www.cpan.org/misc/cpan-faq.html#How_installed_modules). See that you're using the same versions of all modules.
>> All i can see so far is that my script loads Crypt::OpenPGP and the error occurs when a call is made to the Crypt::OpenPGP->sign method.
What is the "my script" you're referring to in the above sentence? These errors are being stored in Apache's log, so I assume it's a CGI script. Before we think about blaming well-used and stable modules for the errors, I think we should look closely at the CGI script that's initiating the whole cascade. Can we see this CGI script?
>> Please note that all the Crypt:: modules should be independant because as i stated that on another box where all these modules are the same (the ones i've managed to trace, so i could be missing some) and it works on that box.
I would definately re-install the modules on the problem machine. Something may have been corrupted, so I would un-install the existing modules, and then re-install the latest versions. To uninstall a module, see http://www.cpan.org/misc/cpan-faq.html#How_delete_Perl_modules.
I'd also generate a list of installed modules from the machine that works, and compare it to a list generated on a machine giving you trouble (see http://www.cpan.org/misc/cpan-faq.html#How_installed_modules). See that you're using the same versions of all modules.
ASKER
I've copied code stubs from the main script and some parts of modules that it uses. Brief explanation is of what happens is in the main script it creates a SRS::OpenPGP object and a SRS::Communications object. SRS::Communications takes a SRS::OpnPGP object as one of its arguments.
SRS::Communications->send method is then called from the main script. this in turn calls SRS::OpenPGP->sign which then calls Crypt::OpenPGP->sign.
(These modules and scripts are the same on both machines)
I have also checked the versions of the installed modules on the working machine compared to the problem machine using the code from ur CPAN links and they are all identitcal. I'll see if it is possible to reinstall the modules
==Main Script==================== ========== ========== ===
sub srs_send {
my $xml = shift;
my $sec = shift || 0;
## Log the XML transaction
my $file = '';
my $time = time;
while ($file eq '' or -e $file) {
$file = "/acnts/logs/xml/srs/srs-x ml-$$-$tim e.txt";
$time++;
}
open (FILE, ">$file");
print FILE $xml;
close FILE;
## We should probably validate the XML against the DTD here too
## Initialise Error Repository
if (my $error = SRS::Error::Repository::in itialize(' SrsClient' )) {
return (undef, $error);
}
my $pgp = new SRS::OpenPGP(
'secretKeyRing' => '/acnts/lib/SRS/keys/secri ng.gpg',
'publicKeyRing' => '/acnts/lib/SRS/keys/pubri ng.gpg');
my $sender = new SRS::Communications(
url => $ServerURI,
registrar => $RegistrarID,
pgp => $pgp,
timeout => 7000,
);
print "1";
my ($sendError, $xmlResponse)
= $sender->send(requiresSecu rity=>$sec , request=>$xml); #<----FAILS INSIDE THIS CALL
print "2";
if ($sendError) {
return (undef, $sendError->logString());
}
========================== ========== =======
==SRS::OpenPGP module==================== ========== ========== =
package SRS::OpenPGP;
use strict;
use warnings;
use Carp;
use Crypt::OpenPGP;
sub new {
my ($class, %args) = @_;
# Create PGP Object
my $pgp = new Crypt::OpenPGP( SecRing => $args{secretKeyRing},
PubRing => $args{publicKeyRing},)
or croak "
Cannot instantiate OpenPGP object for
public key ring: $args{publicKeyRing}
secret key ring: $args{secretKeyRing}
" . Crypt::OpenPGP->errstr;
my $self = {PGP => $pgp};
bless ($self,$class);
$self->{DefaultSigningKey} = $self->findSigningKey($arg s{uid})
or warn "No default signing key". ($args{uid} ? "($args{uid})" : "");
$self->{DefaultEncryptingK ey} = $self->findEncryptingKey($ args{uid})
or warn "No default encrypting key".($args{uid} ? "($args{uid})" : "");
return $self;
}
sub sign {
my $self = shift;
my %params = @_;
my $data = $params{Data} or croak "Data not supplied";
my $key = $params{Key} || $self->{DefaultSigningKey} ;
my $passphrase = $params{PassPhrase} || '';
my $pgp = $self->{PGP};
print "-SRS PGP 1-";
my $signature = $pgp->sign(Data => clean ($data), # XXX this needs more thought
Detach => 1,
Armour => 1,
Digest => 'SHA1',
PassPhrase => $passphrase,
Key => $key); #<---FAILS INSIDE THIS CALL
print "-SRS PGP 2-";
carp "Signing attempt failed: ", $pgp->errstr() unless $signature;
print "-SRS PGP 3-";
return $signature;
}
========================== ========== ========
==SRS::Communications===== ========== ========== ========== ======
sub send {
my $self = shift;
my %params = @_;
my %postParams;
if ($params{postParams}) {
%postParams = %{$params{postParams}};
}
my $pgp = $self->{pgp};
# Check for parameters
unless (defined($params{request}) ) {
return generateError(MISSING_MAND ATORY_FIEL D(), 'Request');
}
my $request = $params{request};
print "-SRS Comm1-";
# Sign Request
my $signature = $pgp->sign(Data => $request); #<---FAILS INSIDE THIS CALL
print "-SRS Comm2-";
========================== ========== ========
SRS::Communications->send method is then called from the main script. this in turn calls SRS::OpenPGP->sign which then calls Crypt::OpenPGP->sign.
(These modules and scripts are the same on both machines)
I have also checked the versions of the installed modules on the working machine compared to the problem machine using the code from ur CPAN links and they are all identitcal. I'll see if it is possible to reinstall the modules
==Main Script====================
sub srs_send {
my $xml = shift;
my $sec = shift || 0;
## Log the XML transaction
my $file = '';
my $time = time;
while ($file eq '' or -e $file) {
$file = "/acnts/logs/xml/srs/srs-x
$time++;
}
open (FILE, ">$file");
print FILE $xml;
close FILE;
## We should probably validate the XML against the DTD here too
## Initialise Error Repository
if (my $error = SRS::Error::Repository::in
return (undef, $error);
}
my $pgp = new SRS::OpenPGP(
'secretKeyRing' => '/acnts/lib/SRS/keys/secri
'publicKeyRing' => '/acnts/lib/SRS/keys/pubri
my $sender = new SRS::Communications(
url => $ServerURI,
registrar => $RegistrarID,
pgp => $pgp,
timeout => 7000,
);
print "1";
my ($sendError, $xmlResponse)
= $sender->send(requiresSecu
print "2";
if ($sendError) {
return (undef, $sendError->logString());
}
==========================
==SRS::OpenPGP module====================
package SRS::OpenPGP;
use strict;
use warnings;
use Carp;
use Crypt::OpenPGP;
sub new {
my ($class, %args) = @_;
# Create PGP Object
my $pgp = new Crypt::OpenPGP( SecRing => $args{secretKeyRing},
PubRing => $args{publicKeyRing},)
or croak "
Cannot instantiate OpenPGP object for
public key ring: $args{publicKeyRing}
secret key ring: $args{secretKeyRing}
" . Crypt::OpenPGP->errstr;
my $self = {PGP => $pgp};
bless ($self,$class);
$self->{DefaultSigningKey}
or warn "No default signing key". ($args{uid} ? "($args{uid})" : "");
$self->{DefaultEncryptingK
or warn "No default encrypting key".($args{uid} ? "($args{uid})" : "");
return $self;
}
sub sign {
my $self = shift;
my %params = @_;
my $data = $params{Data} or croak "Data not supplied";
my $key = $params{Key} || $self->{DefaultSigningKey}
my $passphrase = $params{PassPhrase} || '';
my $pgp = $self->{PGP};
print "-SRS PGP 1-";
my $signature = $pgp->sign(Data => clean ($data), # XXX this needs more thought
Detach => 1,
Armour => 1,
Digest => 'SHA1',
PassPhrase => $passphrase,
Key => $key); #<---FAILS INSIDE THIS CALL
print "-SRS PGP 2-";
carp "Signing attempt failed: ", $pgp->errstr() unless $signature;
print "-SRS PGP 3-";
return $signature;
}
==========================
==SRS::Communications=====
sub send {
my $self = shift;
my %params = @_;
my %postParams;
if ($params{postParams}) {
%postParams = %{$params{postParams}};
}
my $pgp = $self->{pgp};
# Check for parameters
unless (defined($params{request})
return generateError(MISSING_MAND
}
my $request = $params{request};
print "-SRS Comm1-";
# Sign Request
my $signature = $pgp->sign(Data => $request); #<---FAILS INSIDE THIS CALL
print "-SRS Comm2-";
==========================
Where are $ServerURI and $RegistrarID defined? They're not passed to the sub, are they global?
Try adding few debugging messages, to see where it's actually failing:
sub srs_send {
my $xml = shift or die "Didn't get \$xml\n";
my $sec = shift || 0;
## Log the XML transaction
my $file = '';
my $time = time;
while ($file eq '' or -e $file) {
$file = "/acnts/logs/xml/srs/srs-x ml-$$-$tim e.txt" or die "Can't assign to \$file\n";
$time++;
}
open (FILE, ">$file") or die "Can't open file $file: $!\n";;
print FILE $xml;
close FILE;
## We should probably validate the XML against the DTD here too
## Initialise Error Repository
if (my $error = SRS::Error::Repository::in itialize(' SrsClient' )) {
return (undef, $error);
}
my $pgp = new SRS::OpenPGP(
'secretKeyRing' => '/acnts/lib/SRS/keys/secri ng.gpg',
'publicKeyRing' => '/acnts/lib/SRS/keys/pubri ng.gpg')
or die "Can't assign to \$pgp\n";
my $sender = new SRS::Communications(
url => $ServerURI,
registrar => $RegistrarID,
pgp => $pgp,
timeout => 7000,
) or die "Can't assign to \$sender\n";
print "1";
my ($sendError, $xmlResponse)
= $sender->send(requiresSecu rity=>$sec , request=>$xml); #<----FAILS INSIDE THIS CALL
print "2";
if ($sendError) {
return (undef, $sendError->logString());
}
} # I added this
Try adding few debugging messages, to see where it's actually failing:
sub srs_send {
my $xml = shift or die "Didn't get \$xml\n";
my $sec = shift || 0;
## Log the XML transaction
my $file = '';
my $time = time;
while ($file eq '' or -e $file) {
$file = "/acnts/logs/xml/srs/srs-x
$time++;
}
open (FILE, ">$file") or die "Can't open file $file: $!\n";;
print FILE $xml;
close FILE;
## We should probably validate the XML against the DTD here too
## Initialise Error Repository
if (my $error = SRS::Error::Repository::in
return (undef, $error);
}
my $pgp = new SRS::OpenPGP(
'secretKeyRing' => '/acnts/lib/SRS/keys/secri
'publicKeyRing' => '/acnts/lib/SRS/keys/pubri
or die "Can't assign to \$pgp\n";
my $sender = new SRS::Communications(
url => $ServerURI,
registrar => $RegistrarID,
pgp => $pgp,
timeout => 7000,
) or die "Can't assign to \$sender\n";
print "1";
my ($sendError, $xmlResponse)
= $sender->send(requiresSecu
print "2";
if ($sendError) {
return (undef, $sendError->logString());
}
} # I added this
ASKER
yes $ServerURI and $RegistrarID and global in the main script.
I have added debugging comments to the scriipts i have write access to. It fails in the SRS::OpenPGP->sign method which makes a call to Crypt::OpenPGP->sign. it does not return from the Crypt::OpenPGP->sign call but dies, according to the apache log, when somehwere down the line it trys to load the Crypt::Random module.
Corruption of the modules seems like a possiblility but I've done a diff on the modules that i can trace and they are all the same.
The include paths are exactly the same. I don't see what else could be different between the 2 servers that would cause this problem :(
Thanks for your input so far mjcoyne
I have added debugging comments to the scriipts i have write access to. It fails in the SRS::OpenPGP->sign method which makes a call to Crypt::OpenPGP->sign. it does not return from the Crypt::OpenPGP->sign call but dies, according to the apache log, when somehwere down the line it trys to load the Crypt::Random module.
Corruption of the modules seems like a possiblility but I've done a diff on the modules that i can trace and they are all the same.
The include paths are exactly the same. I don't see what else could be different between the 2 servers that would cause this problem :(
Thanks for your input so far mjcoyne
So, it dies at:
my $pgp = new SRS::OpenPGP(
'secretKeyRing' => '/acnts/lib/SRS/keys/secri ng.gpg',
'publicKeyRing' => '/acnts/lib/SRS/keys/pubri ng.gpg')
or die "Can't assign to \$pgp\n";
?
This would indicate to me, all other things being equal (e.g. putting aside for a minute the possibility of corrupt modules, and assuming that all directory stuctures are the same in name and permissions between the two servers), that there's something wrong with your secret or public (or both) keyring files on the server giving you problems.
Are the pubring.gpg and secring.gpg keyring files exactly the same size on both machines (assuming they contain the same contents)? Are they assigned the same permissions on both machines? Though the structure (names and order) of the directories are the same on both machines, are the permissions set for all directories and subdirectories the same? Are both machines running the same OS? Do the user accounts the web server and Perl run under assigned the same privileges?
my $pgp = new SRS::OpenPGP(
'secretKeyRing' => '/acnts/lib/SRS/keys/secri
'publicKeyRing' => '/acnts/lib/SRS/keys/pubri
or die "Can't assign to \$pgp\n";
?
This would indicate to me, all other things being equal (e.g. putting aside for a minute the possibility of corrupt modules, and assuming that all directory stuctures are the same in name and permissions between the two servers), that there's something wrong with your secret or public (or both) keyring files on the server giving you problems.
Are the pubring.gpg and secring.gpg keyring files exactly the same size on both machines (assuming they contain the same contents)? Are they assigned the same permissions on both machines? Though the structure (names and order) of the directories are the same on both machines, are the permissions set for all directories and subdirectories the same? Are both machines running the same OS? Do the user accounts the web server and Perl run under assigned the same privileges?
ASKER
the script dies in SRS::OpenPGP
my $signature = $pgp->sign(Data => clean ($data), # XXX this needs more thought
Detach => 1,
Armour => 1,
Digest => 'SHA1',
PassPhrase => $passphrase,
Key => $key); #<---FAILS INSIDE THIS CALL
$pgp here is a Crypt::OpenPGP object. so the call to Crypt::OpenPGP->sign() is where it dies.
I copied the keyrings from the good to the problem server and it makes no difference.
The directories and keyrings have more permissions on the problem machine but the owner and user group are different. I don't know if that makes a difference.
the /etc/debian_version file are both 3.0
uname release is 2.4.27 on the problem machine and 2.4.19 on the other.
I'm not sure how to find the user accounts for the web server and perl.
If it was a permission problem wouldn't the apache log say can't access the module instead of saying the module doesn't export the functions?
my $signature = $pgp->sign(Data => clean ($data), # XXX this needs more thought
Detach => 1,
Armour => 1,
Digest => 'SHA1',
PassPhrase => $passphrase,
Key => $key); #<---FAILS INSIDE THIS CALL
$pgp here is a Crypt::OpenPGP object. so the call to Crypt::OpenPGP->sign() is where it dies.
I copied the keyrings from the good to the problem server and it makes no difference.
The directories and keyrings have more permissions on the problem machine but the owner and user group are different. I don't know if that makes a difference.
the /etc/debian_version file are both 3.0
uname release is 2.4.27 on the problem machine and 2.4.19 on the other.
I'm not sure how to find the user accounts for the web server and perl.
If it was a permission problem wouldn't the apache log say can't access the module instead of saying the module doesn't export the functions?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
both perl versions are 5.6.1. both machines keyrings are binary files as well.
times like these make u wanna break stuff lol.
I think the answer is 'It should be working' haha.
A complete format might be the way to go but thats out of the question unfortunately
times like these make u wanna break stuff lol.
I think the answer is 'It should be working' haha.
A complete format might be the way to go but thats out of the question unfortunately
ASKER
oh well, thanks for your input mjcoyne.
I'm just gonna skip this problem until i have to fix it lol
I'm just gonna skip this problem until i have to fix it lol
use Crypt::Random qw( makerandom );