Simple static testcgi.c

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Simple static testcgi.c

James Turner-5
So I wanted to test out nginx and slowcgi. I started everything up and
hit up localhost/cgi-bin/test-cgi. Whoops forgot to move /bin/sh into
the chroot. Try again, shit forgot to chmod 555 test-cgi.

I was complaining on IRC and tbert suggested I write a simple statically
linked testcgi.c so people can easily verify cgi is up and working.

That is what is attached. It just prints out the environment like
test-cgi and printenv but is statically linked and doesn't require
anything to be copied into the chroot. Also it's 555 by default so it
just works. Is this so bad?

The BINDIR is set since I have no idea where in /usr/src this should
live or if this is even anything we want in source but here it is for
those who don't want to mess around with moving things into the www
chroot and just want to verify cgi (slowcgi in my case) is working.

Tested with both nginx + slowcgi and httpd.

--
James Turner

testcgi.diff (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Simple static testcgi.c

James Turner-5
Simplified.

On Sat, Mar 01, 2014 at 02:27:44PM -0500, James Turner wrote:

> So I wanted to test out nginx and slowcgi. I started everything up and
> hit up localhost/cgi-bin/test-cgi. Whoops forgot to move /bin/sh into
> the chroot. Try again, shit forgot to chmod 555 test-cgi.
>
> I was complaining on IRC and tbert suggested I write a simple statically
> linked testcgi.c so people can easily verify cgi is up and working.
>
> That is what is attached. It just prints out the environment like
> test-cgi and printenv but is statically linked and doesn't require
> anything to be copied into the chroot. Also it's 555 by default so it
> just works. Is this so bad?
>
> The BINDIR is set since I have no idea where in /usr/src this should
> live or if this is even anything we want in source but here it is for
> those who don't want to mess around with moving things into the www
> chroot and just want to verify cgi (slowcgi in my case) is working.
>
> Tested with both nginx + slowcgi and httpd.
>
--
James Turner

testcgi.diff (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Simple static testcgi.c

Florian Obser-2
In reply to this post by James Turner-5
On Sat, Mar 01, 2014 at 02:27:44PM -0500, James Turner wrote:
> So I wanted to test out nginx and slowcgi. I started everything up and
> hit up localhost/cgi-bin/test-cgi. Whoops forgot to move /bin/sh into
> the chroot. Try again, shit forgot to chmod 555 test-cgi.

heh, been there, done that :)

>
> I was complaining on IRC and tbert suggested I write a simple statically
> linked testcgi.c so people can easily verify cgi is up and working.
>
> That is what is attached. It just prints out the environment like
> test-cgi and printenv but is statically linked and doesn't require
> anything to be copied into the chroot. Also it's 555 by default so it
> just works. Is this so bad?

yes, it's bad.

>
> The BINDIR is set since I have no idea where in /usr/src this should
> live or if this is even anything we want in source but here it is for
> those who don't want to mess around with moving things into the www
> chroot and just want to verify cgi (slowcgi in my case) is working.
>

I would put it somewhere in a directory under usr.sbin/nginx/
and add a SUBDIR to Makefile.bsd-wrapper.

So with httpd gone test-cgi is gone, too. I was thinking, cool, let's
get this static C cgi program in. However, turns out we already have
one in base, it's called bgplg. So to test if slowcgi is working chmod
555 /var/www/cgi-bin/bgplg and point your browser to
http://localhost/cgi-bin/bgplg. It works perfectly fine for this
scenario without a bgpd running. Make sure to chmod 000 it afterwards.

--
I'm not entirely sure you are real.