9d36ace
96e0b33
If SELinux is enabled, log the context on startup.
9d36ace
96e0b33
--- httpd-2.1.10/server/core.c.selinux
96e0b33
+++ httpd-2.1.10/server/core.c
96e0b33
@@ -51,6 +51,8 @@
96e0b33
 
96e0b33
 #include "mod_so.h" /* for ap_find_loaded_module_symbol */
9d36ace
 
9d36ace
+#include <selinux/selinux.h>
9d36ace
+
9d36ace
 /* LimitRequestBody handling */
9d36ace
 #define AP_LIMIT_REQ_BODY_UNSET         ((apr_off_t) -1)
9d36ace
 #define AP_DEFAULT_LIMIT_REQ_BODY       ((apr_off_t) 0)
96e0b33
@@ -3745,6 +3747,26 @@
9d36ace
     }
9d36ace
 #endif
9d36ace
 
9d36ace
+    {
9d36ace
+        static int already_warned = 0;
9d36ace
+        int is_enabled = is_selinux_enabled() > 0;
9d36ace
+        
96e0b33
+        if (is_enabled && !already_warned) {
9d36ace
+            security_context_t con;
9d36ace
+            
9d36ace
+            if (getcon(&con) == 0) {
9d36ace
+                
9d36ace
+                ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, NULL,
9d36ace
+                             "SELinux policy enabled; "
9d36ace
+                             "httpd running as context %s", con);
9d36ace
+                
9d36ace
+                already_warned = 1;
9d36ace
+                
9d36ace
+                freecon(con);
9d36ace
+            }
9d36ace
+        }
9d36ace
+    }
9d36ace
+
9d36ace
     return OK;
9d36ace
 }
9d36ace
 
96e0b33
--- httpd-2.1.10/configure.in.selinux
96e0b33
+++ httpd-2.1.10/configure.in
96e0b33
@@ -382,6 +382,10 @@
96e0b33
 dnl confirm that a void pointer is large enough to store a long integer
96e0b33
 APACHE_CHECK_VOID_PTR_LEN
9d36ace
 
96e0b33
+AC_CHECK_LIB(selinux, is_selinux_enabled, [
96e0b33
+   APR_ADDTO(AP_LIBS, [-lselinux])
96e0b33
+])
9d36ace
+
9d36ace
 dnl ## Check for the tm_gmtoff field in struct tm to get the timezone diffs
9d36ace
 AC_CACHE_CHECK([for tm_gmtoff in struct tm], ac_cv_struct_tm_gmtoff,
9d36ace
 [AC_TRY_COMPILE([#include <sys/types.h>