Paul,

thank you so much for taking the time to write such detailed answer.


> script needs to be able to create a file in its
> /run directory

Thanks to your hints I might have been able to narrow it down a bit, but
I'm still not there.

The "fastcgi" directive from httpd.conf defaults to /run/slowcgi.sock
(http://www.openbsd.org/papers/httpd-asiabsdcon2015.pdf).

So I removed the socket file which might be there from previous starts
of slowcgi:
# rm /var/run/slowcgi.sock

I tried this to tell perl about which socket to use:

# cat cgi-bin/fcgi.fcgi

##########################################################
#!/usr/bin/perl
use FCGI;

my $socket = FCGI::OpenSocket( "/run/slowcgi.sock", 5 );
my $request = FCGI::Request( \*STDIN, \*STDOUT, \*STDERR, \%ENV, $socket );

my $count;
while( $request->Accept() >= 0 ) {
    print "Content-type: text/html\r\n\r\n";
    print ++$count;
}

FCGI::CloseSocket( $socket );
##########################################################

# rcctl start httpd
httpd(ok)

I still get 500 Internal Server Error

but:
# ls -ld /var/www/run/slowcgi.sock
ls: /var/www/run/slowcgi.sock: No such file or directory

So the socket file is not being created when the script was started from
httpd.

Now I try to start the very same script without any change, but instead
letting httpd start the script, I will start it manually, using the
(presumably) same credentials:

# chroot -g www -u www /var/www /cgi-bin/fcgi.fcgi

The script does not return, which is probably because of the while loop
waiting for a new connection. However, in a second shell I can see that
this time the socket was created:

# ls -ld /var/www/run/slowcgi.sock
srwxr-xr-x  1 www  www  0 May 24 13:46 /var/www/run/slowcgi.sock

Can anyone explain this to me? How is httpd starting the script in a
different way than I do with that chroot command?

Help will be appreciated!

Regards,
T.

Reply via email to