mirror of
https://github.com/uqbar-dao/nectar.git
synced 2024-12-23 16:43:24 +03:00
add bootstrapped app vfs caps to app_store
This commit is contained in:
parent
afebba0fcb
commit
104ebb4334
@ -333,7 +333,7 @@ fn handle_local_request(
|
||||
|
||||
// add zip bytes
|
||||
payload.mime = Some("application/zip".to_string());
|
||||
Request::new()
|
||||
let response = Request::new()
|
||||
.target(Address::from_str("our@vfs:sys:uqbar")?)
|
||||
.ipc(serde_json::to_vec(&kt::VfsRequest {
|
||||
drive: package.to_string(),
|
||||
@ -344,6 +344,13 @@ fn handle_local_request(
|
||||
})?)
|
||||
.payload(payload.clone())
|
||||
.send_and_await_response(5)?.unwrap();
|
||||
let Message::Response { ipc: ref vfs_ipc, .. } = response else {
|
||||
panic!("app_store: send_and_await_response must return Response");
|
||||
};
|
||||
let vfs_ipc = serde_json::from_slice::<serde_json::Value>(vfs_ipc)?;
|
||||
if vfs_ipc == serde_json::json!({"Err": "NoCap"}) {
|
||||
return Err(anyhow::anyhow!("cannot add NewPackage: do not have capability to access vfs"));
|
||||
}
|
||||
|
||||
// save the zip file itself in VFS for sharing with other nodes
|
||||
// call it <package>.zip
|
||||
|
@ -174,6 +174,9 @@ async fn bootstrap(
|
||||
|
||||
let mut vfs_messages = Vec::new();
|
||||
|
||||
// special case: add bootstrapped process vfs caps to app_store
|
||||
let mut app_store_caps = Vec::new();
|
||||
|
||||
for (package_name, mut package) in packages {
|
||||
// special case tester: only load it in if in simulation mode
|
||||
if package_name == "tester" {
|
||||
@ -346,7 +349,7 @@ async fn bootstrap(
|
||||
}
|
||||
|
||||
// give access to package_name vfs
|
||||
requested_caps.insert(Capability {
|
||||
let read_cap = Capability {
|
||||
issuer: Address {
|
||||
node: our_name.into(),
|
||||
process: VFS_PROCESS_ID.clone(),
|
||||
@ -356,8 +359,8 @@ async fn bootstrap(
|
||||
"drive": our_drive_name,
|
||||
}))
|
||||
.unwrap(),
|
||||
});
|
||||
requested_caps.insert(Capability {
|
||||
};
|
||||
let write_cap = Capability {
|
||||
issuer: Address {
|
||||
node: our_name.into(),
|
||||
process: VFS_PROCESS_ID.clone(),
|
||||
@ -367,7 +370,11 @@ async fn bootstrap(
|
||||
"drive": our_drive_name,
|
||||
}))
|
||||
.unwrap(),
|
||||
});
|
||||
};
|
||||
requested_caps.insert(read_cap.clone());
|
||||
requested_caps.insert(write_cap.clone());
|
||||
app_store_caps.push(read_cap);
|
||||
app_store_caps.push(write_cap);
|
||||
|
||||
let public_process = entry.public;
|
||||
|
||||
@ -388,6 +395,15 @@ async fn bootstrap(
|
||||
}
|
||||
}
|
||||
|
||||
// special case: add bootstrapped process vfs caps to app_store
|
||||
for cap in app_store_caps {
|
||||
process_map
|
||||
.entry(ProcessId::new(Some("main"), "app_store", "uqbar"))
|
||||
.and_modify(|p| {
|
||||
p.capabilities.insert(cap);
|
||||
});
|
||||
}
|
||||
|
||||
// save kernel process state. FsAction::SetState(kernel)
|
||||
let serialized_process_map =
|
||||
bincode::serialize(&process_map).expect("state map serialization error!");
|
||||
|
Loading…
Reference in New Issue
Block a user