Date: | Mon, Jan 13 2000 |
Author of the patch: | Piotr Klaban <poczta@klaban.torun.pl> |
Patch status: | Not included in the official cgiwrap distribution |
Last modified: | Tue, Mar 12 2002 |
The problem is: how to allow users to run php scripts/phtml pages with their own userids. I do not want to force users chmod scripts to 755, and add #!.../php line in the beggining. This patch allow use cgiwrap with apache, and php that has to be compiled as a normal program that could be used with cgis. If you want your users run PHP with user priviledges then you need to install patched cgiwrap, or run each php page as a cgi script with #!/path/php at the top. I think it would be possible to use both - apache php module for RootDirectory, and cgiwrap-php for user directories. But do not think you would be safe now. Notice, that you should disable FileInfo option in Apache configuration file httpd.conf with directive: 'AllowOverride -FileInfo' (or just do not enable it with 'AllowOverride All'. Otherwise users could override your php-cgiwrap redirection with 'AddType application/x-httpd-php .moo in .htaccess file (thanks to Daniel Lorch for pointing this out). Patch changes includes: - scipts do not need to have execute bit set (all of the other cgiwrap checks (uid,gid etc.) are performed) (utils.c) - configure.in - new option --with-php=/path/to/your/php - cgiwrap.c - check if the filename has 'php-' string (PHP_Enable is then set to 1) -> then php is execv'ed instead of the cgi script. - config.h.in - new macro - PATH_PROG_PHP - util.c - new variable PHP_Enable, chmod 755 *.php not necessary - fetch.c - PATH_INFO is not "fixed" when running php scripts (p5), now (p6) the username is stripped from the PATH_INFOCHANGES
- execv(scriptPath, CreateARGV(scrStr, argc,argv)); +#ifdef PATH_PROG_PHP + if (PHP_Enable) + execv(phpPath, CreateARGV(scriptPath, argc,argv)); + else + +#endif + execv(scriptPath, CreateARGV(scrStr, argc,argv)); - +#endif (Thanks to Steve Hsieh <steveh@eecs.umich.edu>).
cgiwrap-3.7.1-p7-withphp.diff.gz
cd cgiwrap-version # or cd cgiwrap gzip -dc cgiwrap-3.7-p7-withphp.diff.gz | gpatch -p1 # (you have to use GNU patch for this) autoconf # to produce new configure file - do not skip this configure --with-php=/usr/local/bin/php ... gmake # etc.
I use the following command to configure my site:
./configure --with-check-shell --with-rlimit-core=0 --with-rlimit-cpu=30 \ --without-redirect-stderr --without-logging-file --with-perl=/usr/bin/perl \ --with-httpd-user=www --with-cgi-dir=WWW \ --with-install-dir=/usr/local/apache/WWW/cgi-bin --with-wall \ --with-local-contact-email=root@man.torun.pl \ --with-php=/usr/bin/phpYou need to change httpd-user value, paths etc. You have to use --with-php=/path/to/php, though.
AddHandler php-cgiwrap .php Action php-cgiwrap /cgi-bin/php-cgiwrap
# for normal 'system cgi' scripts do not use cgiwrap: <Location /cgi-bin> AddHandler cgi-script .cgi </Location> # for other use it as needed: AddHandler cgi-wrapper .cgi Action cgi-wrapper /cgi-bin/cgiwrap # that is specially for php developers: AddHandler php-cgiwrap .php AddHandler php-cgiwrap .php3 AddHandler php-cgiwrap .phtml Action php-cgiwrap /cgi-bin/php-cgiwrap Action php-cgiwrapd /cgi-bin/php-cgiwrapd # in other place add index.php etc. DirectoryIndex index.html index.htm index.shtml index.cgi index.php index.phtml index.wml
See also my post to cgiwrap mailing list.
Look for CVS version of cgiwrap at: http://sourceforge.net/cvs/?group_id=8209
See the mod_phpcgiwrap page at http://steven.haryan.to/mod_cgiwrap/mod_cgiwrap.html