qemu: Move capability checks for IOMMU features
[libvirt/ericb.git] / m4 / virt-selinux.m4
blobfe274fafe9b8a498784264e27598d53e0ce27ee9
1 dnl The libselinux.so library
2 dnl
3 dnl Copyright (C) 2012-2014, 2016 Red Hat, Inc.
4 dnl
5 dnl This library is free software; you can redistribute it and/or
6 dnl modify it under the terms of the GNU Lesser General Public
7 dnl License as published by the Free Software Foundation; either
8 dnl version 2.1 of the License, or (at your option) any later version.
9 dnl
10 dnl This library is distributed in the hope that it will be useful,
11 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
12 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 dnl Lesser General Public License for more details.
14 dnl
15 dnl You should have received a copy of the GNU Lesser General Public
16 dnl License along with this library.  If not, see
17 dnl <http://www.gnu.org/licenses/>.
18 dnl
20 AC_DEFUN([LIBVIRT_ARG_SELINUX],[
21   LIBVIRT_ARG_WITH_FEATURE([SELINUX], [SELinux], [check])
22   LIBVIRT_ARG_WITH([SELINUX_MOUNT], [set SELinux mount point], [check])
25 AC_DEFUN([LIBVIRT_CHECK_SELINUX],[
26   LIBVIRT_CHECK_LIB([SELINUX], [selinux],
27                     [fgetfilecon_raw], [selinux/selinux.h])
29   if test "$with_selinux" = "yes"; then
30     # libselinux changed signatures between 2.2 and 2.3
31     AC_CACHE_CHECK([for selinux setcon parameter type], [lv_cv_setcon_const],
32     [AC_COMPILE_IFELSE(
33       [AC_LANG_PROGRAM(
34          [[
35 #include <selinux/selinux.h>
36 int setcon(char *context);
37          ]])],
38          [lv_cv_setcon_const=''],
39          [lv_cv_setcon_const='const'])])
40     AC_DEFINE_UNQUOTED([VIR_SELINUX_CTX_CONST], [$lv_cv_setcon_const],
41       [Define to empty or 'const' depending on how SELinux qualifies its
42        security context parameters])
43     # ...and again for 2.5
44     AC_CACHE_CHECK([for selinux selabel_open parameter type],
45                    [lv_cv_selabel_open_const],
46     [AC_COMPILE_IFELSE(
47       [AC_LANG_PROGRAM(
48          [[
49 #include <selinux/selinux.h>
50 #include <selinux/label.h>
51 struct selabel_handle *selabel_open(unsigned, struct selinux_opt *, unsigned);
52          ]])],
53          [lv_cv_selabel_open_const=''],
54          [lv_cv_selabel_open_const='const'])])
55     AC_DEFINE_UNQUOTED([VIR_SELINUX_OPEN_CONST], [$lv_cv_selabel_open_const],
56       [Define to empty or 'const' depending on how SELinux qualifies its
57        selabel_open parameter])
59     AC_MSG_CHECKING([SELinux mount point])
60     if test "$with_selinux_mount" = "check" || test -z "$with_selinux_mount"; then
61       if test -d /sys/fs/selinux ; then
62         SELINUX_MOUNT=/sys/fs/selinux
63       else
64         SELINUX_MOUNT=/selinux
65       fi
66     else
67       SELINUX_MOUNT=$with_selinux_mount
68     fi
69     AC_MSG_RESULT([$SELINUX_MOUNT])
70     AC_DEFINE_UNQUOTED([SELINUX_MOUNT], ["$SELINUX_MOUNT"], [SELinux mount point])
72     dnl We prefer to use <selinux/label.h> and selabel_open, but can fall
73     dnl back to matchpathcon for the sake of RHEL 5's version of libselinux.
74     AC_CHECK_HEADERS([selinux/label.h])
75   fi
78 AC_DEFUN([LIBVIRT_RESULT_SELINUX],[
79   LIBVIRT_RESULT_LIB([SELINUX])