= "stub_header_of_string"
let xenstore_payload_max = 4096 (* xen/include/public/io/xs_wire.h *)
+let xenstore_rel_path_max = 2048 (* xen/include/public/io/xs_wire.h *)
let of_string s =
let tid, rid, opint, dlen = header_of_string_internal s in
external header_of_string_internal : string -> int * int * int * int
= "stub_header_of_string"
val xenstore_payload_max : int
+val xenstore_rel_path_max : int
val of_string : string -> pkt
val append : pkt -> string -> int -> unit
val to_complete : pkt -> int
let domid_self = 0x7FF0
+let path_max = ref Xenbus.Partial.xenstore_rel_path_max
+
exception Not_a_directory of string
exception Not_a_value of string
exception Already_exist
}
let is_dom0 d = d.id = 0
-let get_path dom = "/local/domain/" ^ (sprintf "%u" dom.id)
let get_id domain = domain.id
let get_interface d = d.interface
let get_mfn d = d.mfn
quota-maxwatch = 100
quota-transaction = 10
quota-maxrequests = 1024
+quota-path-max = 1024
# Activate filed base backend
persistent = false
let path_validate path connection_path =
let len = String.length path in
- if len = 0 || len > 1024 then raise Define.Invalid_path;
+ if len = 0 then raise Define.Invalid_path;
let abs_path =
match String.get path 0 with
| _ -> connection_path ^ path
in
+ (* Regardless whether client specified absolute or relative path,
+ canonicalize it (above) and, for domain-relative paths, check the
+ length of the relative part.
+
+ This prevents paths becoming invalid across migrate when the length
+ of the domid changes in @param connection_path.
+ *)
+ let len = String.length abs_path in
+ let on_absolute _ _ = len in
+ let on_relative _ offset = len - offset in
+ let len = Scanf.ksscanf abs_path on_absolute "/local/domain/%d/%n" on_relative in
+ if len > !Define.path_max then raise Define.Invalid_path;
+
abs_path
("quota-maxentity", Config.Set_int Quota.maxent);
("quota-maxsize", Config.Set_int Quota.maxsize);
("quota-maxrequests", Config.Set_int Define.maxrequests);
+ ("quota-path-max", Config.Set_int Define.path_max);
("test-eagain", Config.Set_bool Transaction.test_eagain);
("persistent", Config.Set_bool Disk.enable);
("xenstored-log-file", Config.String Logging.set_xenstored_log_destination);