[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libvir] [PATCH] fixes when running as user or in tree tests



  The following patches does 3 things which correct annoyances when
running as an user or when running from a tree built with --prefix=/usr
   - avoid error message when non-root cannot open xenstore
   - avoid error message when non-root cannot directly access xend
in those two cases the proxy (or remote code) should implement the access
so there is no need to raise the error there.
   - when configuring with --prefix=/usr i.e. the same prefix as the
     installed libvirt, use the same localstatedir /var (instead of
     /usr/var) and sysconfdir /etc (instead of /usr/etc) to be able to
     connect to the system daemon, and use the system local options

Daniel


-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/
Index: configure.in
===================================================================
RCS file: /data/cvs/libxen/configure.in,v
retrieving revision 1.90
diff -u -r1.90 configure.in
--- configure.in	30 Sep 2007 21:09:29 -0000	1.90
+++ configure.in	23 Nov 2007 15:55:54 -0000
@@ -77,6 +77,18 @@
             [HTML_DIR="$HTML_DIR/\$(PACKAGE)-\$(VERSION)/html"])
 AC_SUBST(HTML_DIR)
 
+dnl if --prefix is /usr, don't use /usr/var for localstatedir
+dnl or /usr/etc for sysconfdir
+dnl as this makes a lot of things break in testing situations
+
+if test $prefix = "/usr" -a $localstatedir = '${prefix}/var' ; then
+    localstatedir='/var'
+fi
+if test $prefix = "/usr" -a $sysconfdir = '${prefix}/etc' ; then
+    sysconfdir='/etc'
+fi
+
+
 dnl Allow to build without Xen, QEMU/KVM, test or remote driver
 AC_ARG_WITH(xen,
 [  --with-xen              add XEN support (on)],[],[with_xen=yes])
Index: src/xend_internal.c
===================================================================
RCS file: /data/cvs/libxen/src/xend_internal.c,v
retrieving revision 1.154
diff -u -r1.154 xend_internal.c
--- src/xend_internal.c	14 Nov 2007 11:40:57 -0000	1.154
+++ src/xend_internal.c	23 Nov 2007 15:55:54 -0000
@@ -232,8 +232,15 @@
         close(s);
         errno = serrno;
         s = -1;
-        virXendError(xend, VIR_ERR_INTERNAL_ERROR,
-                     "failed to connect to xend");
+	/*
+	 * not being able to connect via the socket as a normal user
+	 * is rather normal, this should fallback to the proxy (or
+	 * remote) mechanism.
+	 */
+	if ((getuid() == 0) || (xend->flags & VIR_DRV_OPEN_RO)) {
+	    virXendError(xend, VIR_ERR_INTERNAL_ERROR,
+			 "failed to connect to xend");
+        }
     }
 
     return s;
Index: src/xs_internal.c
===================================================================
RCS file: /data/cvs/libxen/src/xs_internal.c,v
retrieving revision 1.54
diff -u -r1.54 xs_internal.c
--- src/xs_internal.c	20 Nov 2007 18:57:41 -0000	1.54
+++ src/xs_internal.c	23 Nov 2007 15:55:54 -0000
@@ -341,8 +341,15 @@
 #endif /* ! PROXY */
 
     if (priv->xshandle == NULL) {
-        virXenStoreError(NULL, VIR_ERR_NO_XEN, 
-	                     _("failed to connect to Xen Store"));
+	/*
+         * not being able to connect via the socket as a normal user
+         * is rather normal, this should fallback to the proxy (or
+         * remote) mechanism.
+	 */
+        if (getuid() == 0) {
+	    virXenStoreError(NULL, VIR_ERR_NO_XEN, 
+				 _("failed to connect to Xen Store"));
+	}
         return (-1);
     }
     return (0);

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]