CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
PL tainting problem

 



Fishhead
Novice

Apr 24, 2016, 4:53 PM

Post #1 of 10 (2621 views)
PL tainting problem Can't Post

I am starting a new thread since the nature of my problem seems to be pointing to an unanticipated problem.

My site is an auction for the commercial fishing industry. It has been up and running since 2011. It is currently located on a shared hosting site and I am in the process of moving it to a VPS site on another company's server.

I have move all the files and database to the new location and I have been testing everything before I have the DNS pointed to a the new location. For the most part everything looks good. I have an archive section, where a user can look at tables of past sales. These are generated from data stored in a mysql database. The display of past sales works fine.

However, when I test a new sale I get an error. For speed in testing I have been using a "buy-it-now" feature rather than have to wait for an auction to end.

The error message was in part "install_driver(mysql) failed: Can't locate DBD/mysql.pm in @INC ...". My thought was that I simply was not correctly pointing where required modules were being stored on the server. In part this was correct, however, ultimately after making suggested changes I received a new error message. The text is:

Quote
Can't locate object method "connect" via package "DBI" (perhaps you forgot to load "DBI"?) at ../auction/buyit.pl line 284, <BUYERFILE> line 79.


At this point Zhris suggested I run a test script. He provided me with the code as follows:

Code
#!/usr/bin/perlml   

BEGIN {
my $base_module_dir = (-d '/home/jeffer36/perl' ? '/home/jeffer36/perl' : ( getpwuid($>) )[7] . '/perl/');
unshift @INC, map { $base_module_dir . $_ } @INC;
}

use lib '/home/jeffer36/perl5/lib/perl5','/home/jeffer36/perl5/lib/perl5/x86_64-linux';

use strict;
use warnings FATAL => qw(all);
use CGI::Carp qw(fatalsToBrowser);
use DBI;

my $db = "jeffer36_closedauctions";
my $server = "localhost";
my $dsn = "DBI:mysql:database=$db;host=$server";
my $userid = 'userid';
my $passwd = 'passwd';

my $dbh = DBI->connect($dsn, $userid, $passwd);

print "content-type: text/plain\n\n";
print "completed successfully\n";


I saved this as a file called test.pl and ran it. I received this following error message:

Quote
Can't load '/home/jeffer36/perl5/lib/perl5/x86_64-linux/auto/DBI/DBI.so' for module DBI: /home/jeffer36/perl5/lib/perl5/x86_64-linux/auto/DBI/DBI.so: undefined symbol: PL_tainting at /usr/lib64/perl5/DynaLoader.pm line 200.
at /home/jeffer36/perl5/lib/perl5/x86_64-linux/DBI.pm line 286
BEGIN failed--compilation aborted at /home/jeffer36/perl5/lib/perl5/x86_64-linux/DBI.pm line 286.
Compilation failed in require at test.pl line 13.
BEGIN failed--compilation aborted at test.pl line 13.


When I run it on the old server, where I know everything works, the screen comes back and says "completed successfully".

So my question now is, is there some additional modules that I should have installed or is this something that I need to contact the server company and have them correct?

Any advice will be most welcome.

Pete


(This post was edited by Fishhead on Apr 25, 2016, 7:51 AM)


FishMonger
Veteran / Moderator

Apr 25, 2016, 8:00 AM

Post #2 of 10 (2614 views)
Re: [Fishhead] PL tainting problem [In reply to] Can't Post


Quote
I have move all the files and database to the new location


Does that include the (DBI and DBD::mysql) modules? If so, that is the most likely cause of the problem.

Pure perl modules can simple be moved but ones built using XS code can't, especially if they were built for a different version of perl or mysql. They would need to be built and installed on the new server instead of copying them from the old server.


(This post was edited by FishMonger on Apr 25, 2016, 8:05 AM)


Fishhead
Novice

Apr 25, 2016, 6:29 PM

Post #3 of 10 (2599 views)
Re: [FishMonger] PL tainting problem [In reply to] Can't Post

FishMonger, thanks for the reply.

The simple answer is no. I asked the server folks to install Perl because there was nothing there when I examined the folders via a FTP program. I also had to ask them to populate the modules in the cPanel because it was empty.

