WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Always allow overriding where clients connect through XE

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Always allow overriding where clients connect through XENSTORED_PATH.
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 12 Sep 2005 21:42:10 +0000
Delivery-date: Mon, 12 Sep 2005 21:40:41 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User cl349@xxxxxxxxxxxxxxxxxxxx
# Node ID d8637529dafff3c610e4bb31349d4ae00a23a18e
# Parent  80afc502461b56539092dec5c1fa6df05df8baf2
Always allow overriding where clients connect through XENSTORED_PATH.
Detect if we're connecting to a socket or to the domain device and
open accordingly.
Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>

diff -r 80afc502461b -r d8637529daff tools/xenstore/xs.c
--- a/tools/xenstore/xs.c       Mon Sep 12 21:12:16 2005
+++ b/tools/xenstore/xs.c       Mon Sep 12 21:42:26 2005
@@ -97,19 +97,32 @@
        return NULL;
 }
 
+static struct xs_handle *get_handle(const char *connect_to)
+{
+       struct stat buf;
+
+       if (stat(connect_to, &buf) != 0)
+               return NULL;
+
+       if (S_ISSOCK(buf.st_mode))
+               return get_socket(connect_to);
+       else
+               return get_dev(connect_to);
+}
+
 struct xs_handle *xs_daemon_open(void)
 {
-       return get_socket(xs_daemon_socket());
+       return get_handle(xs_daemon_socket());
 }
 
 struct xs_handle *xs_daemon_open_readonly(void)
 {
-       return get_socket(xs_daemon_socket_ro());
+       return get_handle(xs_daemon_socket_ro());
 }
 
 struct xs_handle *xs_domain_open(void)
 {
-       return get_dev(xs_domain_dev());
+       return get_handle(xs_domain_dev());
 }
 
 void xs_daemon_close(struct xs_handle *h)
diff -r 80afc502461b -r d8637529daff tools/xenstore/xs_lib.c
--- a/tools/xenstore/xs_lib.c   Mon Sep 12 21:12:16 2005
+++ b/tools/xenstore/xs_lib.c   Mon Sep 12 21:42:26 2005
@@ -38,37 +38,55 @@
        return (s ? s : "/var/run/xenstored");
 }
 
+static const char *xs_daemon_path(void)
+{
+       static char buf[PATH_MAX];
+       char *s = getenv("XENSTORED_PATH");
+       if (s)
+               return s;
+       if (snprintf(buf, PATH_MAX, "%s/socket",
+                    xs_daemon_rundir()) >= PATH_MAX)
+               return NULL;
+       return buf;
+}
+
 const char *xs_daemon_socket(void)
 {
-       static char buf[PATH_MAX];
-       sprintf(buf, "%s/socket", xs_daemon_rundir());
-       return buf;
+       return xs_daemon_path();
 }
 
 const char *xs_daemon_socket_ro(void)
 {
        static char buf[PATH_MAX];
-       sprintf(buf, "%s/socket_ro", xs_daemon_rundir());
+       const char *s = xs_daemon_path();
+       if (s == NULL)
+               return NULL;
+       if (snprintf(buf, PATH_MAX, "%s_ro", s) >= PATH_MAX)
+               return NULL;
        return buf;
 }
 
 const char *xs_daemon_store(void)
 {
        static char buf[PATH_MAX];
-       sprintf(buf, "%s/store", xs_daemon_rootdir());
+       if (snprintf(buf, PATH_MAX, "%s/store",
+                    xs_daemon_rootdir()) >= PATH_MAX)
+               return NULL;
        return buf;
 }
 
 const char *xs_daemon_transactions(void)
 {
        static char buf[PATH_MAX];
-       sprintf(buf, "%s/transactions", xs_daemon_rootdir());
+       if (snprintf(buf, PATH_MAX, "%s/transactions",
+                    xs_daemon_rootdir()) >= PATH_MAX)
+               return NULL;
        return buf;
 }
 
 const char *xs_domain_dev(void)
 {
-       char *s = getenv("XENSTORED_DOMAIN_DEV");
+       char *s = getenv("XENSTORED_PATH");
        return (s ? s : "/proc/xen/xenbus");
 }
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Always allow overriding where clients connect through XENSTORED_PATH., Xen patchbot -unstable <=