Project

General

Profile

Perl CGIs work but C CGIs don't -> give 404 errors

Added by philip_rhoades over 5 years ago

People,

I have spent a few hours trying to get various C CGI examples from the web compiled and going - all with the same result - a 404 error. Even the most simple exercise from here:

http://www.minidevs.com/note/note239.html

gives me the same result.

The only thing that seems different is that I am using port 8080 but that shouldn't matter . .

It seems to me that if Perl CGIs work and compiled C programs don't, then there must be a configuration thing I am missing - I have seen a few other people with the same problem but the fixes suggested didn't work for me.

Info:

lighttpd-filesystem-1.4.50-1.fc27.noarch
lighttpd-fastcgi-1.4.50-1.fc27.x86_64
lighttpd-1.4.50-1.fc27.x86_64

Added to lighttpd/lighttpd.conf:

$HTTP["url"] =~ "/cgi-bin/" {
cgi.assign = ( "" => "" )
}

cgi.assign = (
".cgi" => ""
)

In modules.conf:

server.modules = (
"mod_access",
"mod_cgi",
"mod_alias",
"mod_accesslog",
"mod_compress",
)

Thanks,
Phil.


Replies (3)

RE: Perl CGIs work but C CGIs don't -> give 404 errors - Added by gstrauss over 5 years ago

If Perl CGI works, but others do not, and your config does not specifically call out Perl, then it is your C.

Is the file executable? Is it readable by the webserver? chmod a+rx

Have you checked SELinux enforcement? getenforce man setenforce (For testing, and then figure out how to add proper attributes to allow SELinux to be enforced)

RE: Perl CGIs work but C CGIs don't -> give 404 errors - Added by philip_rhoades over 5 years ago

gstrauss,

If Perl CGI works, but others do not, and your config does not specifically call out Perl, then it is your C.

Don't think so:

drwxrwxrwx 2 lighttpd lighttpd 4096 Oct 13 02:28 .
drwxr-xr-x 8 nginx nginx 4096 Oct 13 01:19 ..
-rwxrwxr-x 1 lighttpd lighttpd 8224 Oct 13 02:27 hello_world.cgi
-rwxr-xr-x 1 lighttpd lighttpd 382 Oct 11 18:29 hw.cgi
-rwxr-xr-x 1 lighttpd lighttpd 382 Oct 11 18:29 index.cgi
-r-xr-xr-x 1 lighttpd lighttpd 93944 Oct 9 17:48 iwebadmin.cgi

[root@pqmail cgi-bin]# file *
hello_world.cgi: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=257039c818a4acfae667611e6f357be72ab74d29, not stripped
hw.cgi: Perl script text executable
index.cgi: Perl script text executable
iwebadmin.cgi: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=a0170167bbf3c38a7251faf34b6d870ffed4b4b6, stripped
[root@pqmail cgi-bin]#
[root@pqmail cgi-bin]#
[root@pqmail cgi-bin]# ./hello_world.cgi
Content-Type: text/plain

Hello world !

Have you checked SELinux enforcement? getenforce man setenforce (For testing, and then figure out how to add proper attributes to allow SELinux to be enforced)

SELinux is DISABLED.

Thanks anyway . .

Phil.

RE: Perl CGIs work but C CGIs don't -> give 404 errors - Added by gstrauss over 5 years ago

What you are trying to do is trivial and works in simple lighttp configs. I just confirmed for good measure.

This is invalid syntax:

$HTTP["url"] =~ "/cgi-bin/" {
cgi.assign = ( "" => "" )
}

cgi.assign = (
".cgi" => "" 
)

Perhaps you should check the lighttpd error log, and test your config. lighttpd -tt -f /etc/lighttpd/lighttpd.conf

    (1-3/3)