ChangeSet 1.1720, 2005/06/10 16:18:00+01:00, kaf24@xxxxxxxxxxxxxxxxxxxx
xenstore fixes for read-only connections.
xenstored_core.c | 16 ++++++++++++----
xenstored_core.h | 3 +++
xenstored_domain.c | 3 +++
xs_test.c | 4 ++--
4 files changed, 20 insertions(+), 6 deletions(-)
diff -Nru a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c
--- a/tools/xenstore/xenstored_core.c 2005-06-10 12:03:15 -04:00
+++ b/tools/xenstore/xenstored_core.c 2005-06-10 12:03:15 -04:00
@@ -617,7 +617,7 @@
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 @@
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 @@
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 @@
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 -Nru a/tools/xenstore/xenstored_core.h b/tools/xenstore/xenstored_core.h
--- a/tools/xenstore/xenstored_core.h 2005-06-10 12:03:15 -04:00
+++ b/tools/xenstore/xenstored_core.h 2005-06-10 12:03:15 -04:00
@@ -56,6 +56,9 @@
/* 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 -Nru a/tools/xenstore/xenstored_domain.c
b/tools/xenstore/xenstored_domain.c
--- a/tools/xenstore/xenstored_domain.c 2005-06-10 12:03:15 -04:00
+++ b/tools/xenstore/xenstored_domain.c 2005-06-10 12:03:15 -04:00
@@ -268,6 +268,9 @@
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 -Nru a/tools/xenstore/xs_test.c b/tools/xenstore/xs_test.c
--- a/tools/xenstore/xs_test.c 2005-06-10 12:03:15 -04:00
+++ b/tools/xenstore/xs_test.c 2005-06-10 12:03:15 -04:00
@@ -176,11 +176,11 @@
" 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");
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|