I would like to propose the patch below for suexec in 1.3.20.
If accepted, I will work up a corresponding one for 2.0.

The effect of the patch is to allow 'suexec -V' to print a list
of its compile-time settings, similar to 'httpd -V'.  I have
been having to help people debug suexec issues recently, and
having to figure these out from strings(1) or config.status
is a pain.

The problem is exacerbated by the fact that suexec built by
a make in src/../ is DIFFERENT from one built by a make in
src/support/.  The former includes the settings from ./configure,
since they are passed along on the src/support/ make command.
But since those setting are not in the src/support/Makefile,
a make in that directory will create a suexec with the default
values.

suexec is ordinarily installed mode 4711, which means that
strings(1) cannot be run against it by J Random User.  This
change should not cause any additional exposure, since the -V
option is only honoured if the current user is either root or
the HTTPD_USER.

Index: suexec.c
===================================================================
RCS file: /home/cvs/apache-1.3/src/support/suexec.c,v
retrieving revision 1.55
diff -u -r1.55 suexec.c
--- suexec.c    2001/01/15 17:06:40     1.55
+++ suexec.c    2001/03/06 19:04:58
@@ -268,11 +268,60 @@
     struct stat dir_info;      /* directory info holder     */
     struct stat prg_info;      /* program info holder       */
 
+    prog = argv[0];
+    /*
+     * Check existence/validity of the UID of the user
+     * running this program.  Error out if invalid.
+     */
+    uid = getuid();
+    if ((pw = getpwuid(uid)) == NULL) {
+       log_err("crit: invalid uid: (%ld)\n", uid);
+       exit(102);
+    }
     /*
+     * See if this is a 'how were you compiled' request, and
+     * comply if so.
+     */
+    if ((argc > 1)
+        && (! strcmp(argv[1], "-V"))
+        && ((uid == 0)
+#ifdef _OSD_POSIX
+        /* User name comparisons are case insensitive on BS2000/OSD */
+            || (! strcasecmp(HTTPD_USER, pw->pw_name)))
+#else  /* _OSD_POSIX */
+            || (! strcmp(HTTPD_USER, pw->pw_name)))
+#endif /* _OSD_POSIX */
+        ) {
+#ifdef DOC_ROOT
+        fprintf(stderr, " -D DOC_ROOT=\"%s\"\n", DOC_ROOT);
+#endif
+#ifdef GID_MIN
+        fprintf(stderr, " -D GID_MID=%d\n", GID_MIN);
+#endif
+#ifdef HTTPD_USER
+        fprintf(stderr, " -D HTTPD_USER=\"%s\"\n", HTTPD_USER);
+#endif
+#ifdef LOG_EXEC
+        fprintf(stderr, " -D LOG_EXEC=\"%s\"\n", LOG_EXEC);
+#endif
+#ifdef SAFE_PATH
+        fprintf(stderr, " -D SAFE_PATH=\"%s\"\n", SAFE_PATH);
+#endif
+#ifdef SUEXEC_UMASK
+        fprintf(stderr, " -D SUEXEC_UMASK=%03o\n", SUEXEC_UMASK);
+#endif
+#ifdef UID_MIN
+        fprintf(stderr, " -D UID_MID=%d\n", UID_MIN);
+#endif
+#ifdef USERDIR_SUFFIX
+        fprintf(stderr, " -D USERDIR_SUFFIX=\"%s\"\n", USERDIR_SUFFIX);
+#endif
+        exit(0);
+    }
+    /*
      * If there are a proper number of arguments, set
      * all of them to variables.  Otherwise, error out.
      */
-    prog = argv[0];
     if (argc < 4) {
        log_err("alert: too few arguments\n");
        exit(101);
@@ -280,16 +329,6 @@
     target_uname = argv[1];
     target_gname = argv[2];
     cmd = argv[3];
-
-    /*
-     * Check existence/validity of the UID of the user
-     * running this program.  Error out if invalid.
-     */
-    uid = getuid();
-    if ((pw = getpwuid(uid)) == NULL) {
-       log_err("crit: invalid uid: (%ld)\n", uid);
-       exit(102);
-    }
 
     /*
      * Check to see if the user running this program

-- 
#ken    P-)}

Ken Coar                    <http://Golux.Com/coar/>
Apache Software Foundation  <http://www.apache.org/>
"Apache Server for Dummies" <http://Apache-Server.Com/>
"Apache Server Unleashed"   <http://ApacheUnleashed.Com/>

ApacheCon 2001!
Four tracks with over 70+ sessions. Free admission to exhibits
and special events - keynote presentations by John 'maddog' Hall
and David Brin. Special thanks to our Platinum Sponsors IBM and
Covalent, Gold Sponsor Thawte, and Silver Sponsor Compaq.  Attend
the only Apache event designed and fully supported by the members of
the ASF. See more information and register at <http://ApacheCon.Com/>!

Reply via email to