Gossamer Forum
Home : Products : Links 2.0 : Discussions :

Need Some Help With Links2 Error

Quote Reply
Need Some Help With Links2 Error
I moved my website to a new server and when checking to see if Links2 still worked I found the following errors when trying to add a new link to the database.

Quote:
Error Message : fatal error: Can't locate GD.pm in @INC (@INC contains: /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 admin/captcha/captcha.pl line 42.
BEGIN failed--compilation aborted at admin/captcha/captcha.pl line 42.
Compilation failed in require at /home/mywebsite/public_html/links/cgi-bin/admin/db_utils.pl line 629.

Script Location : add.cgi
Perl Version : 5.016003

Here is what I see when checking for GD on the server:

Quote:
# php -i | grep 'GD\|ImageMagick'
GD Support => enabled
GD Version => bundled (2.1.0 compatible)

I've looked through the folders and files named in the error message but not sure what is causing the error. Something to do with the captcha changes made but not sure how to troubleshoot. Any ideas?

Also just want to say it is awesome that the powers that be kept this forum up and running. Kudos to all of you!
Basshook
Quote Reply
Re: [Basshook] Need Some Help With Links2 Error In reply to
Hi,

You are looking at PHP, not Perl. Perl uses different modules. So you want to run:

Code:
cpanm GD

If you are not the server admin, then you just need to ask your host to do this for you (it will require root access to the server)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Need Some Help With Links2 Error In reply to
Hi Andy, thanks for the heads up. Sometimes I wonder where my head is at? ;) ;)

If anyone is interested here is the command I used to determine whether Perl GD is installed on my Centos 7 machine:
Quote:
rpm -q perl-GD

And here is the command I used to install it once I determined it wasn't there:
Quote:
yum install perl-GD

Hopefully this will resolve my issue and I'll come back to let you know either way.
Basshook
Quote Reply
Re: [Basshook] Need Some Help With Links2 Error In reply to
Andy, could you tell me if GD.pm is a separate module of Perl GD or is that just the file ext for the GD library. It is a little confusing to me. I've installed Perl GD and rebooted the server but now I only get a blank page which is better than the errors I guess.
Basshook
Quote Reply
Re: [Basshook] Need Some Help With Links2 Error In reply to
If you have root, just do:

Code:
updatedb
locate GD.pm

It may be that your server software has put it in a different lib path, and you need to "include" that in add.cgi. Plesk and cPanel are a real pain for this.

GD is just normal GD. You could also try it with:

Code:
cpanm GD

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Need Some Help With Links2 Error In reply to
Andy, thanks for the reply. I just used
Code:
locate GD.pm
without
Code:
udatedb
and that worked on my server.

Here are the results:
Quote:
# locate GD.pm
/usr/lib64/perl5/vendor_perl/GD.pm
/usr/local/cpanel/3rdparty/perl/532/lib/perl5/cpanel_lib/x86_64-linux-64int/GD.pm

So it is definitely there now.

I have already removed the antibot and captcha modifications and re-installed the original files that those mods made changes to and everything is working as normal so I will start to add the mods again to see if they still work.

I hope so as I am already seeing bot registrations. Doesn't take them long.

On a side note: I cannot use the advanced editor because it embeds the actual forum webpage and there is no place to write anything. I have to switch back to the classic editor. Is that normal?
Basshook
Quote Reply
Re: [Basshook] Need Some Help With Links2 Error In reply to
Hi,

You could try adding this in add.cgi, after the #!/path/to/perl ... so:

Code:
use lib '/usr/local/cpanel/3rdparty/perl/532/lib/perl5/cpanel_lib/x86_64-linux-64int/';

Another option is to create a test script to see what environment variables are set (paths to the "libs" for example);

test.cgi

Code:
#!/usr/bin/perl

use Data::Dumper;
print "Content-Type:text/html\n\n";
print Dumper({ inc => \@INC });

CHMOD to 755 and then run from the browser. What does that print?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Need Some Help With Links2 Error In reply to
Andy, thanks again. Here is my add.cgi file. Is this where you wanted the code you provided?
Code:
#!/usr/bin/perl
# -------------
# Links
# -------------
# Links Manager
#
# File: add.cgi
# Description: Adds a record marked unvalidated to the database and
# optionally emails someone.
# Author: Alex Krohn
# Email: alex@gossamer-threads.com
# Web: http://www.gossamer-threads.com/
# Version: 2.01
#
# (c) 1998 Gossamer Threads Inc.
#
# This script is not freeware! Please read the README for full details
# on registration and terms of use.
# =====================================================================
#
# Setup Notes:
# Make sure the require statement below points to the config file.

