Hi,

Version 3 fixes line wrapping problem and adds more comments.

This late patch is to address Masatake YAMATO's concern for,

<1> selinux.h is available, but libselinux is not.
<2> libselinux is available, but selinux.h is not.

Therefore, we only set HAVE_LIBSELINUX_DEVEL when all libraries and
headers are available. The following situations have been tested.

* no selinux.h and libselinux:
  $ ./configure
  ...
  checking selinux/selinux.h usability... no
  checking selinux/selinux.h presence... no
  checking for selinux/selinux.h... no
  ...
  $ cat include/config.h
  ...
  /* #undef HAVE_LIBSELINUX_DEVEL */
  ...
  $ cat config.mk
  ...
  SELINUX_LIBS =
  ...

* only have libselinux:
  $ ./configure
  ...
  checking selinux/selinux.h usability... no
  checking selinux/selinux.h presence... no
  checking for selinux/selinux.h... no
  ...
  $ cat include/config.h
  ...
  /* #undef HAVE_LIBSELINUX_DEVEL */
  ...
  $ cat config.mk
  ...
  SELINUX_LIBS =
  ...

* only have selinux.h
  $ ./configure
  ...
  checking selinux/selinux.h usability... yes
  checking selinux/selinux.h presence... yes
  checking for selinux/selinux.h... yes
  checking for is_selinux_enabled in -lselinux... no
  ...
  $ cat include/config.h
  ...
  /* #undef HAVE_LIBSELINUX_DEVEL */
  ...
  $ cat config.mk
  ...
  SELINUX_LIBS =
  ...

* have both libselinux and selinux.h
  $ ./configure
  ...
  checking selinux/selinux.h usability... yes
  checking selinux/selinux.h presence... yes
  checking for selinux/selinux.h... yes
  checking for is_selinux_enabled in -lselinux... yes
  ...
  $ cat include/config.h
  ...
  #define HAVE_LIBSELINUX_DEVEL 1
  ...
  $ cat config.mk
  ...
  SELINUX_LIBS = -lselinux
  ...

Signed-off-by: Masatake YAMATO <[email protected]>
Signed-off-by: CAI Qian <[email protected]>

--- m4/ltp-selinux.m4.orig      2009-02-16 13:44:04.000000000 +0800
+++ m4/ltp-selinux.m4   2009-03-13 15:34:19.000000000 +0800
@@ -22,8 +22,11 @@
 dnl
 AC_DEFUN([LTP_CHECK_SELINUX],
 [dnl
+AH_TEMPLATE(HAVE_LIBSELINUX_DEVEL,
+[Define to 1 if you have both SELinux libraries and headers.])
 AC_CHECK_HEADERS(selinux/selinux.h,[
-        SELINUX_LIBS="-lselinux"],[
+        AC_CHECK_LIB(selinux,is_selinux_enabled,[
+                AC_DEFINE(HAVE_LIBSELINUX_DEVEL) SELINUX_LIBS="-lselinux"],[
+                SELINUX_LIBS=""])],[
         SELINUX_LIBS=""])
-AC_SUBST(SELINUX_LIBS)
-])
+AC_SUBST(SELINUX_LIBS)])
--- testcases/kernel/fs/proc/proc01.c.orig      2009-03-13 13:55:33.000000000 
+0800
+++ testcases/kernel/fs/proc/proc01.c   2009-03-15 01:56:21.000000000 +0800
@@ -39,7 +39,7 @@
 #include <fcntl.h>
 #include <fnmatch.h>

-#ifdef HAVE_SELINUX_SELINUX_H
+#ifdef HAVE_LIBSELINUX_DEVEL
 #include <selinux/selinux.h>
 #endif

@@ -105,15 +105,24 @@
     {"", "", 0}
   };

-/* If a particular LSM is enabled, it is expected that some entries can
-   be read successfully. */
-#ifdef HAVE_SELINUX_SELINUX_H
+/*
+ * If a particular LSM is enabled, it is expected that some entries can
+ * be read successfully. Otherwise, those entries will retrun some
+ * failures listed above. Here to add any LSM specific entries.
+ */
+
+/*
+ * Test macro to indicate that SELinux libraries and headers are
+ * installed.
+ */
+#ifdef HAVE_LIBSELINUX_DEVEL
 const char lsm_should_work[][PATH_MAX] =
   {
     "/proc/self/attr/*",
     "/proc/self/task/[0-9]*/attr/*",
     ""
   };
+/* Place holder for none of LSM is detected. */
 #else
 const char lsm_should_work[][PATH_MAX] =
   {
@@ -129,10 +138,13 @@
     ""
   };

-/* Check if a particular LSM is enabled. */
+/*
+ * Here to add any function to check if a particular LSM is enabled.
+ * Return non-zero if enabled, and zero otherwise.
+ */
 int is_lsm_enabled(void)
 {
-#ifdef HAVE_SELINUX_SELINUX_H
+#ifdef HAVE_LIBSELINUX_DEVEL
   return is_selinux_enabled();
 #else
   return 0;

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to