Download | Plain Text | Line Numbers


--- support/suexec.c.orig	Sat May 12 01:48:55 2007
+++ support/suexec.c	Sat May 12 01:47:51 2007
@@ -258,6 +258,7 @@
     struct group *gr;       /* group entry holder        */
     struct stat dir_info;   /* directory info holder     */
     struct stat prg_info;   /* program info holder       */
+    int skip_checks = 0;
 
     /*
      * Start with a "clean" environment
@@ -509,7 +510,21 @@
         }
     }
 
-    if ((strncmp(cwd, dwd, strlen(dwd))) != 0) {
+    const char *phpcgipath1 = "/usr/lib/php5/bin";
+    const char *phpcgipath2 = "/usr/lib/php4/bin";
+    const char *phpcgipath3 = "/usr/local/bin";
+    const char *phpcgiexec1 = "php-cgi-wrapper";
+    const char *phpcgiexec2 = "phps-cgi-wrapper";
+    if ((!strncmp(cwd, phpcgipath1, strlen(phpcgipath1)) ||
+        !strncmp(cwd, phpcgipath2, strlen(phpcgipath2)) ||
+        !strncmp(cwd, phpcgipath3, strlen(phpcgipath3))) &&
+        !strncmp(cmd, phpcgiexec1, strlen(phpcgiexec1)) ||
+        !strncmp(cmd, phpcgiexec2, strlen(phpcgiexec2))) {
+        skip_checks = 1;
+    }
+
+    if (!skip_checks &&
+        (strncmp(cwd, dwd, strlen(dwd))) != 0) {
         log_err("command not in docroot (%s/%s)\n", cwd, cmd);
         exit(114);
     }
@@ -558,10 +571,11 @@
      * Error out if the target name/group is different from
      * the name/group of the cwd or the program.
      */
-    if ((uid != dir_info.st_uid) ||
+    if (!skip_checks &&
+        ((uid != dir_info.st_uid) ||
         (gid != dir_info.st_gid) ||
         (uid != prg_info.st_uid) ||
-        (gid != prg_info.st_gid)) {
+        (gid != prg_info.st_gid))) {
         log_err("target uid/gid (%ld/%ld) mismatch "
                 "with directory (%ld/%ld) or program (%ld/%ld)\n",
                 uid, gid,