Re: cgi issues
> We have a winner. Thanks for the help. Including compile commands to help > anyone who may come across this thread. > > cc -c -o test.o test.c > cc -o test -static test.o or ... /usr/share/mk/bsd.README LDSTATIC= ${STATIC}
Re: cgi issues
On 07/08/18 08:41, Florian Obser wrote: On Sun, Jul 08, 2018 at 08:30:29AM -0500, Edgar Pettijohn III wrote: On 07/08/18 08:09, Florian Obser wrote: On Sun, Jul 08, 2018 at 07:53:41AM -0500, Edgar Pettijohn III wrote: I am playing around with cgi written in c. I am getting what seems like a weird error though. I'm starting off with a very basic program: #include int main(void) { fprintf(stdout, "\n" "\n" "test\n" "\n" "\n" ); you need to output a header, something like printf("Status: 200 OK\r\nContent-Type: text/html\r\n\r\n"); still the same results next guess, you are not building a static binary. We have a winner. Thanks for the help. Including compile commands to help anyone who may come across this thread. cc -c -o test.o test.c cc -o test -static test.o this might tell you what goes wrong: doas chroot -u www /var/www/ /cgi-bin/test alternatively stop slowcgi and start it in debug mode, that might tell you things you might also want to consider using kcgi (in ports) https://kristaps.bsd.lv/kcgi/ I'll look into it. thanks fprintf(stdout, "it works\n"); fprintf( stdout, "\n" "\n" ); return (0); } I set up bgplg to make sure that httpd and slowcgi are working correctly. Here is the only debug info I could find. doas httpd -dvv startup server_privinit: adding server default socket_rlimit: max open files 1024 socket_rlimit: max open files 1024 socket_rlimit: max open files 1024 server_launch: configuring server default server_launch: running server default server_launch: configuring server default server_launch: configuring server default server_launch: running server default server_launch: running server default default 127.0.0.1 - - [08/Jul/2018:07:45:51 -0500] "GET /cgi-bin/bgplg HTTP/1.1" 200 0 default 127.0.0.1 - - [08/Jul/2018:07:45:55 -0500] "GET /cgi-bin/test HTTP/1.1" 500 0 server default, client 1 (1 active), 127.0.0.1:46773 -> 127.0.0.1, empty stdout (500 Internal Server Error) I'm not sure what `empty stdout' means. Thanks, Edgar
Re: cgi issues
On Sun, Jul 08, 2018 at 08:30:29AM -0500, Edgar Pettijohn III wrote: > > > On 07/08/18 08:09, Florian Obser wrote: > > On Sun, Jul 08, 2018 at 07:53:41AM -0500, Edgar Pettijohn III wrote: > > > I am playing around with cgi written in c. I am getting what seems like a > > > weird error though. I'm starting off with a very basic program: > > > > > > #include > > > > > > int > > > main(void) > > > { > > > fprintf(stdout, > > > "\n" > > > "\n" > > > "test\n" > > > "\n" > > > "\n" > > > ); > > you need to output a header, something like > > printf("Status: 200 OK\r\nContent-Type: text/html\r\n\r\n"); > > still the same results next guess, you are not building a static binary. this might tell you what goes wrong: doas chroot -u www /var/www/ /cgi-bin/test alternatively stop slowcgi and start it in debug mode, that might tell you things > > > > you might also want to consider using kcgi (in ports) > > > > https://kristaps.bsd.lv/kcgi/ > I'll look into it. > > thanks > > > fprintf(stdout, "it works\n"); > > > > > > fprintf( > > > stdout, > > > "\n" > > > "\n" > > > ); > > > > > > return (0); > > > } > > > > > > I set up bgplg to make sure that httpd and slowcgi are working correctly. > > > Here is the only debug info I could find. > > > > > > doas httpd -dvv > > > startup > > > server_privinit: adding server default > > > socket_rlimit: max open files 1024 > > > socket_rlimit: max open files 1024 > > > socket_rlimit: max open files 1024 > > > server_launch: configuring server default > > > server_launch: running server default > > > server_launch: configuring server default > > > server_launch: configuring server default > > > server_launch: running server default > > > server_launch: running server default > > > default 127.0.0.1 - - [08/Jul/2018:07:45:51 -0500] "GET /cgi-bin/bgplg > > > HTTP/1.1" 200 0 > > > default 127.0.0.1 - - [08/Jul/2018:07:45:55 -0500] "GET /cgi-bin/test > > > HTTP/1.1" 500 0 > > > server default, client 1 (1 active), 127.0.0.1:46773 -> 127.0.0.1, empty > > > stdout (500 Internal Server Error) > > > > > > I'm not sure what `empty stdout' means. > > > > > > Thanks, > > > > > > Edgar > > > > -- I'm not entirely sure you are real.
Re: cgi issues
On 07/08/18 08:09, Florian Obser wrote: On Sun, Jul 08, 2018 at 07:53:41AM -0500, Edgar Pettijohn III wrote: I am playing around with cgi written in c. I am getting what seems like a weird error though. I'm starting off with a very basic program: #include int main(void) { fprintf(stdout, "\n" "\n" "test\n" "\n" "\n" ); you need to output a header, something like printf("Status: 200 OK\r\nContent-Type: text/html\r\n\r\n"); still the same results you might also want to consider using kcgi (in ports) https://kristaps.bsd.lv/kcgi/ I'll look into it. thanks fprintf(stdout, "it works\n"); fprintf( stdout, "\n" "\n" ); return (0); } I set up bgplg to make sure that httpd and slowcgi are working correctly. Here is the only debug info I could find. doas httpd -dvv startup server_privinit: adding server default socket_rlimit: max open files 1024 socket_rlimit: max open files 1024 socket_rlimit: max open files 1024 server_launch: configuring server default server_launch: running server default server_launch: configuring server default server_launch: configuring server default server_launch: running server default server_launch: running server default default 127.0.0.1 - - [08/Jul/2018:07:45:51 -0500] "GET /cgi-bin/bgplg HTTP/1.1" 200 0 default 127.0.0.1 - - [08/Jul/2018:07:45:55 -0500] "GET /cgi-bin/test HTTP/1.1" 500 0 server default, client 1 (1 active), 127.0.0.1:46773 -> 127.0.0.1, empty stdout (500 Internal Server Error) I'm not sure what `empty stdout' means. Thanks, Edgar
Re: cgi issues
On Sun, Jul 08, 2018 at 07:53:41AM -0500, Edgar Pettijohn III wrote: > I am playing around with cgi written in c. I am getting what seems like a > weird error though. I'm starting off with a very basic program: > > #include > > int > main(void) > { > fprintf(stdout, > "\n" > "\n" > "test\n" > "\n" > "\n" > ); you need to output a header, something like printf("Status: 200 OK\r\nContent-Type: text/html\r\n\r\n"); you might also want to consider using kcgi (in ports) https://kristaps.bsd.lv/kcgi/ > > fprintf(stdout, "it works\n"); > > fprintf( > stdout, > "\n" > "\n" > ); > > return (0); > } > > I set up bgplg to make sure that httpd and slowcgi are working correctly. > Here is the only debug info I could find. > > doas httpd -dvv > startup > server_privinit: adding server default > socket_rlimit: max open files 1024 > socket_rlimit: max open files 1024 > socket_rlimit: max open files 1024 > server_launch: configuring server default > server_launch: running server default > server_launch: configuring server default > server_launch: configuring server default > server_launch: running server default > server_launch: running server default > default 127.0.0.1 - - [08/Jul/2018:07:45:51 -0500] "GET /cgi-bin/bgplg > HTTP/1.1" 200 0 > default 127.0.0.1 - - [08/Jul/2018:07:45:55 -0500] "GET /cgi-bin/test > HTTP/1.1" 500 0 > server default, client 1 (1 active), 127.0.0.1:46773 -> 127.0.0.1, empty > stdout (500 Internal Server Error) > > I'm not sure what `empty stdout' means. > > Thanks, > > Edgar > -- I'm not entirely sure you are real.