omar-polo / gmid

a Gemini server
https://gmid.omarpolo.com
ISC License
102 stars 7 forks source link

Systematic CGI error when in daemon mode #20

Closed timeopochin closed 8 months ago

timeopochin commented 1 year ago

Hello, this issue may be related to #15

System information

OS: FreeBSD 13.2-RELEASE-p2 GENERIC Version: gmid 1.8.6

/usr/local/etc/gmid.conf

user "_gmid"
chroot "/var/gemini"

server "gmiusr.timeopochin.xyz" {
        root "/gmiusr/public"
        cgi  "/*"

        cert "/usr/local/etc/ssl/gmid/gmiusr.timeopochin.xyz.cert.pem"
        key  "/usr/local/etc/ssl/gmid/gmiusr.timeopochin.xyz.key.pem"
}

Behaviour

Any request to a CGI script leads to 42 CGI error

Expected behaviour

Request to working CGI scripts should not return an error

Observations

Any request to a *.gmi file works as expected. This is only a problem when running gmid with the -c flag:

gmid -d /usr/local/etc/ssl/gmid -x '/*' -H gmiusr.timeopochin.xyz /var/gemini/gmiusr/public

works as expected.

omar-polo commented 1 year ago

This is only a problem when running gmid with the -c flag

This could be a hint that the issue is different from #15 and be similar to #10 instead. When you run gmid in a chroot, the CGI scripts are run in that chroot too and this means that the CGI scripts need to be prepared too.

For example, if the CGI script is written in an interpreted language (sh, python, perl, lua, ...) you need the interpreter (plus all its dependencies) installed inside the chroot. If it's a compiled language (C, rust, go, ...) it needs to be statically linked (or need copy all the dependencies to the chroot as well.)

Can you share more information about the CGI script you're trying to run?

Also, I'm finally almost done with gmid 2.0 which will remove the CGI support. (It'll still be possible to run CGI script but only via fastcgi using a program like slowcgi(8) or fcgiwrap. I'll write some documentation for the migration once I'll release a first alpha of 2.0 in the following weeks.)

omar-polo commented 8 months ago

I'm going to close this. gmid 2.0 is out and direct CGI support has been removed (at least for now.)