|
Mark McLoughlin |
da05e0 |
From d54fc5008d465d192101a0cb78fd02c437dff736 Mon Sep 17 00:00:00 2001
|
|
Mark McLoughlin |
da05e0 |
From: Daniel P. Berrange <berrange@redhat.com>
|
|
Mark McLoughlin |
da05e0 |
Date: Mon, 17 Aug 2009 08:32:08 +0100
|
|
Mark McLoughlin |
da05e0 |
Subject: [PATCH] Policykit rewrite (bug #499970)
|
|
Mark McLoughlin |
da05e0 |
|
|
Mark McLoughlin |
da05e0 |
Fedora-patch: libvirt-0.7.0-policy-kit-rewrite.patch
|
|
Mark McLoughlin |
da05e0 |
---
|
|
Mark McLoughlin |
da05e0 |
configure.in | 73 ++++++++++++++++++++++++++++--------------
|
|
Mark McLoughlin |
da05e0 |
qemud/Makefile.am | 11 +++++-
|
|
Mark McLoughlin |
da05e0 |
qemud/libvirtd.policy | 42 ------------------------
|
|
Mark McLoughlin |
da05e0 |
qemud/libvirtd.policy-0 | 42 ++++++++++++++++++++++++
|
|
Mark McLoughlin |
da05e0 |
qemud/libvirtd.policy-1 | 42 ++++++++++++++++++++++++
|
|
Mark McLoughlin |
da05e0 |
qemud/qemud.c | 4 +-
|
|
Mark McLoughlin |
da05e0 |
qemud/qemud.h | 4 +-
|
|
Mark McLoughlin |
da05e0 |
qemud/remote.c | 81 ++++++++++++++++++++++++++++++++++++++++++++--
|
|
Mark McLoughlin |
da05e0 |
src/remote_internal.c | 7 ++++
|
|
Mark McLoughlin |
da05e0 |
9 files changed, 230 insertions(+), 76 deletions(-)
|
|
Mark McLoughlin |
da05e0 |
delete mode 100644 qemud/libvirtd.policy
|
|
Mark McLoughlin |
da05e0 |
create mode 100644 qemud/libvirtd.policy-0
|
|
Mark McLoughlin |
da05e0 |
create mode 100644 qemud/libvirtd.policy-1
|
|
Mark McLoughlin |
da05e0 |
|
|
Mark McLoughlin |
da05e0 |
diff --git a/configure.in b/configure.in
|
|
Mark McLoughlin |
da05e0 |
index 45fa9ed..d28c44a 100644
|
|
Mark McLoughlin |
da05e0 |
--- a/configure.in
|
|
Mark McLoughlin |
da05e0 |
+++ b/configure.in
|
|
Daniel P. Berrange |
c476c8 |
@@ -641,40 +641,61 @@ AC_SUBST([SASL_LIBS])
|
|
Daniel P. Berrange |
c476c8 |
dnl PolicyKit library
|
|
Daniel P. Berrange |
c476c8 |
POLKIT_CFLAGS=
|
|
Daniel P. Berrange |
c476c8 |
POLKIT_LIBS=
|
|
Daniel P. Berrange |
c476c8 |
+PKCHECK_PATH=
|
|
Daniel P. Berrange |
c476c8 |
AC_ARG_WITH([polkit],
|
|
Daniel P. Berrange |
c476c8 |
[ --with-polkit use PolicyKit for UNIX socket access checks],
|
|
Daniel P. Berrange |
c476c8 |
[],
|
|
Daniel P. Berrange |
c476c8 |
[with_polkit=check])
|
|
Daniel P. Berrange |
c476c8 |
|
|
Daniel P. Berrange |
c476c8 |
+with_polkit0=no
|
|
Daniel P. Berrange |
c476c8 |
+with_polkit1=no
|
|
Daniel P. Berrange |
c476c8 |
if test "x$with_polkit" = "xyes" -o "x$with_polkit" = "xcheck"; then
|
|
Daniel P. Berrange |
c476c8 |
- PKG_CHECK_MODULES(POLKIT, polkit-dbus >= $POLKIT_REQUIRED,
|
|
Daniel P. Berrange |
c476c8 |
- [with_polkit=yes], [
|
|
Daniel P. Berrange |
c476c8 |
- if test "x$with_polkit" = "xcheck" ; then
|
|
Daniel P. Berrange |
c476c8 |
- with_polkit=no
|
|
Daniel P. Berrange |
c476c8 |
- else
|
|
Daniel P. Berrange |
c476c8 |
- AC_MSG_ERROR(
|
|
Daniel P. Berrange |
c476c8 |
- [You must install PolicyKit >= $POLKIT_REQUIRED to compile libvirt])
|
|
Daniel P. Berrange |
c476c8 |
- fi
|
|
Daniel P. Berrange |
c476c8 |
- ])
|
|
Daniel P. Berrange |
c476c8 |
- if test "x$with_polkit" = "xyes" ; then
|
|
Daniel P. Berrange |
c476c8 |
+ dnl Check for new polkit first - just a binary
|
|
Daniel P. Berrange |
c476c8 |
+ AC_PATH_PROG([PKCHECK_PATH],[pkcheck], [], [/usr/sbin:$PATH])
|
|
Daniel P. Berrange |
c476c8 |
+ if test "x$PKCHECK_PATH" != "x" ; then
|
|
Daniel P. Berrange |
c476c8 |
+ AC_DEFINE_UNQUOTED([PKCHECK_PATH],["$PKCHECK_PATH"],[Location of pkcheck program])
|
|
Daniel P. Berrange |
c476c8 |
AC_DEFINE_UNQUOTED([HAVE_POLKIT], 1,
|
|
Daniel P. Berrange |
c476c8 |
- [use PolicyKit for UNIX socket access checks])
|
|
Daniel P. Berrange |
c476c8 |
-
|
|
Daniel P. Berrange |
c476c8 |
- old_CFLAGS=$CFLAGS
|
|
Daniel P. Berrange |
c476c8 |
- old_LDFLAGS=$LDFLAGS
|
|
Daniel P. Berrange |
c476c8 |
- CFLAGS="$CFLAGS $POLKIT_CFLAGS"
|
|
Daniel P. Berrange |
c476c8 |
- LDFLAGS="$LDFLAGS $POLKIT_LIBS"
|
|
Daniel P. Berrange |
c476c8 |
- AC_CHECK_FUNCS([polkit_context_is_caller_authorized])
|
|
Daniel P. Berrange |
c476c8 |
- CFLAGS="$old_CFLAGS"
|
|
Daniel P. Berrange |
c476c8 |
- LDFLAGS="$old_LDFLAGS"
|
|
Daniel P. Berrange |
c476c8 |
-
|
|
Daniel P. Berrange |
c476c8 |
- AC_PATH_PROG([POLKIT_AUTH], [polkit-auth])
|
|
Daniel P. Berrange |
c476c8 |
- if test "x$POLKIT_AUTH" != "x"; then
|
|
Daniel P. Berrange |
c476c8 |
- AC_DEFINE_UNQUOTED([POLKIT_AUTH],["$POLKIT_AUTH"],[Location of polkit-auth program])
|
|
Daniel P. Berrange |
c476c8 |
+ [use PolicyKit for UNIX socket access checks])
|
|
Daniel P. Berrange |
c476c8 |
+ AC_DEFINE_UNQUOTED([HAVE_POLKIT1], 1,
|
|
Daniel P. Berrange |
c476c8 |
+ [use PolicyKit for UNIX socket access checks])
|
|
Daniel P. Berrange |
c476c8 |
+ with_polkit="yes"
|
|
Daniel P. Berrange |
c476c8 |
+ with_polkit1="yes"
|
|
Daniel P. Berrange |
c476c8 |
+ else
|
|
Daniel P. Berrange |
c476c8 |
+ dnl Check for old polkit second - library + binary
|
|
Daniel P. Berrange |
c476c8 |
+ PKG_CHECK_MODULES(POLKIT, polkit-dbus >= $POLKIT_REQUIRED,
|
|
Daniel P. Berrange |
c476c8 |
+ [with_polkit=yes], [
|
|
Daniel P. Berrange |
c476c8 |
+ if test "x$with_polkit" = "xcheck" ; then
|
|
Daniel P. Berrange |
c476c8 |
+ with_polkit=no
|
|
Daniel P. Berrange |
c476c8 |
+ else
|
|
Daniel P. Berrange |
c476c8 |
+ AC_MSG_ERROR(
|
|
Daniel P. Berrange |
c476c8 |
+ [You must install PolicyKit >= $POLKIT_REQUIRED to compile libvirt])
|
|
Daniel P. Berrange |
c476c8 |
+ fi
|
|
Daniel P. Berrange |
c476c8 |
+ ])
|
|
Daniel P. Berrange |
c476c8 |
+ if test "x$with_polkit" = "xyes" ; then
|
|
Daniel P. Berrange |
c476c8 |
+ AC_DEFINE_UNQUOTED([HAVE_POLKIT], 1,
|
|
Daniel P. Berrange |
c476c8 |
+ [use PolicyKit for UNIX socket access checks])
|
|
Daniel P. Berrange |
c476c8 |
+ AC_DEFINE_UNQUOTED([HAVE_POLKIT0], 1,
|
|
Daniel P. Berrange |
c476c8 |
+ [use PolicyKit for UNIX socket access checks])
|
|
Daniel P. Berrange |
c476c8 |
+
|
|
Daniel P. Berrange |
c476c8 |
+ old_CFLAGS=$CFLAGS
|
|
Daniel P. Berrange |
c476c8 |
+ old_LDFLAGS=$LDFLAGS
|
|
Daniel P. Berrange |
c476c8 |
+ CFLAGS="$CFLAGS $POLKIT_CFLAGS"
|
|
Daniel P. Berrange |
c476c8 |
+ LDFLAGS="$LDFLAGS $POLKIT_LIBS"
|
|
Daniel P. Berrange |
c476c8 |
+ AC_CHECK_FUNCS([polkit_context_is_caller_authorized])
|
|
Daniel P. Berrange |
c476c8 |
+ CFLAGS="$old_CFLAGS"
|
|
Daniel P. Berrange |
c476c8 |
+ LDFLAGS="$old_LDFLAGS"
|
|
Daniel P. Berrange |
c476c8 |
+
|
|
Daniel P. Berrange |
c476c8 |
+ AC_PATH_PROG([POLKIT_AUTH], [polkit-auth])
|
|
Daniel P. Berrange |
c476c8 |
+ if test "x$POLKIT_AUTH" != "x"; then
|
|
Daniel P. Berrange |
c476c8 |
+ AC_DEFINE_UNQUOTED([POLKIT_AUTH],["$POLKIT_AUTH"],[Location of polkit-auth program])
|
|
Daniel P. Berrange |
c476c8 |
+ fi
|
|
Daniel P. Berrange |
c476c8 |
+ with_polkit0="yes"
|
|
Daniel P. Berrange |
c476c8 |
fi
|
|
Daniel P. Berrange |
c476c8 |
fi
|
|
Daniel P. Berrange |
c476c8 |
fi
|
|
Daniel P. Berrange |
c476c8 |
AM_CONDITIONAL([HAVE_POLKIT], [test "x$with_polkit" = "xyes"])
|
|
Daniel P. Berrange |
c476c8 |
+AM_CONDITIONAL([HAVE_POLKIT0], [test "x$with_polkit0" = "xyes"])
|
|
Daniel P. Berrange |
c476c8 |
+AM_CONDITIONAL([HAVE_POLKIT1], [test "x$with_polkit1" = "xyes"])
|
|
Daniel P. Berrange |
c476c8 |
AC_SUBST([POLKIT_CFLAGS])
|
|
Daniel P. Berrange |
c476c8 |
AC_SUBST([POLKIT_LIBS])
|
|
Daniel P. Berrange |
c476c8 |
|
|
Daniel P. Berrange |
c476c8 |
@@ -1695,7 +1716,11 @@ else
|
|
Daniel P. Berrange |
c476c8 |
AC_MSG_NOTICE([ avahi: no])
|
|
Daniel P. Berrange |
c476c8 |
fi
|
|
Daniel P. Berrange |
c476c8 |
if test "$with_polkit" = "yes" ; then
|
|
Daniel P. Berrange |
c476c8 |
-AC_MSG_NOTICE([ polkit: $POLKIT_CFLAGS $POLKIT_LIBS])
|
|
Daniel P. Berrange |
c476c8 |
+if test "$with_polkit0" = "yes" ; then
|
|
Daniel P. Berrange |
c476c8 |
+AC_MSG_NOTICE([ polkit: $POLKIT_CFLAGS $POLKIT_LIBS (version 0)])
|
|
Daniel P. Berrange |
c476c8 |
+else
|
|
Daniel P. Berrange |
c476c8 |
+AC_MSG_NOTICE([ polkit: $PKCHECK_PATH (version 1)])
|
|
Daniel P. Berrange |
c476c8 |
+fi
|
|
Daniel P. Berrange |
c476c8 |
else
|
|
Daniel P. Berrange |
c476c8 |
AC_MSG_NOTICE([ polkit: no])
|
|
Daniel P. Berrange |
c476c8 |
fi
|
|
Mark McLoughlin |
da05e0 |
diff --git a/qemud/Makefile.am b/qemud/Makefile.am
|
|
Mark McLoughlin |
da05e0 |
index 959ff88..3d143da 100644
|
|
Mark McLoughlin |
da05e0 |
--- a/qemud/Makefile.am
|
|
Mark McLoughlin |
da05e0 |
+++ b/qemud/Makefile.am
|
|
Mark McLoughlin |
da05e0 |
@@ -21,7 +21,8 @@ EXTRA_DIST = \
|
|
Mark McLoughlin |
da05e0 |
remote_protocol.x \
|
|
Mark McLoughlin |
da05e0 |
libvirtd.conf \
|
|
Mark McLoughlin |
da05e0 |
libvirtd.init.in \
|
|
Mark McLoughlin |
da05e0 |
- libvirtd.policy \
|
|
Mark McLoughlin |
da05e0 |
+ libvirtd.policy-0 \
|
|
Mark McLoughlin |
da05e0 |
+ libvirtd.policy-1 \
|
|
Mark McLoughlin |
da05e0 |
libvirtd.sasl \
|
|
Mark McLoughlin |
da05e0 |
libvirtd.sysconf \
|
|
Mark McLoughlin |
da05e0 |
libvirtd.aug \
|
|
Mark McLoughlin |
da05e0 |
@@ -147,7 +148,13 @@ endif
|
|
Mark McLoughlin |
da05e0 |
libvirtd_LDADD += ../src/libvirt.la
|
|
Mark McLoughlin |
da05e0 |
|
|
Mark McLoughlin |
da05e0 |
if HAVE_POLKIT
|
|
Mark McLoughlin |
da05e0 |
+if HAVE_POLKIT0
|
|
Mark McLoughlin |
da05e0 |
policydir = $(datadir)/PolicyKit/policy
|
|
Mark McLoughlin |
da05e0 |
+policyfile = libvirtd.policy-0
|
|
Mark McLoughlin |
da05e0 |
+else
|
|
Mark McLoughlin |
da05e0 |
+policydir = $(datadir)/polkit-1/actions
|
|
Mark McLoughlin |
da05e0 |
+policyfile = libvirtd.policy-1
|
|
Mark McLoughlin |
da05e0 |
+endif
|
|
Mark McLoughlin |
da05e0 |
endif
|
|
Mark McLoughlin |
da05e0 |
|
|
Mark McLoughlin |
da05e0 |
if HAVE_AVAHI
|
|
Mark McLoughlin |
da05e0 |
@@ -197,7 +204,7 @@ endif
|
|
Mark McLoughlin |
da05e0 |
if HAVE_POLKIT
|
|
Mark McLoughlin |
da05e0 |
install-data-polkit:: install-init
|
|
Mark McLoughlin |
da05e0 |
mkdir -p $(DESTDIR)$(policydir)
|
|
Mark McLoughlin |
da05e0 |
- $(INSTALL_DATA) $(srcdir)/libvirtd.policy $(DESTDIR)$(policydir)/org.libvirt.unix.policy
|
|
Mark McLoughlin |
da05e0 |
+ $(INSTALL_DATA) $(srcdir)/$(policyfile) $(DESTDIR)$(policydir)/org.libvirt.unix.policy
|
|
Mark McLoughlin |
da05e0 |
uninstall-data-polkit:: install-init
|
|
Mark McLoughlin |
da05e0 |
rm -f $(DESTDIR)$(policydir)/org.libvirt.unix.policy
|
|
Mark McLoughlin |
da05e0 |
else
|
|
Mark McLoughlin |
da05e0 |
diff --git a/qemud/libvirtd.policy b/qemud/libvirtd.policy
|
|
Mark McLoughlin |
da05e0 |
deleted file mode 100644
|
|
Mark McLoughlin |
da05e0 |
index b6da946..0000000
|
|
Mark McLoughlin |
da05e0 |
--- a/qemud/libvirtd.policy
|
|
Mark McLoughlin |
da05e0 |
+++ /dev/null
|
|
Daniel P. Berrange |
c476c8 |
@@ -1,42 +0,0 @@
|
|
Daniel P. Berrange |
c476c8 |
-
|
|
Daniel P. Berrange |
c476c8 |
- "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
|
|
Daniel P. Berrange |
c476c8 |
- "http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd">
|
|
Daniel P. Berrange |
c476c8 |
-
|
|
Daniel P. Berrange |
c476c8 |
-
|
|
Daniel P. Berrange |
c476c8 |
-Policy definitions for libvirt daemon
|
|
Daniel P. Berrange |
c476c8 |
-
|
|
Daniel P. Berrange |
c476c8 |
-Copyright (c) 2007 Daniel P. Berrange <berrange redhat com>
|
|
Daniel P. Berrange |
c476c8 |
-
|
|
Daniel P. Berrange |
c476c8 |
-libvirt is licensed to you under the GNU Lesser General Public License
|
|
Daniel P. Berrange |
c476c8 |
-version 2. See COPYING for details.
|
|
Daniel P. Berrange |
c476c8 |
-
|
|
Daniel P. Berrange |
c476c8 |
-NOTE: If you make changes to this file, make sure to validate the file
|
|
Daniel P. Berrange |
c476c8 |
-using the polkit-policy-file-validate(1) tool. Changes made to this
|
|
Daniel P. Berrange |
c476c8 |
-file are instantly applied.
|
|
Daniel P. Berrange |
c476c8 |
--->
|
|
Daniel P. Berrange |
c476c8 |
-
|
|
Daniel P. Berrange |
c476c8 |
-<policyconfig>
|
|
Daniel P. Berrange |
c476c8 |
- <action id="org.libvirt.unix.monitor">
|
|
Daniel P. Berrange |
c476c8 |
- <description>Monitor local virtualized systems</description>
|
|
Daniel P. Berrange |
c476c8 |
- <message>System policy prevents monitoring of local virtualized systems</message>
|
|
Daniel P. Berrange |
c476c8 |
- <defaults>
|
|
Daniel P. Berrange |
c476c8 |
-
|
|
Daniel P. Berrange |
c476c8 |
- even if not part of a session -->
|
|
Daniel P. Berrange |
c476c8 |
- <allow_any>yes</allow_any>
|
|
Daniel P. Berrange |
c476c8 |
- <allow_inactive>yes</allow_inactive>
|
|
Daniel P. Berrange |
c476c8 |
- <allow_active>yes</allow_active>
|
|
Daniel P. Berrange |
c476c8 |
- </defaults>
|
|
Daniel P. Berrange |
c476c8 |
- </action>
|
|
Daniel P. Berrange |
c476c8 |
-
|
|
Daniel P. Berrange |
c476c8 |
- <action id="org.libvirt.unix.manage">
|
|
Daniel P. Berrange |
c476c8 |
- <description>Manage local virtualized systems</description>
|
|
Daniel P. Berrange |
c476c8 |
- <message>System policy prevents management of local virtualized systems</message>
|
|
Daniel P. Berrange |
c476c8 |
- <defaults>
|
|
Daniel P. Berrange |
c476c8 |
-
|
|
Daniel P. Berrange |
c476c8 |
- read-write mode for management, and we require user password -->
|
|
Daniel P. Berrange |
c476c8 |
- <allow_any>no</allow_any>
|
|
Daniel P. Berrange |
c476c8 |
- <allow_inactive>no</allow_inactive>
|
|
Daniel P. Berrange |
c476c8 |
- <allow_active>auth_admin_keep_session</allow_active>
|
|
Daniel P. Berrange |
c476c8 |
- </defaults>
|
|
Daniel P. Berrange |
c476c8 |
- </action>
|
|
Daniel P. Berrange |
c476c8 |
-</policyconfig>
|
|
Mark McLoughlin |
da05e0 |
diff --git a/qemud/libvirtd.policy-0 b/qemud/libvirtd.policy-0
|
|
Mark McLoughlin |
da05e0 |
new file mode 100644
|
|
Mark McLoughlin |
da05e0 |
index 0000000..b6da946
|
|
Mark McLoughlin |
da05e0 |
--- /dev/null
|
|
Mark McLoughlin |
da05e0 |
+++ b/qemud/libvirtd.policy-0
|
|
Daniel P. Berrange |
c476c8 |
@@ -0,0 +1,42 @@
|
|
Daniel P. Berrange |
c476c8 |
+
|
|
Daniel P. Berrange |
c476c8 |
+ "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
|
|
Daniel P. Berrange |
c476c8 |
+ "http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd">
|
|
Daniel P. Berrange |
c476c8 |
+
|
|
Daniel P. Berrange |
c476c8 |
+
|
|
Daniel P. Berrange |
c476c8 |
+Policy definitions for libvirt daemon
|
|
Daniel P. Berrange |
c476c8 |
+
|
|
Daniel P. Berrange |
c476c8 |
+Copyright (c) 2007 Daniel P. Berrange <berrange redhat com>
|
|
Daniel P. Berrange |
c476c8 |
+
|
|
Daniel P. Berrange |
c476c8 |
+libvirt is licensed to you under the GNU Lesser General Public License
|
|
Daniel P. Berrange |
c476c8 |
+version 2. See COPYING for details.
|
|
Daniel P. Berrange |
c476c8 |
+
|
|
Daniel P. Berrange |
c476c8 |
+NOTE: If you make changes to this file, make sure to validate the file
|
|
Daniel P. Berrange |
c476c8 |
+using the polkit-policy-file-validate(1) tool. Changes made to this
|
|
Daniel P. Berrange |
c476c8 |
+file are instantly applied.
|
|
Daniel P. Berrange |
c476c8 |
+-->
|
|
Daniel P. Berrange |
c476c8 |
+
|
|
Daniel P. Berrange |
c476c8 |
+<policyconfig>
|
|
Daniel P. Berrange |
c476c8 |
+ <action id="org.libvirt.unix.monitor">
|
|
Daniel P. Berrange |
c476c8 |
+ <description>Monitor local virtualized systems</description>
|
|
Daniel P. Berrange |
c476c8 |
+ <message>System policy prevents monitoring of local virtualized systems</message>
|
|
Daniel P. Berrange |
c476c8 |
+ <defaults>
|
|
Daniel P. Berrange |
c476c8 |
+
|
|
Daniel P. Berrange |
c476c8 |
+ even if not part of a session -->
|
|
Daniel P. Berrange |
c476c8 |
+ <allow_any>yes</allow_any>
|
|
Daniel P. Berrange |
c476c8 |
+ <allow_inactive>yes</allow_inactive>
|
|
Daniel P. Berrange |
c476c8 |
+ <allow_active>yes</allow_active>
|
|
Daniel P. Berrange |
c476c8 |
+ </defaults>
|
|
Daniel P. Berrange |
c476c8 |
+ </action>
|
|
Daniel P. Berrange |
c476c8 |
+
|
|
Daniel P. Berrange |
c476c8 |
+ <action id="org.libvirt.unix.manage">
|
|
Daniel P. Berrange |
c476c8 |
+ <description>Manage local virtualized systems</description>
|
|
Daniel P. Berrange |
c476c8 |
+ <message>System policy prevents management of local virtualized systems</message>
|
|
Daniel P. Berrange |
c476c8 |
+ <defaults>
|
|
Daniel P. Berrange |
c476c8 |
+
|
|
Daniel P. Berrange |
c476c8 |
+ read-write mode for management, and we require user password -->
|
|
Daniel P. Berrange |
c476c8 |
+ <allow_any>no</allow_any>
|
|
Daniel P. Berrange |
c476c8 |
+ <allow_inactive>no</allow_inactive>
|
|
Daniel P. Berrange |
c476c8 |
+ <allow_active>auth_admin_keep_session</allow_active>
|
|
Daniel P. Berrange |
c476c8 |
+ </defaults>
|
|
Daniel P. Berrange |
c476c8 |
+ </action>
|
|
Daniel P. Berrange |
c476c8 |
+</policyconfig>
|
|
Mark McLoughlin |
da05e0 |
diff --git a/qemud/libvirtd.policy-1 b/qemud/libvirtd.policy-1
|
|
Mark McLoughlin |
da05e0 |
new file mode 100644
|
|
Mark McLoughlin |
da05e0 |
index 0000000..6fa3a5e
|
|
Mark McLoughlin |
da05e0 |
--- /dev/null
|
|
Mark McLoughlin |
da05e0 |
+++ b/qemud/libvirtd.policy-1
|
|
Daniel P. Berrange |
c476c8 |
@@ -0,0 +1,42 @@
|
|
Daniel P. Berrange |
c476c8 |
+
|
|
Daniel P. Berrange |
c476c8 |
+ "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
|
|
Daniel P. Berrange |
c476c8 |
+ "http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd">
|
|
Daniel P. Berrange |
c476c8 |
+
|
|
Daniel P. Berrange |
c476c8 |
+
|
|
Daniel P. Berrange |
c476c8 |
+Policy definitions for libvirt daemon
|
|
Daniel P. Berrange |
c476c8 |
+
|
|
Daniel P. Berrange |
c476c8 |
+Copyright (c) 2007 Daniel P. Berrange <berrange redhat com>
|
|
Daniel P. Berrange |
c476c8 |
+
|
|
Daniel P. Berrange |
c476c8 |
+libvirt is licensed to you under the GNU Lesser General Public License
|
|
Daniel P. Berrange |
c476c8 |
+version 2. See COPYING for details.
|
|
Daniel P. Berrange |
c476c8 |
+
|
|
Daniel P. Berrange |
c476c8 |
+NOTE: If you make changes to this file, make sure to validate the file
|
|
Daniel P. Berrange |
c476c8 |
+using the polkit-policy-file-validate(1) tool. Changes made to this
|
|
Daniel P. Berrange |
c476c8 |
+file are instantly applied.
|
|
Daniel P. Berrange |
c476c8 |
+-->
|
|
Daniel P. Berrange |
c476c8 |
+
|
|
Daniel P. Berrange |
c476c8 |
+<policyconfig>
|
|
Daniel P. Berrange |
c476c8 |
+ <action id="org.libvirt.unix.monitor">
|
|
Daniel P. Berrange |
c476c8 |
+ <description>Monitor local virtualized systems</description>
|
|
Daniel P. Berrange |
c476c8 |
+ <message>System policy prevents monitoring of local virtualized systems</message>
|
|
Daniel P. Berrange |
c476c8 |
+ <defaults>
|
|
Daniel P. Berrange |
c476c8 |
+
|
|
Daniel P. Berrange |
c476c8 |
+ even if not part of a session -->
|
|
Daniel P. Berrange |
c476c8 |
+ <allow_any>yes</allow_any>
|
|
Daniel P. Berrange |
c476c8 |
+ <allow_inactive>yes</allow_inactive>
|
|
Daniel P. Berrange |
c476c8 |
+ <allow_active>yes</allow_active>
|
|
Daniel P. Berrange |
c476c8 |
+ </defaults>
|
|
Daniel P. Berrange |
c476c8 |
+ </action>
|
|
Daniel P. Berrange |
c476c8 |
+
|
|
Daniel P. Berrange |
c476c8 |
+ <action id="org.libvirt.unix.manage">
|
|
Daniel P. Berrange |
c476c8 |
+ <description>Manage local virtualized systems</description>
|
|
Daniel P. Berrange |
c476c8 |
+ <message>System policy prevents management of local virtualized systems</message>
|
|
Daniel P. Berrange |
c476c8 |
+ <defaults>
|
|
Daniel P. Berrange |
c476c8 |
+
|
|
Daniel P. Berrange |
c476c8 |
+ read-write mode for management, and we require user password -->
|
|
Daniel P. Berrange |
c476c8 |
+ <allow_any>no</allow_any>
|
|
Daniel P. Berrange |
c476c8 |
+ <allow_inactive>no</allow_inactive>
|
|
Daniel P. Berrange |
c476c8 |
+ <allow_active>auth_admin_keep</allow_active>
|
|
Daniel P. Berrange |
c476c8 |
+ </defaults>
|
|
Daniel P. Berrange |
c476c8 |
+ </action>
|
|
Daniel P. Berrange |
c476c8 |
+</policyconfig>
|
|
Mark McLoughlin |
da05e0 |
diff --git a/qemud/qemud.c b/qemud/qemud.c
|
|
Mark McLoughlin |
da05e0 |
index 3e551ca..50b0cdd 100644
|
|
Mark McLoughlin |
da05e0 |
--- a/qemud/qemud.c
|
|
Mark McLoughlin |
da05e0 |
+++ b/qemud/qemud.c
|
|
Mark McLoughlin |
da05e0 |
@@ -895,7 +895,7 @@ static struct qemud_server *qemudNetworkInit(struct qemud_server *server) {
|
|
Daniel P. Berrange |
c476c8 |
}
|
|
Daniel P. Berrange |
c476c8 |
#endif
|
|
Daniel P. Berrange |
c476c8 |
|
|
Daniel P. Berrange |
c476c8 |
-#ifdef HAVE_POLKIT
|
|
Daniel P. Berrange |
c476c8 |
+#if HAVE_POLKIT0
|
|
Daniel P. Berrange |
c476c8 |
if (auth_unix_rw == REMOTE_AUTH_POLKIT ||
|
|
Daniel P. Berrange |
c476c8 |
auth_unix_ro == REMOTE_AUTH_POLKIT) {
|
|
Daniel P. Berrange |
c476c8 |
DBusError derr;
|
|
Mark McLoughlin |
da05e0 |
@@ -982,7 +982,7 @@ static struct qemud_server *qemudNetworkInit(struct qemud_server *server) {
|
|
Daniel P. Berrange |
c476c8 |
sock = sock->next;
|
|
Daniel P. Berrange |
c476c8 |
}
|
|
Daniel P. Berrange |
c476c8 |
|
|
Daniel P. Berrange |
c476c8 |
-#ifdef HAVE_POLKIT
|
|
Daniel P. Berrange |
c476c8 |
+#if HAVE_POLKIT0
|
|
Daniel P. Berrange |
c476c8 |
if (server->sysbus)
|
|
Daniel P. Berrange |
c476c8 |
dbus_connection_unref(server->sysbus);
|
|
Daniel P. Berrange |
c476c8 |
#endif
|
|
Mark McLoughlin |
da05e0 |
diff --git a/qemud/qemud.h b/qemud/qemud.h
|
|
Mark McLoughlin |
da05e0 |
index 254db44..e8ce209 100644
|
|
Mark McLoughlin |
da05e0 |
--- a/qemud/qemud.h
|
|
Mark McLoughlin |
da05e0 |
+++ b/qemud/qemud.h
|
|
Daniel P. Berrange |
c476c8 |
@@ -34,7 +34,7 @@
|
|
Daniel P. Berrange |
c476c8 |
#include <sasl/sasl.h>
|
|
Daniel P. Berrange |
c476c8 |
#endif
|
|
Daniel P. Berrange |
c476c8 |
|
|
Daniel P. Berrange |
c476c8 |
-#ifdef HAVE_POLKIT
|
|
Daniel P. Berrange |
c476c8 |
+#if HAVE_POLKIT0
|
|
Daniel P. Berrange |
c476c8 |
#include <dbus/dbus.h>
|
|
Daniel P. Berrange |
c476c8 |
#endif
|
|
Daniel P. Berrange |
c476c8 |
|
|
Daniel P. Berrange |
c476c8 |
@@ -253,7 +253,7 @@ struct qemud_server {
|
|
Daniel P. Berrange |
c476c8 |
#if HAVE_SASL
|
|
Daniel P. Berrange |
c476c8 |
char **saslUsernameWhitelist;
|
|
Daniel P. Berrange |
c476c8 |
#endif
|
|
Daniel P. Berrange |
c476c8 |
-#if HAVE_POLKIT
|
|
Daniel P. Berrange |
c476c8 |
+#if HAVE_POLKIT0
|
|
Daniel P. Berrange |
c476c8 |
DBusConnection *sysbus;
|
|
Daniel P. Berrange |
c476c8 |
#endif
|
|
Daniel P. Berrange |
c476c8 |
};
|
|
Mark McLoughlin |
da05e0 |
diff --git a/qemud/remote.c b/qemud/remote.c
|
|
Mark McLoughlin |
da05e0 |
index d32d513..490a807 100644
|
|
Mark McLoughlin |
da05e0 |
--- a/qemud/remote.c
|
|
Mark McLoughlin |
da05e0 |
+++ b/qemud/remote.c
|
|
Daniel P. Berrange |
c476c8 |
@@ -43,7 +43,7 @@
|
|
Daniel P. Berrange |
c476c8 |
#include <fnmatch.h>
|
|
Daniel P. Berrange |
c476c8 |
#include "virterror_internal.h"
|
|
Daniel P. Berrange |
c476c8 |
|
|
Daniel P. Berrange |
c476c8 |
-#ifdef HAVE_POLKIT
|
|
Daniel P. Berrange |
c476c8 |
+#if HAVE_POLKIT0
|
|
Daniel P. Berrange |
c476c8 |
#include <polkit/polkit.h>
|
|
Daniel P. Berrange |
c476c8 |
#include <polkit-dbus/polkit-dbus.h>
|
|
Daniel P. Berrange |
c476c8 |
#endif
|
|
Mark McLoughlin |
da05e0 |
@@ -3106,7 +3106,80 @@ remoteDispatchAuthSaslStep (struct qemud_server *server ATTRIBUTE_UNUSED,
|
|
Daniel P. Berrange |
c476c8 |
#endif /* HAVE_SASL */
|
|
Daniel P. Berrange |
c476c8 |
|
|
Daniel P. Berrange |
c476c8 |
|
|
Daniel P. Berrange |
c476c8 |
-#if HAVE_POLKIT
|
|
Daniel P. Berrange |
c476c8 |
+#if HAVE_POLKIT1
|
|
Daniel P. Berrange |
c476c8 |
+static int
|
|
Daniel P. Berrange |
c476c8 |
+remoteDispatchAuthPolkit (struct qemud_server *server,
|
|
Daniel P. Berrange |
c476c8 |
+ struct qemud_client *client,
|
|
Daniel P. Berrange |
c476c8 |
+ virConnectPtr conn ATTRIBUTE_UNUSED,
|
|
Daniel P. Berrange |
c476c8 |
+ remote_error *rerr,
|
|
Daniel P. Berrange |
c476c8 |
+ void *args ATTRIBUTE_UNUSED,
|
|
Daniel P. Berrange |
c476c8 |
+ remote_auth_polkit_ret *ret)
|
|
Daniel P. Berrange |
c476c8 |
+{
|
|
Daniel P. Berrange |
c476c8 |
+ pid_t callerPid;
|
|
Daniel P. Berrange |
c476c8 |
+ uid_t callerUid;
|
|
Daniel P. Berrange |
c476c8 |
+ const char *action;
|
|
Daniel P. Berrange |
c476c8 |
+ int status = -1;
|
|
Daniel P. Berrange |
c476c8 |
+ char pidbuf[50];
|
|
Daniel P. Berrange |
c476c8 |
+ int rv;
|
|
Daniel P. Berrange |
c476c8 |
+
|
|
Daniel P. Berrange |
c476c8 |
+ virMutexLock(&server->lock);
|
|
Daniel P. Berrange |
c476c8 |
+ virMutexLock(&client->lock);
|
|
Daniel P. Berrange |
c476c8 |
+ virMutexUnlock(&server->lock);
|
|
Daniel P. Berrange |
c476c8 |
+
|
|
Daniel P. Berrange |
c476c8 |
+ action = client->readonly ?
|
|
Daniel P. Berrange |
c476c8 |
+ "org.libvirt.unix.monitor" :
|
|
Daniel P. Berrange |
c476c8 |
+ "org.libvirt.unix.manage";
|
|
Daniel P. Berrange |
c476c8 |
+
|
|
Daniel P. Berrange |
c476c8 |
+ const char * const pkcheck [] = {
|
|
Daniel P. Berrange |
c476c8 |
+ PKCHECK_PATH,
|
|
Daniel P. Berrange |
c476c8 |
+ "--action-id", action,
|
|
Daniel P. Berrange |
c476c8 |
+ "--process", pidbuf,
|
|
Daniel P. Berrange |
c476c8 |
+ "--allow-user-interaction",
|
|
Daniel P. Berrange |
c476c8 |
+ NULL
|
|
Daniel P. Berrange |
c476c8 |
+ };
|
|
Daniel P. Berrange |
c476c8 |
+
|
|
Daniel P. Berrange |
c476c8 |
+ REMOTE_DEBUG("Start PolicyKit auth %d", client->fd);
|
|
Daniel P. Berrange |
c476c8 |
+ if (client->auth != REMOTE_AUTH_POLKIT) {
|
|
Daniel P. Berrange |
c476c8 |
+ VIR_ERROR0(_("client tried invalid PolicyKit init request"));
|
|
Daniel P. Berrange |
c476c8 |
+ goto authfail;
|
|
Daniel P. Berrange |
c476c8 |
+ }
|
|
Daniel P. Berrange |
c476c8 |
+
|
|
Daniel P. Berrange |
c476c8 |
+ if (qemudGetSocketIdentity(client->fd, &callerUid, &callerPid) < 0) {
|
|
Daniel P. Berrange |
c476c8 |
+ VIR_ERROR0(_("cannot get peer socket identity"));
|
|
Daniel P. Berrange |
c476c8 |
+ goto authfail;
|
|
Daniel P. Berrange |
c476c8 |
+ }
|
|
Daniel P. Berrange |
c476c8 |
+
|
|
Daniel P. Berrange |
c476c8 |
+ VIR_INFO(_("Checking PID %d running as %d"), callerPid, callerUid);
|
|
Daniel P. Berrange |
c476c8 |
+
|
|
Daniel P. Berrange |
c476c8 |
+ rv = snprintf(pidbuf, sizeof pidbuf, "%d", callerPid);
|
|
Daniel P. Berrange |
c476c8 |
+ if (rv < 0 || rv >= sizeof pidbuf) {
|
|
Daniel P. Berrange |
c476c8 |
+ VIR_ERROR(_("Caller PID was too large %d"), callerPid);
|
|
Daniel P. Berrange |
c476c8 |
+ goto authfail;
|
|
Daniel P. Berrange |
c476c8 |
+ }
|
|
Daniel P. Berrange |
c476c8 |
+
|
|
Daniel P. Berrange |
c476c8 |
+ if (virRun(NULL, pkcheck, &status) < 0) {
|
|
Daniel P. Berrange |
c476c8 |
+ VIR_ERROR(_("Cannot invoke %s"), PKCHECK_PATH);
|
|
Daniel P. Berrange |
c476c8 |
+ goto authfail;
|
|
Daniel P. Berrange |
c476c8 |
+ }
|
|
Daniel P. Berrange |
c476c8 |
+ if (status != 0) {
|
|
Daniel P. Berrange |
c476c8 |
+ VIR_ERROR(_("Policy kit denied action %s from pid %d, uid %d, result: %d\n"),
|
|
Daniel P. Berrange |
c476c8 |
+ action, callerPid, callerUid, status);
|
|
Daniel P. Berrange |
c476c8 |
+ goto authfail;
|
|
Daniel P. Berrange |
c476c8 |
+ }
|
|
Daniel P. Berrange |
c476c8 |
+ VIR_INFO(_("Policy allowed action %s from pid %d, uid %d"),
|
|
Daniel P. Berrange |
c476c8 |
+ action, callerPid, callerUid);
|
|
Daniel P. Berrange |
c476c8 |
+ ret->complete = 1;
|
|
Daniel P. Berrange |
c476c8 |
+ client->auth = REMOTE_AUTH_NONE;
|
|
Daniel P. Berrange |
c476c8 |
+
|
|
Daniel P. Berrange |
c476c8 |
+ virMutexUnlock(&client->lock);
|
|
Daniel P. Berrange |
c476c8 |
+ return 0;
|
|
Daniel P. Berrange |
c476c8 |
+
|
|
Daniel P. Berrange |
c476c8 |
+authfail:
|
|
Daniel P. Berrange |
c476c8 |
+ remoteDispatchAuthError(rerr);
|
|
Daniel P. Berrange |
c476c8 |
+ virMutexUnlock(&client->lock);
|
|
Daniel P. Berrange |
c476c8 |
+ return -1;
|
|
Daniel P. Berrange |
c476c8 |
+}
|
|
Daniel P. Berrange |
c476c8 |
+#elif HAVE_POLKIT0
|
|
Daniel P. Berrange |
c476c8 |
static int
|
|
Daniel P. Berrange |
c476c8 |
remoteDispatchAuthPolkit (struct qemud_server *server,
|
|
Daniel P. Berrange |
c476c8 |
struct qemud_client *client,
|
|
Daniel P. Berrange |
c476c8 |
@@ -3217,7 +3290,7 @@ authfail:
|
|
Daniel P. Berrange |
c476c8 |
return -1;
|
|
Daniel P. Berrange |
c476c8 |
}
|
|
Daniel P. Berrange |
c476c8 |
|
|
Daniel P. Berrange |
c476c8 |
-#else /* HAVE_POLKIT */
|
|
Daniel P. Berrange |
c476c8 |
+#else /* !HAVE_POLKIT0 & !HAVE_POLKIT1*/
|
|
Daniel P. Berrange |
c476c8 |
|
|
Daniel P. Berrange |
c476c8 |
static int
|
|
Daniel P. Berrange |
c476c8 |
remoteDispatchAuthPolkit (struct qemud_server *server ATTRIBUTE_UNUSED,
|
|
Mark McLoughlin |
da05e0 |
@@ -3231,7 +3304,7 @@ remoteDispatchAuthPolkit (struct qemud_server *server ATTRIBUTE_UNUSED,
|
|
Daniel P. Berrange |
c476c8 |
remoteDispatchAuthError(rerr);
|
|
Daniel P. Berrange |
c476c8 |
return -1;
|
|
Daniel P. Berrange |
c476c8 |
}
|
|
Daniel P. Berrange |
c476c8 |
-#endif /* HAVE_POLKIT */
|
|
Daniel P. Berrange |
c476c8 |
+#endif /* HAVE_POLKIT1 */
|
|
Daniel P. Berrange |
c476c8 |
|
|
Daniel P. Berrange |
c476c8 |
|
|
Daniel P. Berrange |
c476c8 |
/***************************************************************
|
|
Mark McLoughlin |
da05e0 |
diff --git a/src/remote_internal.c b/src/remote_internal.c
|
|
Mark McLoughlin |
da05e0 |
index a58b768..e98c99b 100644
|
|
Mark McLoughlin |
da05e0 |
--- a/src/remote_internal.c
|
|
Mark McLoughlin |
da05e0 |
+++ b/src/remote_internal.c
|
|
Mark McLoughlin |
da05e0 |
@@ -6201,6 +6201,7 @@ remoteAuthPolkit (virConnectPtr conn, struct private_data *priv, int in_open,
|
|
Daniel P. Berrange |
c476c8 |
virConnectAuthPtr auth)
|
|
Daniel P. Berrange |
c476c8 |
{
|
|
Daniel P. Berrange |
c476c8 |
remote_auth_polkit_ret ret;
|
|
Daniel P. Berrange |
c476c8 |
+#if HAVE_POLKIT0
|
|
Daniel P. Berrange |
c476c8 |
int i, allowcb = 0;
|
|
Daniel P. Berrange |
c476c8 |
virConnectCredential cred = {
|
|
Daniel P. Berrange |
c476c8 |
VIR_CRED_EXTERNAL,
|
|
Mark McLoughlin |
da05e0 |
@@ -6210,8 +6211,10 @@ remoteAuthPolkit (virConnectPtr conn, struct private_data *priv, int in_open,
|
|
Daniel P. Berrange |
c476c8 |
NULL,
|
|
Daniel P. Berrange |
c476c8 |
0,
|
|
Daniel P. Berrange |
c476c8 |
};
|
|
Daniel P. Berrange |
c476c8 |
+#endif
|
|
Daniel P. Berrange |
c476c8 |
DEBUG0("Client initialize PolicyKit authentication");
|
|
Daniel P. Berrange |
c476c8 |
|
|
Daniel P. Berrange |
c476c8 |
+#if HAVE_POLKIT0
|
|
Daniel P. Berrange |
c476c8 |
if (auth && auth->cb) {
|
|
Daniel P. Berrange |
c476c8 |
/* Check if the necessary credential type for PolicyKit is supported */
|
|
Daniel P. Berrange |
c476c8 |
for (i = 0 ; i < auth->ncredtype ; i++) {
|
|
Mark McLoughlin |
da05e0 |
@@ -6220,6 +6223,7 @@ remoteAuthPolkit (virConnectPtr conn, struct private_data *priv, int in_open,
|
|
Daniel P. Berrange |
c476c8 |
}
|
|
Daniel P. Berrange |
c476c8 |
|
|
Daniel P. Berrange |
c476c8 |
if (allowcb) {
|
|
Daniel P. Berrange |
c476c8 |
+ DEBUG0("Client run callback for PolicyKit authentication");
|
|
Daniel P. Berrange |
c476c8 |
/* Run the authentication callback */
|
|
Daniel P. Berrange |
c476c8 |
if ((*(auth->cb))(&cred, 1, auth->cbdata) < 0) {
|
|
Daniel P. Berrange |
c476c8 |
virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE,
|
|
Mark McLoughlin |
da05e0 |
@@ -6233,6 +6237,9 @@ remoteAuthPolkit (virConnectPtr conn, struct private_data *priv, int in_open,
|
|
Daniel P. Berrange |
c476c8 |
} else {
|
|
Daniel P. Berrange |
c476c8 |
DEBUG0("No auth callback provided");
|
|
Daniel P. Berrange |
c476c8 |
}
|
|
Daniel P. Berrange |
c476c8 |
+#else
|
|
Daniel P. Berrange |
c476c8 |
+ DEBUG0("No auth callback required for PolicyKit-1");
|
|
Daniel P. Berrange |
c476c8 |
+#endif
|
|
Daniel P. Berrange |
c476c8 |
|
|
Daniel P. Berrange |
c476c8 |
memset (&ret, 0, sizeof ret);
|
|
Daniel P. Berrange |
c476c8 |
if (call (conn, priv, in_open, REMOTE_PROC_AUTH_POLKIT,
|
|
Mark McLoughlin |
da05e0 |
--
|
|
Mark McLoughlin |
da05e0 |
1.6.2.5
|
|
Mark McLoughlin |
da05e0 |
|