Once they told me that Perl and the modules had been installed I went to cPanel and began installing the modules that I had used before (ie DBI, DBD::mysql, et.). The only one that I copied from the old server was File::CounterFile because I had modified it slightly several years ago.

This morning I asked the server support people to re-install Perl, hoping that might help the situation. That did not help. So I am stuck at square one.

The only thing that does not work is inserting new data into the database. I can produce all of the archive tables that I want without any problems. I can disable the insert code and the auctions work fine by themselves. When I disable the insert, current sales data is written into temporary text files, it is just not saved in the mysql database.

Pete


FishMonger
Veteran / Moderator

Apr 25, 2016, 6:56 PM

Post #4 of 10 (2597 views)
Re: [Fishhead] PL tainting problem [In reply to] Can't Post

Are you having similar problems with other modules, or are all other modules that you install working correctly?


Fishhead
Novice

Apr 25, 2016, 7:47 PM

Post #5 of 10 (2594 views)
Re: [FishMonger] PL tainting problem [In reply to] Can't Post

As far as I know, the only problems seem to be related to DBD::mysql or DBI.

On the old server modules appeared to have stored in the perl folder, where as on the new server that are going into the perl5 folder. So I have added a number of use lib statements to include those folders.

This is what the current configuration looks like:

Code
#!/usr/bin/perlml 

BEGIN {
my $base_module_dir = (-d '/home/jeffer36/perl' ? '/home/jeffer36/perl' : ( getpwuid($>) )[7] . '/perl/');
unshift @INC, map { $base_module_dir . $_ } @INC;
}

use lib '/home/jeffer36/perl5/lib/perl5/x86_64-linux';
use lib '/home/jeffer36/perl5/lib/perl5/x86_64-linux/auto';
use lib '/home/jeffer36/perl5/lib/perl5/x86_64-linux-thread-multi/.meta';
use lib '/home/jeffer36/perl5/lib/perl5/x86_64-linux/Bundle';
use lib '/home/jeffer36/perl5/lib/perl5/x86_64-linux/BDB';
use lib '/home/jeffer36/perl5/lib/perl5/x86_64-linux/auto/DBI';
use lib '/home/jeffer36/perl5/lib/perl5/CGI/Session/Driver';
use lib '/home/jeffer36/perl5/man/man3';
use lib '/home/jeffer36/perl5/man/man1';
use lib '/home/jeffer36/perl5/bin';


use vars qw(%config %category %supercat %form %cookie $loginalias $loginpassword);
use POSIX qw(strftime);
use File::Copy;
use strict;
use CGI;
use CGI::Session;
use CGI::Carp qw(fatalsToBrowser);
use File::CounterFile;
use Data::Dumper;
use DBI;



When I run a test sale with the buy-it-now feature, I get this error message as the sale is to be finalized and the data inserted into the mysql database:

Quote
Can't locate object method "connect" via package "DBI" (perhaps you forgot to load "DBI"?) at ../auction/buyit.pl line 286, <BUYERFILE> line 85


The code at line 286 in buyit.pl is:

Code
## connect to database 
my $dbh = DBI->connect("DBI:mysql:$db:$server", $userid, $passwd);


When I go to the cPanel and look DBI is listed as installed.

And using the FTP program, CGI.pm is located in /perl5/lib/perl5/CGI"/Session/Driver.

Suggestions?

Pete


Zhris
Enthusiast

Apr 27, 2016, 11:11 AM

Post #6 of 10 (2575 views)
Re: [Fishhead] PL tainting problem [In reply to] Can't Post

You should focus on your original issue first, messing around with the code will inevitably create new errors that will need to be solved before getting back to square 1. The benefit of the standalone is that any one of us can run the exact code as you do without modification and eliminates the possibility that unknown script level factors are causing your issue.

