altarch-user / rpms / httpd

Forked from rpms/httpd 2 years ago
Clone

Blame SOURCES/httpd-2.4.4-r1337344+.patch

008793
# ./pullrev.sh 1337344 1341905 1342065 1341930
008793
008793
suexec enhancements:
008793
008793
1) use syslog for logging
008793
2) use capabilities not setuid/setgid root binary
008793
008793
http://svn.apache.org/viewvc?view=revision&revision=1337344
008793
http://svn.apache.org/viewvc?view=revision&revision=1341905
008793
http://svn.apache.org/viewvc?view=revision&revision=1342065
008793
http://svn.apache.org/viewvc?view=revision&revision=1341930
008793
008793
--- httpd-2.4.4/configure.in.r1337344+
008793
+++ httpd-2.4.4/configure.in
008793
@@ -734,7 +734,24 @@ APACHE_HELP_STRING(--with-suexec-gidmin,
008793
 
008793
 AC_ARG_WITH(suexec-logfile,
008793
 APACHE_HELP_STRING(--with-suexec-logfile,Set the logfile),[
008793
-  AC_DEFINE_UNQUOTED(AP_LOG_EXEC, "$withval", [SuExec log file] ) ] )
008793
+  if test "x$withval" = "xyes"; then
008793
+    AC_DEFINE_UNQUOTED(AP_LOG_EXEC, "$withval", [SuExec log file])
008793
+  fi
008793
+])
008793
+
008793
+AC_ARG_WITH(suexec-syslog,
008793
+APACHE_HELP_STRING(--with-suexec-syslog,Set the logfile),[
008793
+  if test $withval = "yes"; then
008793
+    if test "x${with_suexec_logfile}" != "xno"; then
008793
+      AC_MSG_NOTICE([hint: use "--without-suexec-logfile --with-suexec-syslog"])
008793
+      AC_MSG_ERROR([suexec does not support both logging to file and syslog])
008793
+    fi
008793
+    AC_CHECK_FUNCS([vsyslog], [], [
008793
+       AC_MSG_ERROR([cannot support syslog from suexec without vsyslog()])])
008793
+    AC_DEFINE(AP_LOG_SYSLOG, 1, [SuExec log to syslog])
008793
+  fi    
008793
+])
008793
+
008793
 
008793
 AC_ARG_WITH(suexec-safepath,
008793
 APACHE_HELP_STRING(--with-suexec-safepath,Set the safepath),[
008793
@@ -744,6 +761,15 @@ AC_ARG_WITH(suexec-umask,
008793
 APACHE_HELP_STRING(--with-suexec-umask,umask for suexec'd process),[
008793
   AC_DEFINE_UNQUOTED(AP_SUEXEC_UMASK, 0$withval, [umask for suexec'd process] ) ] )
008793
 
008793
+INSTALL_SUEXEC=setuid
008793
+AC_ARG_ENABLE([suexec-capabilities], 
008793
+APACHE_HELP_STRING(--enable-suexec-capabilities,Use Linux capability bits not setuid root suexec), [
008793
+INSTALL_SUEXEC=caps
008793
+AC_DEFINE(AP_SUEXEC_CAPABILITIES, 1, 
008793
+          [Enable if suexec is installed with Linux capabilities, not setuid])
008793
+])
008793
+APACHE_SUBST(INSTALL_SUEXEC)
008793
+
008793
 dnl APR should go after the other libs, so the right symbols can be picked up
008793
 if test x${apu_found} != xobsolete; then
008793
   AP_LIBS="$AP_LIBS `$apu_config --avoid-ldap --link-libtool`"
008793
--- httpd-2.4.4/docs/manual/suexec.html.en.r1337344+
008793
+++ httpd-2.4.4/docs/manual/suexec.html.en
008793
@@ -372,6 +372,21 @@
008793
       together with the --enable-suexec option to let
008793
       APACI accept your request for using the suEXEC feature.
008793
 
008793
+      
--enable-suexec-capabilities
008793
+
008793
+      
Linux specific: Normally,
008793
+      the suexec binary is installed "setuid/setgid
008793
+      root", which allows it to run with the full privileges of the
008793
+      root user.  If this option is used, the suexec
008793
+      binary will instead be installed with only the setuid/setgid
008793
+      "capability" bits set, which is the subset of full root
008793
+      priviliges required for suexec operation.  Note that
008793
+      the suexec binary may not be able to write to a log
008793
+      file in this mode; it is recommended that the
008793
+      --with-suexec-syslog --without-suexec-logfile
008793
+      options are used in conjunction with this mode, so that syslog
008793
+      logging is used instead.
008793
+
008793
       
--with-suexec-bin=PATH
008793
 
008793
       
The path to the suexec binary must be hard-coded
008793
@@ -433,6 +448,12 @@
008793
       "suexec_log" and located in your standard logfile
008793
       directory (--logfiledir).
008793
 
008793
+      
--with-suexec-syslog
008793
+
008793
+      
If defined, suexec will log notices and errors to syslog
008793
+      instead of a logfile.  This option must be combined
008793
+      with --without-suexec-logfile.
008793
+
008793
       
--with-suexec-safepath=PATH
008793
 
008793
       
Define a safe PATH environment to pass to CGI
008793
@@ -550,9 +571,12 @@ Group webgroup
008793
 
008793
     

The suEXEC wrapper will write log information

008793
     to the file defined with the --with-suexec-logfile
008793
-    option as indicated above. If you feel you have configured and
008793
-    installed the wrapper properly, have a look at this log and the
008793
-    error_log for the server to see where you may have gone astray.

008793
+    option as indicated above, or to syslog if --with-suexec-syslog
008793
+    is used. If you feel you have configured and
008793
+    installed the wrapper properly, have a look at the log and the
008793
+    error_log for the server to see where you may have gone astray. 
008793
+    The output of "suexec -V" will show the options
008793
+    used to compile suexec, if using a binary distribution.

008793
 
008793
 
top
008793
 
008793
@@ -640,4 +664,4 @@ if (typeof(prettyPrint) !== 'undefined')
008793
     prettyPrint();
008793
 }
008793
 //--></script>
008793
-</body></html>
008793
\ No newline at end of file
008793
+</body></html>
008793
--- httpd-2.4.4/Makefile.in.r1337344+
008793
+++ httpd-2.4.4/Makefile.in
008793
@@ -238,11 +238,22 @@ install-man:
008793
 	  cd $(DESTDIR)$(manualdir) && find . -name ".svn" -type d -print | xargs rm -rf 2>/dev/null || true; \
008793
 	fi
008793
 
008793
-install-suexec:
008793
+install-suexec: install-suexec-binary install-suexec-$(INSTALL_SUEXEC)
008793
+
008793
+install-suexec-binary:
008793
 	@if test -f $(builddir)/support/suexec; then \
008793
             test -d $(DESTDIR)$(sbindir) || $(MKINSTALLDIRS) $(DESTDIR)$(sbindir); \
008793
             $(INSTALL_PROGRAM) $(top_builddir)/support/suexec $(DESTDIR)$(sbindir); \
008793
-            chmod 4755 $(DESTDIR)$(sbindir)/suexec; \
008793
+	fi
008793
+
008793
+install-suexec-setuid:
008793
+	@if test -f $(builddir)/support/suexec; then \
008793
+	    chmod 4755 $(DESTDIR)$(sbindir)/suexec; \
008793
+	fi
008793
+
008793
+install-suexec-caps:
008793
+	@if test -f $(builddir)/support/suexec; then \
008793
+            setcap 'cap_setuid,cap_setgid+pe' $(DESTDIR)$(sbindir)/suexec; \
008793
 	fi
008793
 
008793
 suexec:
008793
--- httpd-2.4.4/modules/arch/unix/mod_unixd.c.r1337344+
008793
+++ httpd-2.4.4/modules/arch/unix/mod_unixd.c
008793
@@ -284,6 +284,13 @@ unixd_set_suexec(cmd_parms *cmd, void *d
008793
     return NULL;
008793
 }
008793
 
008793
+#ifdef AP_SUEXEC_CAPABILITIES
008793
+/* If suexec is using capabilities, don't test for the setuid bit. */
008793
+#define SETUID_TEST(finfo) (1)
008793
+#else
008793
+#define SETUID_TEST(finfo) (finfo.protection & APR_USETID)
008793
+#endif
008793
+
008793
 static int
008793
 unixd_pre_config(apr_pool_t *pconf, apr_pool_t *plog,
008793
                  apr_pool_t *ptemp)
008793
@@ -300,7 +307,7 @@ unixd_pre_config(apr_pool_t *pconf, apr_
008793
     ap_unixd_config.suexec_enabled = 0;
008793
     if ((apr_stat(&wrapper, SUEXEC_BIN, APR_FINFO_NORM, ptemp))
008793
          == APR_SUCCESS) {
008793
-        if ((wrapper.protection & APR_USETID) && wrapper.user == 0
008793
+        if (SETUID_TEST(wrapper) && wrapper.user == 0
008793
             && (access(SUEXEC_BIN, R_OK|X_OK) == 0)) {
008793
             ap_unixd_config.suexec_enabled = 1;
008793
             ap_unixd_config.suexec_disabled_reason = "";
008793
--- httpd-2.4.4/support/suexec.c.r1337344+
008793
+++ httpd-2.4.4/support/suexec.c
008793
@@ -58,6 +58,10 @@
008793
 #include <grp.h>
008793
 #endif
008793
 
008793
+#ifdef AP_LOG_SYSLOG
008793
+#include <syslog.h>
008793
+#endif
008793
+
008793
 #if defined(PATH_MAX)
008793
 #define AP_MAXPATH PATH_MAX
008793
 #elif defined(MAXPATHLEN)
008793
@@ -69,7 +73,20 @@
008793
 #define AP_ENVBUF 256
008793
 
008793
 extern char **environ;
008793
+
008793
+#ifdef AP_LOG_SYSLOG
008793
+/* Syslog support. */
008793
+#if !defined(AP_LOG_FACILITY) && defined(LOG_AUTHPRIV)
008793
+#define AP_LOG_FACILITY LOG_AUTHPRIV
008793
+#elif !defined(AP_LOG_FACILITY)
008793
+#define AP_LOG_FACILITY LOG_AUTH
008793
+#endif
008793
+
008793
+static int log_open;
008793
+#else
008793
+/* Non-syslog support. */
008793
 static FILE *log = NULL;
008793
+#endif
008793
 
008793
 static const char *const safe_env_lst[] =
008793
 {
008793
@@ -137,7 +154,14 @@ static void err_output(int is_error, con
008793
 
008793
 static void err_output(int is_error, const char *fmt, va_list ap)
008793
 {
008793
-#ifdef AP_LOG_EXEC
008793
+#if defined(AP_LOG_SYSLOG)
008793
+    if (!log_open) {
008793
+        openlog("suexec", LOG_PID, AP_LOG_FACILITY);
008793
+        log_open = 1;
008793
+    }
008793
+
008793
+    vsyslog(is_error ? LOG_ERR : LOG_INFO, fmt, ap);
008793
+#elif defined(AP_LOG_EXEC)
008793
     time_t timevar;
008793
     struct tm *lt;
008793
 
008793
@@ -295,7 +319,9 @@ int main(int argc, char *argv[])
008793
 #ifdef AP_HTTPD_USER
008793
         fprintf(stderr, " -D AP_HTTPD_USER=\"%s\"\n", AP_HTTPD_USER);
008793
 #endif
008793
-#ifdef AP_LOG_EXEC
008793
+#if defined(AP_LOG_SYSLOG)
008793
+        fprintf(stderr, " -D AP_LOG_SYSLOG\n");
008793
+#elif defined(AP_LOG_EXEC)
008793
         fprintf(stderr, " -D AP_LOG_EXEC=\"%s\"\n", AP_LOG_EXEC);
008793
 #endif
008793
 #ifdef AP_SAFE_PATH
008793
@@ -591,6 +617,12 @@ int main(int argc, char *argv[])
008793
 #endif /* AP_SUEXEC_UMASK */
008793
 
008793
     /* Be sure to close the log file so the CGI can't mess with it. */
008793
+#ifdef AP_LOG_SYSLOG
008793
+    if (log_open) {
008793
+        closelog();
008793
+        log_open = 0;
008793
+    }
008793
+#else
008793
     if (log != NULL) {
008793
 #if APR_HAVE_FCNTL_H
008793
         /*
008793
@@ -612,6 +644,7 @@ int main(int argc, char *argv[])
008793
         log = NULL;
008793
 #endif
008793
     }
008793
+#endif
008793
 
008793
     /*
008793
      * Execute the command, replacing our image with its own.