# Required Librariers
# --------------------------------------------------------

use lib '/usr/local/cpanel/3rdparty/perl/532/lib/perl5/cpanel_lib/x86_64-linux-64int/';
eval {
($0 =~ m,(.*)/[^/]+,) && unshift (@INC, "$1"); # Get the script location: UNIX /
($0 =~ m,(.*)\\[^\\]+,) && unshift (@INC, "$1"); # Get the script location: Windows \

require "/home/website/public_html/links/cgi-bin/admin/links.cfg"; # Change this to full path to links.cfg if you have problems.
require "$db_lib_path/db_utils.pl";
require "$db_lib_path/links.def";
$build_use_templates ?
require "$db_lib_path/site_html_templates.pl" :
require "$db_lib_path/site_html.pl";
};

Also I created the test.cgi file with the code you provided, chmod to 755 and got a 500 server error when browsing to it.
Basshook
Quote Reply
Re: [Basshook] Need Some Help With Links2 Error In reply to
Hi,

Yes, that looks like the place I wanted it added. Been a while since I used Links2. Did you replace any lines to put that in? Or just add it above the eval {} ?

Odd why my test script didn't work. What if you add this to it near the top:

Code:
use CGI::Carp qw(fatalsToBrowser);

(after the path to perl, on a new line)

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Need Some Help With Links2 Error In reply to
Hi Andy, Yes I added it above the eval() function without replacing anything. I haven't tried this method yet though to see if it works, just wanted to be clear where you wanted it placed.

As for the test.cgi error, I am see this in my apache logs:
Quote:
[Wed Apr 21 09:48:21.063402 2021] [cgid:error] [pid 24419:tid 47552762627840] [client 70.67.143.193:53358] End of script output before headers: test.cgi


And this in my modsec_audit_log file:
Quote:
GET //cgi-bin/test.cgi HTTP/1.1
Apache-Error: [file "apache2_util.c"] [line 271] [level 3] [client 85.214.44.193] ModSecurity: Access denied with code 403 (phase 1). Pattern match "^(?:\\\\\\\\'\\\\\\\\w+?=)?\\\\\\\\(\\\\\\\\)\\\\\\\\s{" at MATCHED_VAR. [file "/etc/apache2/conf.d/modsec_vendor_configs/comodo_apache/02_Global_Generic.conf"] [line "80"] [id "221260"] [rev "3"] [msg "COMODO WAF: Shellshock Command Injection Vulnerabilities in GNU Bash through 4.3 bash43-026 (CVE-2014-7187, CVE-2014-7186, CVE-2014-7169, CVE-2014-6278, CVE-2014-6277, CVE-2014-6271)||71.19.244.107|F|2"] [severity "CRITICAL"] [tag "CWAF"] [tag "Generic"] [hostname "71.19.244.107"] [uri "/cgi-bin/test.cgi"] [unique_id "X9-HwB9cqlh40TFzr5nfZAAAAMY"]


It seems a modsecurity rule is blocking the request for the test.cgi.
Tried whitelisting rule id#221260 for the domain but that didn't work.

I am going to try modifying the files necessary to install the antibot and captcha plugins again to see if it will work. Think I'll install one at a time and verify before installing the other one.
Basshook

Last edited by:

Basshook: Apr 21, 2021, 11:07 AM
Quote Reply
Re: [Basshook] Need Some Help With Links2 Error In reply to
Andy,

I started over and verified that the "Add Confirm" mod works.

I then re-installed all the captcha mod code where it belongs and when I tried to add a new site to the links page I got this error:

Quote:
fatal error: GD::Image::copy: source is not of type GD::Image at admin/captcha/captcha.pl line 162


Here is what is at line 158-168 in captcha.pl and I underlined 162:

