diff -Nru apache_1.3.12/src/main/util_script.c apache_1.3.12-knf/src/main/util_script.c
--- apache_1.3.12/src/main/util_script.c	Thu Dec  9 18:19:45 1999
+++ apache_1.3.12-knf/src/main/util_script.c	Sun Oct  8 23:30:25 2000
@@ -67,6 +67,8 @@
 #include "util_script.h"
 #include "util_date.h"		/* For parseHTTPdate() */
 
+#include <sys/stat.h>
+ 
 #ifdef OS2
 #define INCL_DOS
 #include <os2.h>
@@ -711,6 +713,7 @@
 			     char **env, int shellcmd)
 {
     int pid = 0;
+    struct stat sbuf;
 #if defined(RLIMIT_CPU)  || defined(RLIMIT_NPROC) || \
     defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined (RLIMIT_AS)
 
@@ -1066,10 +1069,19 @@
     }
 #elif defined(NETWARE)
 #else
+	
+    if (stat(argv0, &sbuf)) {
+	    ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
+			    "extended suEXEC: stat failed!");
+	    return (pid);
+    }
+
     if (ap_suexec_enabled
 	&& ((r->server->server_uid != ap_user_id)
 	    || (r->server->server_gid != ap_group_id)
-	    || (!strncmp("/~", r->uri, 2)))) {
+	    || (!strncmp("/~", r->uri, 2))
+	    || (sbuf.st_uid != ap_user_id)
+	    || (sbuf.st_gid != ap_group_id))) {
 
 	char *execuser, *grpname;
 	struct passwd *pw;
@@ -1103,6 +1115,15 @@
 	    else {
 		grpname = gr->gr_name;
 	    }
+	}
+	else if ((sbuf.st_uid != ap_user_id)||(sbuf.st_gid != ap_group_id)) {
+		
+		pw = getpwuid(sbuf.st_uid);
+		execuser = ap_pstrdup(r->pool, pw->pw_name);
+
+		gr = getgrgid(sbuf.st_gid);
+		grpname = gr->gr_name;
+
 	}
 	else {
 	    if ((pw = getpwuid(r->server->server_uid)) == NULL) {
diff -Nru apache_1.3.12/src/support/suexec.c apache_1.3.12-knf/src/support/suexec.c
--- apache_1.3.12/src/support/suexec.c	Tue Jan 11 20:47:59 2000
+++ apache_1.3.12-knf/src/support/suexec.c	Mon Oct  9 00:05:13 2000
@@ -469,11 +469,12 @@
 	    exit(113);
 	}
     }
-
+#if 0
     if ((strncmp(cwd, dwd, strlen(dwd))) != 0) {
 	log_err("error: command not in docroot (%s/%s)\n", cwd, cmd);
 	exit(114);
     }
+#endif
 
     /*
      * Stat the cwd and verify it is a directory, or error out.
@@ -483,6 +484,7 @@
 	exit(115);
     }
 
+#if 0
     /*
      * Error out if cwd is writable by others.
      */
@@ -491,6 +493,7 @@
 	exit(116);
     }
 
+#endif
     /*
      * Error out if we cannot stat the program.
      */
