Unify client policy across File_system servers

File_system servers shall deny clients not matching a defined policy.
Servers shall also apply session root offset policy followed by a client
offset.

Fix #2365
This commit is contained in:
Emery Hemingway
2017-04-03 12:24:19 -05:00
committed by Christian Helmuth
parent 2668a55688
commit dde11de008
3 changed files with 56 additions and 55 deletions

View File

@@ -410,28 +410,24 @@ class File_system::Root : public Root_component<Session_component>
try {
Session_policy policy(label);
/* Determine the session root directory.
* Defaults to '/' if not specified by session
* policy or session arguments.
*/
/* determine policy root offset */
try {
policy.attribute("root").value(tmp, sizeof(tmp));
session_root.import(tmp, "/");
} catch (Xml_node::Nonexistent_attribute) { }
/* Determine if the session is writeable.
* Policy overrides arguments, both default to false.
/*
* Determine if the session is writeable.
* Policy overrides client argument, both default to false.
*/
if (policy.attribute_value("writeable", false))
writeable = Arg_string::find_arg(args, "writeable").bool_value(false);
} catch (Session_policy::No_policy_defined) {
/* missing policy - deny request */
throw Root::Unavailable();
}
} catch (...) { }
/*
* If no policy matches the client gets
* read-only access to the root.
*/
/* apply client's root offset */
Arg_string::find_arg(args, "root").string(tmp, sizeof(tmp), "/");
if (Genode::strcmp("/", tmp, sizeof(tmp))) {
session_root.append("/");