76f6dc7
diff --git a/configure.in b/configure.in
76f6dc7
index c8f9aa2..cb43246 100644
76f6dc7
--- a/configure.in
76f6dc7
+++ b/configure.in
76f6dc7
@@ -484,6 +484,11 @@ getloadavg
110f0ad
 dnl confirm that a void pointer is large enough to store a long integer
110f0ad
 APACHE_CHECK_VOID_PTR_LEN
110f0ad
 
110f0ad
+AC_CHECK_LIB(selinux, is_selinux_enabled, [
3a44ff7
+   AC_DEFINE(HAVE_SELINUX, 1, [Defined if SELinux is supported])
59afc15
+   APR_ADDTO(HTTPD_LIBS, [-lselinux])
110f0ad
+])
110f0ad
+
3a44ff7
 AC_CACHE_CHECK([for gettid()], ac_cv_gettid,
3a44ff7
 [AC_TRY_RUN(#define _GNU_SOURCE
3a44ff7
 #include <unistd.h>
76f6dc7
diff --git a/server/core.c b/server/core.c
76f6dc7
index dc0f17a..7ed9527 100644
76f6dc7
--- a/server/core.c
76f6dc7
+++ b/server/core.c
76f6dc7
@@ -59,6 +59,10 @@
3a44ff7
 #include <unistd.h>
3a44ff7
 #endif
9d36ace
 
3a44ff7
+#ifdef HAVE_SELINUX
9d36ace
+#include <selinux/selinux.h>
3a44ff7
+#endif
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)
76f6dc7
@@ -5015,6 +5019,28 @@ static int core_post_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *pte
9d36ace
     }
9d36ace
 #endif
9d36ace
 
3a44ff7
+#ifdef HAVE_SELINUX
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
+    }
3a44ff7
+#endif
9d36ace
+
9d36ace
     return OK;
9d36ace
 }
9d36ace