aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>2005-06-10 15:18:00 +0000
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>2005-06-10 15:18:00 +0000
commitf2e3420e7337a878e984ec5a906cb9267bfc23c0 (patch)
treea23fc27960a5d44acb3a5a69480578cfb49cf815
parentcaac1f78197747509f2003568a3ac283f635d29f (diff)
downloadxen-f2e3420e7337a878e984ec5a906cb9267bfc23c0.tar.gz
xen-f2e3420e7337a878e984ec5a906cb9267bfc23c0.tar.bz2
xen-f2e3420e7337a878e984ec5a906cb9267bfc23c0.zip
bitkeeper revision 1.1705.1.15 (42a9af28Mzva9Shzn8gUSiuJSM-TbA)
xenstore fixes for read-only connections.
-rw-r--r--tools/xenstore/xenstored_core.c16
-rw-r--r--tools/xenstore/xenstored_core.h3
-rw-r--r--tools/xenstore/xenstored_domain.c3
-rw-r--r--tools/xenstore/xs_test.c4
4 files changed, 20 insertions, 6 deletions
diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c
index b1ce20a554..1df00f37b4 100644
--- a/tools/xenstore/xenstored_core.c
+++ b/tools/xenstore/xenstored_core.c
@@ -617,7 +617,7 @@ bool check_node_perms(struct connection *conn, const char *node,
return false;
}
- if (!conn->write && (perm & XS_PERM_WRITE)) {
+ if (!conn->can_write && (perm & XS_PERM_WRITE)) {
errno = EROFS;
return false;
}
@@ -938,6 +938,12 @@ static bool process_message(struct connection *conn, struct buffered_data *in)
return do_set_perms(conn, in);
case XS_SHUTDOWN:
+ /* FIXME: Implement gentle shutdown too. */
+ /* Only tools can do this. */
+ if (conn->id != 0)
+ return send_error(conn, EACCES);
+ if (!conn->can_write)
+ return send_error(conn, EROFS);
send_ack(conn, XS_SHUTDOWN);
/* Everything hangs off auto-free context, freed at exit. */
exit(0);
@@ -1137,6 +1143,7 @@ struct connection *new_connection(connwritefn_t *write, connreadfn_t *read)
new->transaction = NULL;
new->write = write;
new->read = read;
+ new->can_write = true;
talloc_set_fail_handler(out_of_mem, &talloc_fail);
if (setjmp(talloc_fail)) {
@@ -1170,10 +1177,11 @@ static void accept_connection(int sock, bool canwrite)
if (fd < 0)
return;
- conn = new_connection(canwrite ? writefd : NULL, readfd);
- if (conn)
+ conn = new_connection(writefd, readfd);
+ if (conn) {
conn->fd = fd;
- else
+ conn->can_write = canwrite;
+ } else
close(fd);
}
diff --git a/tools/xenstore/xenstored_core.h b/tools/xenstore/xenstored_core.h
index fe6eec8f72..0d0ebcaae0 100644
--- a/tools/xenstore/xenstored_core.h
+++ b/tools/xenstore/xenstored_core.h
@@ -56,6 +56,9 @@ struct connection
/* Are we blocked waiting for a transaction to end? Contains node. */
char *blocked;
+ /* Is this a read-only connection? */
+ bool can_write;
+
/* Our current event. If all used, we're waiting for ack. */
struct watch_event *event;
diff --git a/tools/xenstore/xenstored_domain.c b/tools/xenstore/xenstored_domain.c
index bcc0a64967..a6f69ddf5b 100644
--- a/tools/xenstore/xenstored_domain.c
+++ b/tools/xenstore/xenstored_domain.c
@@ -268,6 +268,9 @@ bool do_introduce(struct connection *conn, struct buffered_data *in)
if (get_strings(in, vec, ARRAY_SIZE(vec)) < ARRAY_SIZE(vec))
return send_error(conn, EINVAL);
+ if (!conn->can_write)
+ return send_error(conn, EROFS);
+
/* Hang domain off "in" until we're finished. */
domain = talloc(in, struct domain);
domain->domid = atoi(vec[0]);
diff --git a/tools/xenstore/xs_test.c b/tools/xenstore/xs_test.c
index 74f5e5e649..4d769e220d 100644
--- a/tools/xenstore/xs_test.c
+++ b/tools/xenstore/xs_test.c
@@ -176,11 +176,11 @@ static void __attribute__((noreturn)) usage(void)
" watch <path> <prio>\n"
" waitwatch\n"
" ackwatch\n"
- " unwatch <path>\n"
+ " unwatch <path> <token>\n"
" close\n"
" start <node>\n"
" abort\n"
- " introduce <domid> <mfn> <eventchn>\n"
+ " introduce <domid> <mfn> <eventchn> <path>\n"
" commit\n"
" sleep <seconds>\n"
" dump\n");