Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cgi-bin resolves to wrong location #6

Open
bitsgalore opened this issue Oct 16, 2020 · 0 comments
Open

cgi-bin resolves to wrong location #6

bitsgalore opened this issue Oct 16, 2020 · 0 comments

Comments

@bitsgalore
Copy link
Member

bitsgalore commented Oct 16, 2020

Example:

http://mazda.nl/cgi-bin/dealer

Returns 404. Source:

<A HREF=/cgi-bin/dealer><IMG SRC=323.jpg WIDTH=188 HEIGHT=100 BORDER=0><BR>Of vind nu al de kortste weg naar de Mazda dealer</A>

Looking at httpd.conf:

Exec    /cgi-bin/*	/home/local/www/mazda/cgi-bin/*

So originally this resolved to location outside of "root" dir defined in:

Map /*.map  /htbin/htimage/home/local/www/mazda/root/

So how does the server "know" that it has to use the script inside the mazda/cgi-bin/ dir?

So perhaps /cgi-bin/ needs ScriptAlias or sth similar:

https://stackoverflow.com/questions/18903002/apache-scriptalias-cgi-bin-directory

But look here:

https://httpd.apache.org/docs/2.4/vhosts/mass.html

So (TODO: modify script so /var/www/chi-bin is included as well!):

ScriptAlias /cgi-bin/ "/var/www/xxLINK-DDS-2/www/mazda/cgi-bin/"
ScriptAlias /htbin/ "/var/www/cgi-bin/"

But now wet get a 500 Internal Server Error. Apache log file:

[Fri Oct 16 18:08:24.893667 2020] [cgid:error] [pid 18738:tid 139934497795008] (2)No such file or directory: AH01241: exec of '/var/www/xxLINK-DDS-2/www/mazda/cgi-bin/dealer' failed
[Fri Oct 16 18:08:24.893933 2020] [cgid:error] [pid 18346:tid 139934287505152] [client 127.0.0.1:51572] End of script output before headers: dealer, referer: http://mazda.nl/home.htm

Looking at the script:

#!/bin/perl
#
# Requires: lib vsbbank

# $spath_real: the path of the script on the server
$spath_real = '/home/local/www/mazda/cgi-bin';

# Obtain the subroutines needed
require "$spath_real/lib";
require "$spath_real/mazda";

First of all interpreter defined in shebang (/bin/perl) doesn't exist on file system, so changed this to /usr/bin/perl. After that script runs, but fails on:

[Fri Oct 16 18:21:36.050241 2020] [core:notice] [pid 1517:tid 139934497795008] AH00094: Command line: '/usr/sbin/apache2'
Can't locate /home/local/www/mazda/cgi-bin/lib at /var/www/xxLINK-DDS-2/www/mazda/cgi-bin/dealer line 9.
[Fri Oct 16 18:21:41.284539 2020] [cgid:error] [pid 19949:tid 139934407153408] [client 127.0.0.1:51718] End of script output before headers: dealer, referer: http://mazda.nl/home.htm

Which is caused bc script has hard-coded path ( '/home/local/www/mazda/cgi-bin') that exists somewhere else on the local fs.

Also, apparently the script dependson locally installed custom software as well (lib vsbbank):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant