omar-polo / gmid

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

gmid sometimes throws CGI error #15

Closed tbzx89 closed 5 months ago

tbzx89 commented 2 years ago

gmid sometimes throws CGI error

stderr logs:

x.x.x.x:56284 GET gemini://hyperstorm.hu/linkek.gmi 20 text/gemini x.x.x.x:56286 GET gemini://hyperstorm.hu/index.gmi 20 text/gemini; charset=utf-8 x.x.x.x:56288 GET gemini://hyperstorm.hu/linkek.gmi 20 text/gemini x.x.x.x:56290 GET gemini://hyperstorm.hu/index.gmi 20 text/gemini; charset=utf-8 x.x.x.x:56292 GET gemini://hyperstorm.hu/gemini-halozat.gmi 20 text/gemini x.x.x.x:56294 GET gemini://hyperstorm.hu/gemini-halozat.gmi 20 text/gemini x.x.x.x:56296 GET gemini://hyperstorm.hu/linkek.gmi 20 text/gemini y.y.y.y:35335 GET gemini://hyperstorm.hu/index.gmi 42 CGI error y.y.y.y:35598 GET gemini://hyperstorm.hu/index.gmi 42 CGI error y.y.y.y:34932 GET gemini://hyperstorm.hu/index.gmi 42 CGI error x.x.x.x:56298 GET gemini://hyperstorm.hu/index.gmi 42 CGI error x.x.x.x:56300 GET gemini://hyperstorm.hu/index.gmi 42 CGI error x.x.x.x:56304 GET gemini://hyperstorm.hu/index.gmi 42 CGI error root@Hyperstorm:~# gmid.linux.amd64 -f -vv -c /etc/gmid.conf --> here I restarted the server x.x.x.x:56306 GET gemini://hyperstorm.hu/index.gmi 20 text/gemini; charset=utf-8 x.x.x.x:56308 GET gemini://hyperstorm.hu/index.gmi 20 text/gemini; charset=utf-8 x.x.x.x:56310 GET gemini://hyperstorm.hu/index.gmi 20 text/gemini; charset=utf-8 x.x.x.x:56312 GET gemini://hyperstorm.hu/index.gmi 20 text/gemini; charset=utf-8

System: Linux Hyperstorm 4.19.0-6-amd64 #1 SMP Debian 4.19.67-2+deb10u2 (2019-11-11) x86_64 GNU/Linux Distributor ID: Debian Description: Debian GNU/Linux 10 (buster) Release: 10 Codename: buster

omar-polo commented 2 years ago

Hello @urandom0 and thanks for the bug report!

(probably a dumb question but I have to ask it) are you sure the reply "42 CGI Error" is not returned by the CGI script? Also, are you sure you're running the latest version? gmid --version should say 1.8.3.

Why did you restart the server at some point? It always replies "42 CGI Error" until you restart it?

There is something special about the cgi script?

Can you reproduce this issue locally? Maybe by running gg in a loop with something like this:

$ while gg -d header gemini://localhost | grep '^20' >/dev/null; do :; done
tbzx89 commented 2 years ago

are you sure the reply "42 CGI Error" is not returned by the CGI script?

I think not returned by CGI script, because the script works perfectly with another gemini server (gemserv, molly-brown) and sometimes works with gmid, but sometimes simply return CGI error.

Also, are you sure you're running the latest version? gmid --version should say 1.8.3.

Yes.

Why did you restart the server at some point? It always replies "42 CGI Error" until you restart it?

Yes, always.

There is something special about the cgi script?

No, this is a little bash script (guestbook).

Can you reproduce this issue locally? Maybe by running gg in a loop with something like this:

$ while gg -d header gemini://localhost | grep '^20' >/dev/null; do :; done

The command:

while gg.linux.amd64 -d header gemini://hyperstorm.hu | grep '^20' >/dev/null; do :; done

I replaced localhost with hyperstorm.hu because no cert for localhost ("gg.linux.amd64: handshake: name `localhost' not present in server certificate").

The gmid result:

root@Hyperstorm:~# gmid.linux.amd64 -f -vv -c /etc/gmid.conf
x.x.x.x:35412 GET gemini://hyperstorm.hu/index.gmi 20 text/gemini; charset=utf-8 x.x.x.x:35414 GET gemini://hyperstorm.hu/index.gmi 20 text/gemini; charset=utf-8 x.x.x.x:35416 GET gemini://hyperstorm.hu/index.gmi 20 text/gemini; charset=utf-8 x.x.x.x:35418 GET gemini://hyperstorm.hu/index.gmi 20 text/gemini; charset=utf-8 x.x.x.x:35420 GET gemini://hyperstorm.hu/index.gmi 20 text/gemini; charset=utf-8 x.x.x.x:35422 GET gemini://hyperstorm.hu/index.gmi 20 text/gemini; charset=utf-8 x.x.x.x:35424 GET gemini://hyperstorm.hu/index.gmi 20 text/gemini; charset=utf-8 x.x.x.x:35426 GET gemini://hyperstorm.hu/index.gmi 20 text/gemini; charset=utf-8 x.x.x.x:35428 GET gemini://hyperstorm.hu/index.gmi 20 text/gemini; charset=utf-8 x.x.x.x:35430 GET gemini://hyperstorm.hu/index.gmi 20 text/gemini; charset=utf-8 x.x.x.x:35432 GET gemini://hyperstorm.hu/index.gmi 20 text/gemini; charset=utf-8 x.x.x.x:35434 GET gemini://hyperstorm.hu/index.gmi 20 text/gemini; charset=utf-8 x.x.x.x:35436 GET gemini://hyperstorm.hu/index.gmi 20 text/gemini; charset=utf-8 x.x.x.x:35438 GET gemini://hyperstorm.hu/index.gmi 20 text/gemini; charset=utf-8 x.x.x.x:35440 GET gemini://hyperstorm.hu/index.gmi 20 text/gemini; charset=utf-8 x.x.x.x:35442 GET gemini://hyperstorm.hu/index.gmi 20 text/gemini; charset=utf-8 x.x.x.x:35444 GET gemini://hyperstorm.hu/index.gmi 20 text/gemini; charset=utf-8 x.x.x.x:35446 GET gemini://hyperstorm.hu/index.gmi 20 text/gemini; charset=utf-8 x.x.x.x:35448 GET gemini://hyperstorm.hu/index.gmi 20 text/gemini; charset=utf-8 x.x.x.x:35450 GET gemini://hyperstorm.hu/index.gmi 20 text/gemini; charset=utf-8 x.x.x.x:35452 GET gemini://hyperstorm.hu/index.gmi 20 text/gemini; charset=utf-8 x.x.x.x:35454 GET gemini://hyperstorm.hu/index.gmi 20 text/gemini; charset=utf-8 x.x.x.x:35456 GET gemini://hyperstorm.hu/index.gmi 20 text/gemini; charset=utf-8 x.x.x.x:35458 GET gemini://hyperstorm.hu/index.gmi 20 text/gemini; charset=utf-8 x.x.x.x:35460 GET gemini://hyperstorm.hu/index.gmi 20 text/gemini; charset=utf-8 x.x.x.x:35462 GET gemini://hyperstorm.hu/index.gmi 42 CGI error

omar-polo commented 2 years ago

so it's indeed a gmid issue, thanks for confirming. I'll spin up a debian virtual machine later today to do some testing.

omar-polo commented 2 years ago

Sorry for the delay,

I'm still not sure why it's happening, but libevent reports an EOF reading the CGI output, that's why then gmid reports "CGI Error".

It's really interesting because I can't seem to reproduce this issue on OpenBSD nor on FreeBSD, but it's really easy to trigger on devuan.

P.S.:

I replaced localhost with hyperstorm.hu because no cert for localhost ("gg.linux.amd64: handshake: name `localhost' not present in server certificate").

for that you can use the -N flag, it disables server name verification.

omar-polo commented 5 months ago

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