Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
configure.ac | 83 ++----------------------------------------
m4/virt-polkit.m4 | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 110 insertions(+), 80 deletions(-)
create mode 100644 m4/virt-polkit.m4
diff --git a/configure.ac b/configure.ac
index 75a1a0c030..6667a00282 100644
--- a/configure.ac
+++ b/configure.ac
@@ -110,7 +110,6 @@ then
fi
dnl Required minimum versions of all libs we depend on
-POLKIT_REQUIRED="0.6"
PARTED_REQUIRED="1.8.0"
DEVMAPPER_REQUIRED=1.0.0
LIBPCAP_REQUIRED="1.0.0"
@@ -991,76 +990,8 @@ AC_DEFINE_UNQUOTED([TLS_PRIORITY], ["$with_tls_priority"],
[TLS default priority string])
-dnl PolicyKit library
-POLKIT_CFLAGS=
-POLKIT_LIBS=
-PKCHECK_PATH=
-LIBVIRT_ARG_WITH_ALT([POLKIT], [use PolicyKit for UNIX socket access checks],
- [check])
-
-with_polkit0=no
-with_polkit1=no
-if test "x$with_polkit" = "xyes" || test "x$with_polkit" =
"xcheck"; then
- dnl Check for new polkit first. We directly talk over DBus
- dnl but we use existence of pkcheck binary as a sign that
- dnl we should prefer polkit-1 over polkit-0, so we check
- dnl for it even though we don't ultimately use it
- AC_PATH_PROG([PKCHECK_PATH],[pkcheck], [], [$LIBVIRT_SBIN_PATH])
- if test "x$PKCHECK_PATH" != "x" ; then
- dnl Found pkcheck, so ensure dbus-devel is present
- if test "x$with_dbus" = "xyes" ; then
- AC_DEFINE_UNQUOTED([WITH_POLKIT], 1,
- [use PolicyKit for UNIX socket access checks])
- AC_DEFINE_UNQUOTED([WITH_POLKIT1], 1,
- [use PolicyKit for UNIX socket access checks])
- with_polkit="yes"
- with_polkit1="yes"
- else
- if test "x$with_polkit" = "xcheck" ; then
- with_polkit=no
- else
- AC_MSG_ERROR(
- [You must install dbus to compile libvirt with polkit-1])
- fi
- fi
- else
- dnl Check for old polkit second - library + binary
- PKG_CHECK_MODULES(POLKIT, polkit-dbus >= $POLKIT_REQUIRED,
- [with_polkit=yes], [
- if test "x$with_polkit" = "xcheck" ; then
- with_polkit=no
- else
- AC_MSG_ERROR(
- [You must install PolicyKit >= $POLKIT_REQUIRED to compile libvirt])
- fi
- ])
- if test "x$with_polkit" = "xyes" ; then
- AC_DEFINE_UNQUOTED([WITH_POLKIT], 1,
- [use PolicyKit for UNIX socket access checks])
- AC_DEFINE_UNQUOTED([WITH_POLKIT0], 1,
- [use PolicyKit for UNIX socket access checks])
-
- old_CFLAGS=$CFLAGS
- old_LIBS=$LIBS
- CFLAGS="$CFLAGS $POLKIT_CFLAGS"
- LIBS="$LIBS $POLKIT_LIBS"
- AC_CHECK_FUNCS([polkit_context_is_caller_authorized])
- CFLAGS="$old_CFLAGS"
- LIBS="$old_LIBS"
-
- AC_PATH_PROG([POLKIT_AUTH], [polkit-auth])
- if test "x$POLKIT_AUTH" != "x"; then
- AC_DEFINE_UNQUOTED([POLKIT_AUTH],["$POLKIT_AUTH"],[Location of
polkit-auth program])
- fi
- with_polkit0="yes"
- fi
- fi
-fi
-AM_CONDITIONAL([WITH_POLKIT], [test "x$with_polkit" = "xyes"])
-AM_CONDITIONAL([WITH_POLKIT0], [test "x$with_polkit0" = "xyes"])
-AM_CONDITIONAL([WITH_POLKIT1], [test "x$with_polkit1" = "xyes"])
-AC_SUBST([POLKIT_CFLAGS])
-AC_SUBST([POLKIT_LIBS])
+LIBVIRT_ARG_POLKIT
+LIBVIRT_CHECK_POLKIT
LIBVIRT_ARG_FIREWALLD
LIBVIRT_CHECK_FIREWALLD
@@ -2355,6 +2286,7 @@ LIBVIRT_RESULT_NSS
LIBVIRT_RESULT_NUMACTL
LIBVIRT_RESULT_OPENWSMAN
LIBVIRT_RESULT_PCIACCESS
+LIBVIRT_RESULT_POLKIT
LIBVIRT_RESULT_READLINE
LIBVIRT_RESULT_SANLOCK
LIBVIRT_RESULT_SASL
@@ -2362,15 +2294,6 @@ LIBVIRT_RESULT_SELINUX
LIBVIRT_RESULT_SSH2
LIBVIRT_RESULT_UDEV
LIBVIRT_RESULT_YAJL
-if test "$with_polkit" = "yes" ; then
-if test "$with_polkit0" = "yes" ; then
-AC_MSG_NOTICE([ polkit: $POLKIT_CFLAGS $POLKIT_LIBS (version 0)])
-else
-AC_MSG_NOTICE([ polkit: $PKCHECK_PATH (version 1)])
-fi
-else
-AC_MSG_NOTICE([ polkit: no])
-fi
if test "$with_xen" = "yes" ; then
AC_MSG_NOTICE([ xen: $XEN_CFLAGS $XEN_LIBS])
else
diff --git a/m4/virt-polkit.m4 b/m4/virt-polkit.m4
new file mode 100644
index 0000000000..206fc4a39d
--- /dev/null
+++ b/m4/virt-polkit.m4
@@ -0,0 +1,107 @@
+dnl The polkit library
+dnl
+dnl Copyright (C) 2016 Red Hat, Inc.
+dnl
+dnl This library is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU Lesser General Public
+dnl License as published by the Free Software Foundation; either
+dnl version 2.1 of the License, or (at your option) any later version.
+dnl
+dnl This library is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+dnl Lesser General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU Lesser General Public
+dnl License along with this library. If not, see
+dnl <
http://www.gnu.org/licenses/>.
+dnl
+
+AC_DEFUN([LIBVIRT_ARG_POLKIT], [
+ LIBVIRT_ARG_WITH_ALT([POLKIT], [use PolicyKit for UNIX socket access checks],
+ [check])
+])
+
+AC_DEFUN([LIBVIRT_CHECK_POLKIT], [
+ AC_REQUIRE([LIBVIRT_CHECK_DBUS])
+
+ POLKIT_REQUIRED="0.6"
+ POLKIT_CFLAGS=
+ POLKIT_LIBS=
+ PKCHECK_PATH=
+
+ with_polkit0=no
+ with_polkit1=no
+
+ if test "x$with_polkit" = "xyes" || test "x$with_polkit"
= "xcheck"; then
+ dnl Check for new polkit first. We directly talk over DBus
+ dnl but we use existence of pkcheck binary as a sign that
+ dnl we should prefer polkit-1 over polkit-0, so we check
+ dnl for it even though we don't ultimately use it
+ AC_PATH_PROG([PKCHECK_PATH], [pkcheck], [], [/usr/sbin:$PATH])
+ if test "x$PKCHECK_PATH" != "x" ; then
+ dnl Found pkcheck, so ensure dbus-devel is present
+ if test "x$with_dbus" = "xyes" ; then
+ AC_DEFINE_UNQUOTED([WITH_POLKIT], 1,
+ [use PolicyKit for UNIX socket access checks])
+ AC_DEFINE_UNQUOTED([WITH_POLKIT1], 1,
+ [use PolicyKit for UNIX socket access checks])
+ with_polkit="yes"
+ with_polkit1="yes"
+ else
+ if test "x$with_polkit" = "xcheck" ; then
+ with_polkit=no
+ else
+ AC_MSG_ERROR(
+ [You must install dbus to compile libvirt with polkit-1])
+ fi
+ fi
+ else
+ dnl Check for old polkit second - library + binary
+ PKG_CHECK_MODULES(POLKIT, polkit-dbus >= $POLKIT_REQUIRED,
+ [with_polkit=yes], [
+ if test "x$with_polkit" = "xcheck" ; then
+ with_polkit=no
+ else
+ AC_MSG_ERROR(
+ [You must install PolicyKit >= $POLKIT_REQUIRED to compile libvirt])
+ fi
+ ])
+ if test "x$with_polkit" = "xyes" ; then
+ AC_DEFINE_UNQUOTED([WITH_POLKIT], 1,
+ [use PolicyKit for UNIX socket access checks])
+ AC_DEFINE_UNQUOTED([WITH_POLKIT0], 1,
+ [use PolicyKit for UNIX socket access checks])
+
+ old_CFLAGS=$CFLAGS
+ old_LIBS=$LIBS
+ CFLAGS="$CFLAGS $POLKIT_CFLAGS"
+ LIBS="$LIBS $POLKIT_LIBS"
+ AC_CHECK_FUNCS([polkit_context_is_caller_authorized])
+ CFLAGS="$old_CFLAGS"
+ LIBS="$old_LIBS"
+
+ AC_PATH_PROG([POLKIT_AUTH], [polkit-auth])
+ if test "x$POLKIT_AUTH" != "x"; then
+ AC_DEFINE_UNQUOTED([POLKIT_AUTH],["$POLKIT_AUTH"],[Location of
polkit-auth program])
+ fi
+ with_polkit0="yes"
+ fi
+ fi
+ fi
+
+ AM_CONDITIONAL([WITH_POLKIT], [test "x$with_polkit" = "xyes"])
+ AM_CONDITIONAL([WITH_POLKIT0], [test "x$with_polkit0" = "xyes"])
+ AM_CONDITIONAL([WITH_POLKIT1], [test "x$with_polkit1" = "xyes"])
+ AC_SUBST([POLKIT_CFLAGS])
+ AC_SUBST([POLKIT_LIBS])
+])
+
+AC_DEFUN([LIBVIRT_RESULT_POLKIT], [
+ if test "$with_polkit0" = "yes" ; then
+ msg="$POLKIT_CFLAGS $POLKIT_LIBS (version 0)"
+ else
+ msg="$PKCHECK_PATH (version 1)"
+ fi
+ LIBVIRT_RESULT([polkit], [$with_polkit], [$msg])
+])
--
2.11.0