I'm trying to set up a virtualhost that uses CGI scripts that run as a particular user and group. I'm using the SuexecUserGroup directive, but that doesn't seem to work.
Basic setup. User "Bob" has some CGI scripts that work correctly in his cgi-bin directory. So for this URL:
http://myhost.com/~bob/cgi-bin/whoami.cgi
where the whoami.cgi script prints the uid, that URL works correctly and report's Bob's UID.
Bob got a domain name, bobhost.org, which my server is hosting. I set up a virtualhost like this:
<VirtualHost *:80>
ServerName bobhost.org
DocumentRoot /home/bob/public_html
ScriptLog logs/bob_script_log
TransferLog logs/bob_access_log
ErrorLog logs/bob_error_log
LogLevel warn suexec:debug
SuexecUserGroup bob bob
ScriptAlias /cgi-bin/ "/home/bob/public_html/cgi-bin/"
<Directory "/home/bob/public_html/">
Require all granted
Options +ExecCGI
AddHandler cgi-script .cgi
</Directory>
</VirtualHost>
The following url fails:
http://bobhost.org/cgi-bin/whoami.cgi
even though the whoami.cgi script is exactly the same file. The error logfile says:
[timestamp] [cgi:error] [pid] [client] End of script output before headers: whoami.cgi
There's nothing in the ScriptLog (does that directive even work?) or anyplace else that I can see.
I eventually got it to work by (1) removing the SuexecUserGroup line and (2) changing the uid:gid of all the files to apache:apache.
While I'm glad I got it to work, I feel uncomfortable with the solution. Can the SuexecUserGroup directive can be made to work with virtualhosts?