make selinux detection more user friendly

Mike Frysinger <[email protected]> Mon, 9 Jan 2006 18:53:06 -0500
Newsgroups gmane.linux.pld.shadow.general
Organization wh0rd.org
Message-ID <[email protected]>
as noted before, a default `./configure` run will fail on all non-selinux 
systems ... patch attached
-mike
shadow-friendly-selinux.patch (text/x-diff, 1.6 KB)
Index: configure.in
===================================================================
RCS file: /cvsroot/shadow/configure.in,v
retrieving revision 1.135
diff -u -p -r1.135 configure.in
--- configure.in	5 Jan 2006 17:40:35 -0000	1.135
+++ configure.in	9 Jan 2006 23:51:20 -0000
@@ -226,7 +226,7 @@ AC_ARG_WITH(libpam,
 	[with_libpam=$withval], [with_libpam=yes])
 AC_ARG_WITH(selinux,
 	[AC_HELP_STRING([--with-selinux], [use SELinux support @<:@default=autodetect@:>@])],
-	[with_selinux=$withval], [with_selinux=yes])
+	[with_selinux=$withval], [with_selinux=maybe])
 AC_ARG_WITH(skey,
 	[AC_HELP_STRING([--with-skey], [use S/Key support @<:@default=no@:>@])],
 	[with_skey=$withval], [with_skey=no])
@@ -288,13 +288,21 @@ if test "$with_libcrack" = "yes"; then
 		AC_DEFINE(HAVE_LIBCRACK_PW, 1, [Defined if it includes *Pw functions.]))
 fi
 
-if test "$with_selinux" = "yes"; then
+if test "$with_selinux" != "no"; then
+	have_selinux="yes"
 	AC_CHECK_LIB(selinux, is_selinux_enabled,
 		[LIBSELINUX="-lselinux"],
-		[AC_MSG_ERROR([libselinux not found])])
+		[have_selinux="no"])
 	AC_SUBST(LIBSELINUX)
-	AC_CHECK_HEADERS(selinux/selinux.h, [], [selinux/selinux.h is missing])
-	AC_DEFINE(WITH_SELINUX, 1, [Build shadow with SELinux support])
+	if test "x$have_selinux$with_selinux" = "xnoyes" ; then
+		AC_MSG_ERROR([libselinux not found])
+	elif test "x$have_selinux" = "yes" ; then
+		with_selinux="yes"
+		AC_CHECK_HEADERS(selinux/selinux.h, [], [selinux/selinux.h is missing])
+		AC_DEFINE(WITH_SELINUX, 1, [Build shadow with SELinux support])
+	else
+		with_selinux="no"
+	fi
 fi
 
 AC_SUBST(LIBPAM)