]> xenbits.xensource.com Git - xen.git/commitdiff
tools/xenstore: add XS_RESTRICT operation to C xenstore client libs.
authorIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 6 Jul 2010 10:57:20 +0000 (11:57 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 6 Jul 2010 10:57:20 +0000 (11:57 +0100)
The OCaml xenstored supports the XS_RESTRICT operation, which
deprivileges a dom0 xenstore connection so it can only affect one
domain's entries.   Add the relevant definitions to the C libraries
so that callers can use it.

Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
tools/ocaml/libs/xb/op.ml
tools/xenstore/xs.c
tools/xenstore/xs.h
xen/include/public/io/xs_wire.h

index 6ea8fe6d0706038452673420bbee3c65c1cb1fce..97e38f236e8b6df25df2c686c1a753e1172945eb 100644 (file)
@@ -31,13 +31,13 @@ let operation_c_mapping =
            Transaction_end; Introduce; Release;
            Getdomainpath; Write; Mkdir; Rm;
            Setperms; Watchevent; Error; Isintroduced;
-           Resume; Set_target |]
+           Resume; Set_target; Restrict |]
 let size = Array.length operation_c_mapping
 
 (* [offset_pq] has to be the same as in <xen/io/xs_wire.h> *)
 let offset_pq = size
 let operation_c_mapping_pq =
-       [| Restrict |]
+       [| |]
 let size_pq = Array.length operation_c_mapping_pq
 
 let array_search el a =
index 094db25efafd352e7a02a1d592dbe8a43d84665e..34416560390e5a79ef16cbd49e3e97ff7e21e203 100644 (file)
@@ -615,6 +615,14 @@ unwind:
        return false;
 }
 
+bool xs_restrict(struct xs_handle *h, unsigned domid)
+{
+       char buf[16];
+
+       sprintf(buf, "%d", domid);
+       return xs_bool(xs_single(h, XBT_NULL, XS_RESTRICT, buf, NULL));
+}
+
 /* Watch a node for changes (poll on fd to detect, or call read_watch()).
  * When the node (or any child) changes, fd will become readable.
  * Token is returned when watch is read, to allow matching.
index 4dae5944ae94c787e82caad59cc222c30dd9500e..4806f1e24042b6640c41ffa3a3930b420f45d0f3 100644 (file)
@@ -83,6 +83,15 @@ bool xs_mkdir(struct xs_handle *h, xs_transaction_t t,
 bool xs_rm(struct xs_handle *h, xs_transaction_t t,
           const char *path);
 
+/* Restrict a xenstore handle so that it acts as if it had the
+ * permissions of domain @domid.  The handle must currently be
+ * using domain 0's credentials.
+ *
+ * Returns false on failure, in which case the handle continues
+ * to use the old credentials, or true on success.
+ */
+bool xs_restrict(struct xs_handle *h, unsigned domid);
+
 /* Get permissions of node (first element is owner, first perms is "other").
  * Returns malloced array, or NULL: call free() after use.
  */
index 24b5619fd8ad29adc872e5fee9de63df6a6aa803..e1debceb63bf950a157a8a8c9125aed6936775bf 100644 (file)
@@ -47,7 +47,8 @@ enum xsd_sockmsg_type
     XS_ERROR,
     XS_IS_DOMAIN_INTRODUCED,
     XS_RESUME,
-    XS_SET_TARGET
+    XS_SET_TARGET,
+    XS_RESTRICT
 };
 
 #define XS_WRITE_NONE "NONE"