X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=m4%2Fselinux-selinux-h.m4;h=35d2dbed45ad38167d51cbf5057fe32f02e7801a;hb=758fee15d9627556a3f0011973e83afb8d56d9be;hp=c6e735c08f10b2c02fbb18cdd81255ad0a10dfc3;hpb=42d1eda5dcce2d68deab7a642e7f29bcd7144a0d;p=gnulib.git diff --git a/m4/selinux-selinux-h.m4 b/m4/selinux-selinux-h.m4 index c6e735c08..35d2dbed4 100644 --- a/m4/selinux-selinux-h.m4 +++ b/m4/selinux-selinux-h.m4 @@ -1,20 +1,45 @@ -# serial 2 -*- Autoconf -*- -# Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc. +# serial 3 -*- Autoconf -*- +# Copyright (C) 2006-2007, 2009-2010 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # From Jim Meyering # Provide , if necessary. +# If it is already present, provide wrapper functions to guard against +# misbehavior from getfilecon, lgetfilecon, and fgetfilecon. AC_DEFUN([gl_HEADERS_SELINUX_SELINUX_H], [ - # Check for , - AC_CHECK_HEADERS([selinux/selinux.h], - [SELINUX_SELINUX_H=], - [SELINUX_SELINUX_H=selinux/selinux.h]) - AC_SUBST([SELINUX_SELINUX_H]) + AC_REQUIRE([gl_LIBSELINUX]) + AC_CHECK_HEADERS([selinux/selinux.h]) + if test "$ac_cv_header_selinux_selinux_h" = yes; then + # We do have , so do compile getfilecon.c + # and arrange to use its wrappers. + AC_LIBOBJ([getfilecon]) + gl_CHECK_NEXT_HEADERS([selinux/selinux.h]) + AC_DEFINE([getfilecon], [rpl_getfilecon], + [Always use our getfilecon wrapper.]) + AC_DEFINE([lgetfilecon], [rpl_lgetfilecon], + [Always use our lgetfilecon wrapper.]) + AC_DEFINE([fgetfilecon], [rpl_fgetfilecon], + [Always use our fgetfilecon wrapper.]) + fi + + case "$ac_cv_search_setfilecon:$ac_cv_header_selinux_selinux_h" in + no:*) # already warned + ;; + *:no) + AC_MSG_WARN([libselinux was found but selinux/selinux.h is missing.]) + AC_MSG_WARN([AC_PACKAGE_NAME will be compiled without SELinux support.]) + esac +]) + +AC_DEFUN([gl_LIBSELINUX], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([AC_CANONICAL_BUILD]) LIB_SELINUX= gl_save_LIBS=$LIBS AC_SEARCH_LIBS([setfilecon], [selinux], @@ -22,4 +47,11 @@ AC_DEFUN([gl_HEADERS_SELINUX_SELINUX_H], LIB_SELINUX=$ac_cv_search_setfilecon]) AC_SUBST([LIB_SELINUX]) LIBS=$gl_save_LIBS + + # Warn if SELinux is found but libselinux is absent; + if test "$ac_cv_search_setfilecon" = no && + test "$host" = "$build" && test -d /selinux; then + AC_MSG_WARN([This system supports SELinux but libselinux is missing.]) + AC_MSG_WARN([AC_PACKAGE_NAME will be compiled without SELinux support.]) + fi ])