Re: Cgi shell script in httpd

2018-01-02 Thread Stuart Henderson
On 2018-01-01, Jordon  wrote:
> Over the last few days I have been learning the BCHS approach at web design.  
> I am not a web designer (i had to learn CSS as part of this!) but have 
> enjoyed this little adventure.  My goal was to make an web interface to view 
> data that i provide in a c++ library and so far i have been pretty successful.
> In doing some cleaning up and reorganizing, i have renamed the cgi program.  
> I thought it would be nice to create a shell script with the old name that 
> would spit out a simple page saying the name changed and providing a link to 
> the new cgi app.  I made the shell script but for the life of me cannot get 
> it to work.  Is this allowed/supported in httpd?  If so, any idea what I 
> could be missing?

I think you might want something along the lines of "location /old/path.cgi
{ block return 301 https://hostname/new/path.cgi?$QUERY_STRING }" in httpd.conf.

If you're interested in why the shell script doesn't work, start by running
it manually inside the chroot jail and see what it says, e.g.

# chroot /var/www /var/www/cgi-bin/script.cgi




Re: Cgi shell script in httpd

2018-01-01 Thread Jordon
> 
> You are providing no information whatsoever, so let me try a shot in
> the utter dark and hope i don't hit any of the cats on your couch:

I am very new to this field so sorry for the vagueness!

> 
> Maybe you are running httpd(8) chroot(2)ed but don't have any sh(1)
> binary in the chroot?  That's a common error.

I did read about this and put sh into /var/www/bin but it still didn’t work.

> 
> By the way, putting a shell binary in a chroot (or any other
> interpreter for that matter, like PHP) is an ugly thing to do, so
> a good alternative might be to write the redirect CGI program in C
> as well (which you already managed to do for something more
> complicated), or even simpler, make it a static HTML page and tell
> httpd.conf(5) with location { no fastcgi } and types { } to simply
> serve it as text/html, even if the name ends in *.cgi or something
> like that.

This is the real answer.  If scripts a cgi programs is bad practice, I won’t do 
it.  Again, I am very new to this area of programming and I am as interested in 
the “should I” as much as the “can I”.

Thanks!

Jordon


Re: Cgi shell script in httpd

2017-12-31 Thread Ingo Schwarze
Hi Jordon,

Jordon wrote on Sun, Dec 31, 2017 at 09:29:05PM -0600:

> I thought it would be nice to create a shell script with the old name
> that would spit out a simple page saying the name changed and providing
> a link to the new cgi app.  I made the shell script but for the life of
> me cannot get it to work.  Is this allowed/supported in httpd?
> If so, any idea what I could be missing?

You are providing no information whatsoever, so let me try a shot in
the utter dark and hope i don't hit any of the cats on your couch:

Maybe you are running httpd(8) chroot(2)ed but don't have any sh(1)
binary in the chroot?  That's a common error.

By the way, putting a shell binary in a chroot (or any other
interpreter for that matter, like PHP) is an ugly thing to do, so
a good alternative might be to write the redirect CGI program in C
as well (which you already managed to do for something more
complicated), or even simpler, make it a static HTML page and tell
httpd.conf(5) with location { no fastcgi } and types { } to simply
serve it as text/html, even if the name ends in *.cgi or something
like that.

Yours,
  Ingo