Quote:
# copy the character images into the code graphic
for($captcha_i=0; $captcha_i<$captcha_length; $captcha_i++){
$captcha_letter = substr($captcha_code,$captcha_i,1);
$captcha_source = new GD::Image("$captcha_imagesfolder/$captcha_letter.png");
$captcha_im->copy($captcha_source,$captcha_i*$captcha_width,0,0,0,$captcha_width,$captcha_height);
$captcha_a =int(rand (int($captcha_width/14)))+0;
$captcha_b =int(rand (int($captcha_height/12)))+0;
$captcha_c =int(rand (int($captcha_width/3)))-(int($captcha_width/5));
$captcha_d =int(rand (int($captcha_height/3)))-(int($captcha_height/5));
$captcha_im->copyResized($captcha_source,($captcha_i*$captcha_width)+$captcha_a,$captcha_b,0,0,$captcha_width+$captcha_c,$captcha_height+$captcha_d,$captcha_width,$captcha_height);


I checked my apache_error_log and mod security logs and there is nothing referencing the GD error.

I believe I am getting closer. I wonder if links2 captcha mod isn't compatible with the newer version of GD.pm?
Basshook

Last edited by:

Basshook: Apr 21, 2021, 5:16 PM
Quote Reply
Re: [Basshook] Need Some Help With Links2 Error In reply to
Okay it seems that GD::Image is another module I have to install on my server but the command I used didn't work.

Quote:
# rpm -q perl-GD::Image
package perl-GD::Image is not installed

# yum install perl-GD::Image
Loaded plugins: fastestmirror, universal-hooks
Loading mirror speeds from cached hostfile
* EA4: 204.10.37.146
* cpanel-addons-production-feed: 204.10.37.146
* cpanel-plugins: 204.10.37.146
* base: mirror.esecuredata.com
* extras: centos.mirror.netelligent.ca
* updates: centos.ca-west.mirror.fullhost.io
No package perl-GD::Image available.
Error: Nothing to do

Is there another way to install this module? My searching hasn't come up with another one.
Basshook
Quote Reply
Re: [Basshook] Need Some Help With Links2 Error In reply to
If you have cpanm, you can do this as root:

Code:
cpanm GD::Image

Or:

Code:
perl -e 'install GD::Image'

Both of those should work if you have the correct permissions. I'm afraid I don't know much about the CAPTCHA plugin for Links2. The last time I used links2 was probably 10-15 years ago. I work exclusively with the SQL version now which is very different.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Need Some Help With Links2 Error In reply to
Hi Andy, thanks again for your support. I've tried both suggestions and here is the output:
Quote:
cpanm GD::Image
-bash: cpanm: command not found
# perl -e 'install GD::Image'
Can't locate object method "install" via package "GD::Image" (perhaps you forgot to load "GD::Image"?) at -e line 1.


I tried cpan GD::Image and it ran for a while but still didn't install GD::Image but installed a few other modules. Even logged into my WHM and tried to install the GD::Image module from there but nothing is working it seems.

Not sure why I wouldn't have permissions as I manage my own dedicated server. Not that experienced at it obviously but I am learning.
Basshook

Last edited by:

Basshook: Apr 21, 2021, 11:32 PM
Quote Reply
Re: [Basshook] Need Some Help With Links2 Error In reply to
Sorry my mistake - it should be:

Code:
perl -MCPAN -e 'install GD::Image'

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Need Some Help With Links2 Error In reply to
Andy,

Okay just tried to add a site to the links again and this time I got this error:
Quote:
/home/website/links/cgi-bin/admin/captcha/images/b.png not found: No such file or directory at /usr/local/lib64/perl5/GD/Image.pm line 64


When I went to /usr/local/lib64/perl5/GD/Image.pm, GD:Image was there. Very strange that the command I used was telling me it wasn't installed.
Basshook
Quote Reply
Re: [Basshook] Need Some Help With Links2 Error In reply to
/home/website/links/cgi-bin/admin/captcha/images/

Does that folder exist, and has 775 CHMOD?

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Need Some Help With Links2 Error In reply to
Andy, yes both captcha and images exist and are 755.
I'm running out of gas so off to bed and giver a go in the morning. Appreciate all your help on this. Sooner or later I'll get it figured out.
Basshook
Quote Reply
Re: [Basshook] Need Some Help With Links2 Error In reply to
Andy, one last question for tonight. Is PerlFlunkie still around? Haven't seen any recent posts by him.
Basshook

Last edited by:

Basshook: Apr 21, 2021, 11:53 PM
Quote Reply
Re: [Basshook] Need Some Help With Links2 Error In reply to
775 not 755 :)

Quote:
Appreciate all your help on this.

NP

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Basshook] Need Some Help With Links2 Error In reply to
Basshook wrote:
Andy, one last question for tonight. Is PerlFlunkie still around? Haven't seen any recent posts by him.

No idea. The forum has been pretty dead for a while, as GT don't update any of their scripts any more. In fact, they did take the forum offline (but I convinced them to keep it going, as there are still a few active users who are using GT scripts, and its a great resource)

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Need Some Help With Links2 Error In reply to
Andy, sorry for not getting back to you but something else has reared its ugly head that I have to deal with. I will take care of that and come back to this issue with my results and hopefully you will still be around to help if needed. Thanks again.
Basshook