Nonetheless, your new issue is a result of your modifications to @INC via lib. Each time you use lib, you are prioritizing the path as it unshifts each onto the beginning of @INC. /home/jeffer36/perl5/lib/perl5/CGI/Session/Driver is given a higher priority over the path where the DBI you want exists. When you use DBI, it actually uses /home/jeffer36/perl5/lib/perl5/CGI/Session/Driver/DBI.pm as this is the first place it finds it, but since the fully qualified package name is CGI::Session::Driver::DBI, let alone there not being a connect method, it errors. You should only ever need to include the root to your perl module libraries, the two you have in your original code should suffice. If you dump %INC, I suspect it will confirm the above with the entry 'DBI.pm' => '/home/jeffer36/perl5/lib/perl5/CGI/Session/Driver/DBI.pm'.

Chris


Fishhead
Novice

Apr 27, 2016, 3:59 PM

Post #7 of 10 (2566 views)
Re: [Zhris] PL tainting problem [In reply to] Can't Post

Chris thanks for your continued help.

Starting from square 1, let me step through where I am at this point. The original code is:

Code
#!/usr/bin/perlml 

BEGIN {
my $base_module_dir = (-d '/home/jeffer36/perl' ? '/home/jeffer36/perl' : ( getpwuid($>) )[7] . '/perl/');
unshift @INC, map { $base_module_dir . $_ } @INC;
}

use POSIX qw(strftime);
use File::Copy;
use strict;
use CGI;
use CGI::Session;
use CGI::Carp qw(fatalsToBrowser);
use File::CounterFile;
use Data::Dumper;
use DBI;
#use DBD::mysql


This generates the following error message:

Quote
install_driver(mysql) failed: Can't locate DBD/mysql.pm in @INC (@INC contains: /home/jeffer36/perl/home/jeffer36/perl5/lib/perl5 /home/jeffer36/perl/home/jeffer36/perl5/lib/perl5/x86_64-linux-thread-multi /home/jeffer36/perl/home/jeffer36/perl/usr/local/lib64/perl5 /home/jeffer36/perl/home/jeffer36/perl/usr/local/share/perl5 /home/jeffer36/perl/home/jeffer36/perl/usr/lib64/perl5/vendor_perl /home/jeffer36/perl/home/jeffer36/perl/usr/share/perl5/vendor_perl /home/jeffer36/perl/home/jeffer36/perl/usr/lib64/perl5 /home/jeffer36/perl/home/jeffer36/perl/usr/share/perl5
/home/jeffer36/perl/usr/local/lib64/perl5 /home/jeffer36/perl/usr/local/share/perl5 /home/jeffer36/perl/usr/lib64/perl5/vendor_perl /home/jeffer36/perl/usr/share/perl5/vendor_perl /home/jeffer36/perl/usr/lib64/perl5
/home/jeffer36/perl/usr/share/perl5 /home/jeffer36/perl.
/home/jeffer36/perl5/lib/perl5
/home/jeffer36/perl5/lib/perl5/x86_64-linux-thread-multi
/home/jeffer36/perl/usr/local/lib64/perl5 /home/jeffer36/perl/usr/local/share/perl5 /home/jeffer36/perl/usr/lib64/perl5/vendor_perl /home/jeffer36/perl/usr/share/perl5/vendor_perl /home/jeffer36/perl/usr/lib64/perl5
/home/jeffer36/perl/usr/share/perl5
/usr/local/lib64/perl5
/usr/local/share/perl5
/usr/lib64/perl5/vendor_perl
/usr/share/perl5/vendor_perl
/usr/lib64/perl5
/usr/share/perl5 .) at (eval 16) line 3, <BUYERFILE> line 88.
Perhaps the DBD::mysql perl module hasn't been fully installed,
or perhaps the capitalisation of 'mysql' isn't right.
Available drivers: DBM, ExampleP, File, Gofer, Proxy, SQLite, Sponge.
at ../auction/buyit.pl line 287


To locate the DBD/mysql file a "use lib" line was added:

Code
#!/usr/bin/perlml 


BEGIN {
my $base_module_dir = (-d '/home/jeffer36/perl' ? '/home/jeffer36/perl' : ( getpwuid($>) )[7] . '/perl/');
unshift @INC, map { $base_module_dir . $_ } @INC;
}
use lib '/home/jeffer36/perl5/lib/perl5','/home/jeffer36/perl5/lib/perl5/x86_64-linux','/home/jeffer36/perl5/lib/perl5/x86_64-linux/Bundle';



