[PATCH app-xdm 3/9] config: upgrade the checking for SELinux support

Gaetan Nadon memsize at videotron.ca
Mon Nov 22 07:32:13 PST 2010


Use AC_CHECK_FUNCS to get the consistent #define HAVE_xxx
Use "auto" rather than "try" for consistency with other modules.
Update help string to mention default value.
Unchanged: if configured --with-selinux and -lselinux is misisng,
abort the configuration.

Signed-off-by: Gaetan Nadon <memsize at videotron.ca>
---
 configure.ac |   20 ++++++++++----------
 session.c    |   12 ++++++------
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/configure.ac b/configure.ac
index 3e6bc01..6765f2f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -132,17 +132,17 @@ if test "x$USE_PAM" != "xno" ; then
     )
 fi
 
-use_selinux_default=no
-# Check for selinux support
-AC_ARG_WITH(selinux, AC_HELP_STRING([--with-selinux],[Add support for selinux]),
-	[USE_SELINUX=$withval], [USE_SELINUX=$use_selinux_default])
+# Check for Security-Enhanced Linux (SELinux) support
+AC_ARG_WITH(selinux, AS_HELP_STRING([--with-selinux],
+	[Add support for SELinux (default is no support)]),
+	[USE_SELINUX=$withval], [USE_SELINUX=no])
 if test "x$USE_SELINUX" != "xno" ; then
-	AC_SEARCH_LIBS(is_selinux_enabled,[selinux])
-	AC_CHECK_FUNC(is_selinux_enabled,
-		[AC_DEFINE(HAVE_SELINUX,1,[Add support for selinux])],
-		[if test "x$USE_SELINUX" != "xtry" ; then
-			AC_MSG_ERROR(["selinux support requested, but is_selinux_enabled not found."])
-		 fi])
+    AC_SEARCH_LIBS(is_selinux_enabled, [selinux],
+	[AC_CHECK_FUNCS([is_selinux_enabled])],
+	[AS_IF([test "x$USE_SELINUX" = "xyes"],
+	    [AC_MSG_ERROR([SELinux support requested, but is_selinux_enabled not found.])]
+	)]
+    )
 fi
 
 # FIXME: Find better test for which OS'es use su -m  - for now, just try to
diff --git a/session.c b/session.c
index b368b68..f2c2680 100644
--- a/session.c
+++ b/session.c
@@ -71,17 +71,17 @@ extern int key_setnet(struct key_netstarg *arg);
 # include <prot.h>
 #endif
 
-#ifdef HAVE_SELINUX
+#ifdef HAVE_IS_SELINUX_ENABLED
 #include <selinux/selinux.h>
 #include <selinux/get_context_list.h>
-#endif /* HAVE_SELINUX */
+#endif /* HAVE_IS_SELINUX_ENABLED */
 
 # include <dlfcn.h>
 # ifndef RTLD_NOW
 #  define RTLD_NOW 1
 # endif
 
-#ifdef HAVE_SELINUX
+#ifdef HAVE_IS_SELINUX_ENABLED
 /* This should be run just before we exec the user session. */
 static int
 xdm_selinux_setup (const char *login)
@@ -115,7 +115,7 @@ xdm_selinux_setup (const char *login)
 	freecon (scontext);
 	return TRUE;
 }
-#endif /* HAVE_SELINUX */
+#endif /* HAVE_IS_SELINUX_ENABLED */
 
 static	int	runAndWait (char **args, char **environ);
 
@@ -817,7 +817,7 @@ StartClient (
 	    bzero(passwd, strlen(passwd));
 
 	SetUserAuthorization (d, verify);
-#ifdef HAVE_SELINUX
+#ifdef HAVE_IS_SELINUX_ENABLED
    /*
     * For Security Enhanced Linux:
     * set the default security context for this user.
@@ -827,7 +827,7 @@ StartClient (
        exit (UNMANAGE_DISPLAY);
        return (0);
    }
-#endif /* HAVE_SELINUX */
+#endif /* HAVE_IS_SELINUX_ENABLED */
 	home = getEnv (verify->userEnviron, "HOME");
 	if (home)
 	    if (chdir (home) == -1) {
-- 
1.6.0.4



More information about the xorg-devel mailing list