Author: mturk
Date: Wed Jun 10 06:32:14 2009
New Revision: 783223
URL: http://svn.apache.org/viewvc?rev=783223&view=rev
Log:
Add SELinux support stub
Added:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/linux/
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/linux/SELinux.java
(with props)
commons/sandbox/runtime/trunk/src/main/native/os/linux/selinux.c (with
props)
Modified:
commons/sandbox/runtime/trunk/src/main/native/Makefile.in
commons/sandbox/runtime/trunk/src/main/native/include/arch/darwin/acr_arch_private.h
commons/sandbox/runtime/trunk/src/main/native/include/arch/hpux/acr_arch_private.h
commons/sandbox/runtime/trunk/src/main/native/include/arch/linux/acr_arch_private.h
commons/sandbox/runtime/trunk/src/main/native/include/arch/solaris/acr_arch_private.h
commons/sandbox/runtime/trunk/src/main/native/include/arch/unix/acr_arch.h
Added:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/linux/SELinux.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/linux/SELinux.java?rev=783223&view=auto
==============================================================================
---
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/linux/SELinux.java
(added)
+++
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/linux/SELinux.java
Wed Jun 10 06:32:14 2009
@@ -0,0 +1,59 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.runtime.platform.linux;
+
+import org.apache.commons.runtime.exception.OperatingSystemException;
+import
org.apache.commons.runtime.exception.UnsupportedOperatingSystemException;
+
+/**
+ * Security-Enhanced Linux support.
+ */
+public class SELinux
+{
+
+ private SELinux()
+ {
+ // No instance
+ }
+
+ /*
+ * Return 1 if we are running on a SELinux kernel, or 0 if not or -1
+ * if we get an error.
+ * @param type OS type to test.
+ */
+ private static native boolean enabled0()
+ throws OperatingSystemException;
+
+ /**
+ * Check if we are running on {...@code SELinux} kernel.
+ *
+ * @return {...@code true} if kernel has {...@code SELinux} support
enabled.
+ * @throws OperatingSystemException if we have error
+ * @throws UnsupportedOperatingSystemException if not running on {...@code
Linux}
+ * operating system.
+ */
+ public static boolean isEnabled()
+ throws OperatingSystemException, UnsupportedOperatingSystemException
+ {
+ try {
+ return enabled0();
+ } catch (UnsatisfiedLinkError e) {
+ throw new UnsupportedOperatingSystemException();
+ }
+ }
+
+}
Propchange:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/linux/SELinux.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.in
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/Makefile.in?rev=783223&r1=783222&r2=783223&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/Makefile.in (original)
+++ commons/sandbox/runtime/trunk/src/main/native/Makefile.in Wed Jun 10
06:32:14 2009
@@ -97,6 +97,7 @@
$(SRCDIR)/os/linux/platform.$(OBJ) \
$(SRCDIR)/os/linux/pgroup.$(OBJ) \
$(SRCDIR)/os/linux/puser.$(OBJ) \
+ $(SRCDIR)/os/linux/selinux.$(OBJ) \
$(SRCDIR)/os/linux/os.$(OBJ)
SOLARIS_OBJS= \
Modified:
commons/sandbox/runtime/trunk/src/main/native/include/arch/darwin/acr_arch_private.h
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/arch/darwin/acr_arch_private.h?rev=783223&r1=783222&r2=783223&view=diff
==============================================================================
---
commons/sandbox/runtime/trunk/src/main/native/include/arch/darwin/acr_arch_private.h
(original)
+++
commons/sandbox/runtime/trunk/src/main/native/include/arch/darwin/acr_arch_private.h
Wed Jun 10 06:32:14 2009
@@ -37,8 +37,8 @@
* ACR Darwin platform private macros and defines
*
*/
-#define ACR_ARCHIMPL_CLASS_PATH ACR_CLASS_PATH "platform/darwin/"
-#define ACR_JNI_ARCHIMPL_DECLARE(RT, CL, FN) \
+#define ACR_PLATFORM_CLASS_PATH ACR_CLASS_PATH "platform/darwin/"
+#define ACR_JNI_PLATFORM_DECLARE(RT, CL, FN) \
JNIEXPORT RT JNICALL
Java_org_apache_commons_runtime_platform_darwin_##CL##_##FN
#ifdef __cplusplus
Modified:
commons/sandbox/runtime/trunk/src/main/native/include/arch/hpux/acr_arch_private.h
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/arch/hpux/acr_arch_private.h?rev=783223&r1=783222&r2=783223&view=diff
==============================================================================
---
commons/sandbox/runtime/trunk/src/main/native/include/arch/hpux/acr_arch_private.h
(original)
+++
commons/sandbox/runtime/trunk/src/main/native/include/arch/hpux/acr_arch_private.h
Wed Jun 10 06:32:14 2009
@@ -33,8 +33,8 @@
* ACR HP-UX platform private macros and defines
*
*/
-#define ACR_ARCHIMPL_CLASS_PATH ACR_CLASS_PATH "platform/hpux/"
-#define ACR_JNI_ARCHIMPL_DECLARE(RT, CL, FN) \
+#define ACR_PLATFORM_CLASS_PATH ACR_CLASS_PATH "platform/hpux/"
+#define ACR_JNI_PLATFORM_DECLARE(RT, CL, FN) \
JNIEXPORT RT JNICALL
Java_org_apache_commons_runtime_platform_hpux_##CL##_##FN
#ifdef __cplusplus
Modified:
commons/sandbox/runtime/trunk/src/main/native/include/arch/linux/acr_arch_private.h
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/arch/linux/acr_arch_private.h?rev=783223&r1=783222&r2=783223&view=diff
==============================================================================
---
commons/sandbox/runtime/trunk/src/main/native/include/arch/linux/acr_arch_private.h
(original)
+++
commons/sandbox/runtime/trunk/src/main/native/include/arch/linux/acr_arch_private.h
Wed Jun 10 06:32:14 2009
@@ -34,9 +34,10 @@
*
*/
-#define ACR_ARCHIMPL_CLASS_PATH ACR_CLASS_PATH "platform/linux/"
-#define ACR_JNI_ARCHIMPL_DECLARE(RT, CL, FN) \
- JNIEXPORT RT JNICALL
Java_org_apache_commons_runtime_platform_unix_##CL##_##FN
+#define ACR_PLATFORM_CLASS_PATH ACR_CLASS_PATH "platform/linux/"
+#define ACR_JNI_PLATFORM_DECLARE(RT, CL, FN) \
+ JNIEXPORT RT JNICALL
Java_org_apache_commons_runtime_platform_linux_##CL##_##FN
+
#ifdef __cplusplus
}
Modified:
commons/sandbox/runtime/trunk/src/main/native/include/arch/solaris/acr_arch_private.h
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/arch/solaris/acr_arch_private.h?rev=783223&r1=783222&r2=783223&view=diff
==============================================================================
---
commons/sandbox/runtime/trunk/src/main/native/include/arch/solaris/acr_arch_private.h
(original)
+++
commons/sandbox/runtime/trunk/src/main/native/include/arch/solaris/acr_arch_private.h
Wed Jun 10 06:32:14 2009
@@ -33,8 +33,8 @@
* ACR SunOS platform private macros and defines
*
*/
-#define ACR_ARCHIMPL_CLASS_PATH ACR_CLASS_PATH "platform/solaris/"
-#define ACR_JNI_ARCHIMPL_DECLARE(RT, CL, FN) \
+#define ACR_PLATFORM_CLASS_PATH ACR_CLASS_PATH "platform/solaris/"
+#define ACR_JNI_PLATFORM_DECLARE(RT, CL, FN) \
JNIEXPORT RT JNICALL
Java_org_apache_commons_runtime_platform_solaris_##CL##_##FN
#ifdef __cplusplus
Modified:
commons/sandbox/runtime/trunk/src/main/native/include/arch/unix/acr_arch.h
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/arch/unix/acr_arch.h?rev=783223&r1=783222&r2=783223&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/arch/unix/acr_arch.h
(original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/arch/unix/acr_arch.h
Wed Jun 10 06:32:14 2009
@@ -29,8 +29,8 @@
#define ACR_INLINE inline
#endif
-#define ACR_PLATFORM_CLASS_PATH ACR_CLASS_PATH "platform/unix/"
-#define ACR_JNI_PLATFORM_DECLARE(RT, CL, FN) \
+#define ACR_ARCHIMPL_CLASS_PATH ACR_CLASS_PATH "platform/unix/"
+#define ACR_JNI_ARCHIMPL_DECLARE(RT, CL, FN) \
JNIEXPORT RT JNICALL
Java_org_apache_commons_runtime_platform_unix_##CL##_##FN
#define ACR_MIN_FREAD_LEN 4096
Added: commons/sandbox/runtime/trunk/src/main/native/os/linux/selinux.c
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/linux/selinux.c?rev=783223&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/linux/selinux.c (added)
+++ commons/sandbox/runtime/trunk/src/main/native/os/linux/selinux.c Wed Jun 10
06:32:14 2009
@@ -0,0 +1,37 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "acr.h"
+#include "acr_private.h"
+#include "acr_arch.h"
+#include "acr_error.h"
+#include "acr_string.h"
+
+#include <selinux/selinux.h>
+
+ACR_JNI_PLATFORM_DECLARE(jboolean, SELinux, enabled0)(ACR_JNISTDARGS)
+{
+ int rc;
+
+ rc = is_selinux_enabled();
+ if (rc < 0) {
+ ACR_ThrowException(_E, THROW_NMARK, ACR_EX_OSERR, ACR_GET_OS_ERROR());
+ return JNI_FALSE;
+ }
+ else {
+ return V2Z(rc);
+ }
+}
Propchange: commons/sandbox/runtime/trunk/src/main/native/os/linux/selinux.c
------------------------------------------------------------------------------
svn:eol-style = native