This generates this error message:

Quote
install_driver(mysql) failed: Can't load '/home/jeffer36/perl5/lib/perl5/x86_64-linux/auto/DBD/mysql/mysql.so' for module DBD::mysql: /home/jeffer36/perl5/lib/perl5/x86_64-linux/auto/DBD/mysql/mysql.so: undefined symbol: PL_perl_destruct_level at /usr/lib64/perl5/DynaLoader.pm line 200, <BUYERFILE> line 88.
at (eval 16) line 3
Compilation failed in require at (eval 16) line 3, <BUYERFILE> line 88.
Perhaps a required shared library or dll isn't installed where expected
at ../auction/buyit.pl line 284


I do not fully understand this message. I get that mysql.so could not be loaded. But there is no file DynaLoader.pm on my server. There is a module that can be installed call DynaLoader, but when I install it, it goes through all of the installation, but does not indicate where is being installed and if I search for it, it is not found. So I am puzzled and do not know what to do next.

Lastly, if I un# the "use DBD::mysql". I receive the same error message as above.

Pete


FishMonger
Veteran / Moderator

Apr 28, 2016, 9:50 AM

Post #8 of 10 (2544 views)
Re: [Fishhead] PL tainting problem [In reply to] Can't Post

It looks to me like you have several problems, the first being your begin block. It appears to me that it's messing up your @INC array.

Do you really have paths like these?

Quote
/home/jeffer36/perl/home/jeffer36/perl5/lib/perl5
/home/jeffer36/perl/home/jeffer36/perl5/lib/perl5/x86_64-linux-thread-multi
/home/jeffer36/perl/home/jeffer36/perl/usr/local/lib64/perl5


Or, are they really like these:

Quote
/home/jeffer36/perl5/lib/perl5
/home/jeffer36/perl5/lib/perl5/x86_64-linux-thread-multi
/home/jeffer36/perl/usr/local/lib64/perl5




This error message

Quote
install_driver(mysql) failed: Can't load '/home/jeffer36/perl5/lib/perl5/x86_64-linux/auto/DBD/mysql/mysql.so' for module DBD::mysql:

Tells me that you probably have a version conflict. The most common conflict in this case is that that the DBD::mysql module was built against a different version of perl or mysql than what you're using. The next most common conflict is that the database you're connecting to was manually copied from another server which uses a different version of mysql than what the new server has installed.

I hit the wrong button and submitted it before I was done. I'll post the rest separately.


(This post was edited by FishMonger on Apr 28, 2016, 9:52 AM)


FishMonger
Veteran / Moderator

Apr 28, 2016, 10:18 AM

Post #9 of 10 (2539 views)
Re: [Fishhead] PL tainting problem [In reply to] Can't Post

Let's try a test script that just connects to mysql and not your database and doesn't use your begin block.

Place and run the script below in your home directory. The modules will be found if they are located directly under your home dir.

Quote
/home/jeffer36/DBI.pm
/home/jeffer36/DBD/mysql.pm

If they are in a different directory, adjust the use lib ... statement accordingly.


Code
#!/usr/bin/perlml 

use strict;
use warnings FATAL => 'all';
use lib '.';
use DBI;
use DBD::mysql;
use Data::Dumper;

my $host = 'locahost';
my $user = 'userid';
my $pass = 'passwrd';

my @databases = DBI->data_sources("mysql",
{host => $host, user => $user, password => $pass}) or die DBI->errstr;

print Dumper \@databases;



(This post was edited by FishMonger on Apr 28, 2016, 1:38 PM)


Fishhead
Novice

Apr 29, 2016, 2:46 PM

Post #10 of 10 (2519 views)
Re: [FishMonger] PL tainting problem [In reply to] Can't Post

FishMonger

Sorry for the delay in responding to you. My "day job" was calling.

Your comments about incompatibility prompted me to delete all of the Perl files on the server and I have asked the tech support folks to re-install Perl. Once that is done, things will either work properly or I will be on firm ground talking with tech support about incompatibility.

Thank you much for your help. Don't take this wrong, but I hope that I am not back here anytime soon.

Pete

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives