Blame SOURCES/httpd-2.4.1-selinux.patch

28b219
28b219
Log the SELinux context at startup.
28b219
28b219
Upstream-Status: unlikely to be any interest in this upstream
28b219
28b219
--- httpd-2.4.1/configure.in.selinux
28b219
+++ httpd-2.4.1/configure.in
28b219
@@ -458,6 +458,11 @@ fopen64
28b219
 dnl confirm that a void pointer is large enough to store a long integer
28b219
 APACHE_CHECK_VOID_PTR_LEN
28b219
 
28b219
+AC_CHECK_LIB(selinux, is_selinux_enabled, [
28b219
+   AC_DEFINE(HAVE_SELINUX, 1, [Defined if SELinux is supported])
28b219
+   APR_ADDTO(AP_LIBS, [-lselinux])
28b219
+])
28b219
+
28b219
 AC_CACHE_CHECK([for gettid()], ac_cv_gettid,
28b219
 [AC_TRY_RUN(#define _GNU_SOURCE
28b219
 #include <unistd.h>
28b219
--- httpd-2.4.1/server/core.c.selinux
28b219
+++ httpd-2.4.1/server/core.c
28b219
@@ -58,6 +58,10 @@
28b219
 #include <unistd.h>
28b219
 #endif
28b219
 
28b219
+#ifdef HAVE_SELINUX
28b219
+#include <selinux/selinux.h>
28b219
+#endif
28b219
+
28b219
 /* LimitRequestBody handling */
28b219
 #define AP_LIMIT_REQ_BODY_UNSET         ((apr_off_t) -1)
28b219
 #define AP_DEFAULT_LIMIT_REQ_BODY       ((apr_off_t) 0)
28b219
@@ -4452,6 +4456,28 @@ static int core_post_config(apr_pool_t *
28b219
     }
28b219
 #endif
28b219
 
28b219
+#ifdef HAVE_SELINUX
28b219
+    {
28b219
+        static int already_warned = 0;
28b219
+        int is_enabled = is_selinux_enabled() > 0;
28b219
+        
28b219
+        if (is_enabled && !already_warned) {
28b219
+            security_context_t con;
28b219
+            
28b219
+            if (getcon(&con) == 0) {
28b219
+                
28b219
+                ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, NULL,
28b219
+                             "SELinux policy enabled; "
28b219
+                             "httpd running as context %s", con);
28b219
+                
28b219
+                already_warned = 1;
28b219
+                
28b219
+                freecon(con);
28b219
+            }
28b219
+        }
28b219
+    }
28b219
+#endif
28b219
+
28b219
     return OK;
28b219
 }
28b219