mirror of
https://github.com/uqbar-dao/nectar.git
synced 2024-11-23 03:44:04 +03:00
Merge pull request #101 from uqbar-dao/hf/app_store-bootstrapped-app-caps
app store bootstrapped app caps
This commit is contained in:
commit
48b0ca4d5b
@ -333,7 +333,7 @@ fn handle_local_request(
|
|||||||
|
|
||||||
// add zip bytes
|
// add zip bytes
|
||||||
payload.mime = Some("application/zip".to_string());
|
payload.mime = Some("application/zip".to_string());
|
||||||
Request::new()
|
let response = Request::new()
|
||||||
.target(Address::from_str("our@vfs:sys:uqbar")?)
|
.target(Address::from_str("our@vfs:sys:uqbar")?)
|
||||||
.ipc(serde_json::to_vec(&kt::VfsRequest {
|
.ipc(serde_json::to_vec(&kt::VfsRequest {
|
||||||
drive: package.to_string(),
|
drive: package.to_string(),
|
||||||
@ -344,6 +344,13 @@ fn handle_local_request(
|
|||||||
})?)
|
})?)
|
||||||
.payload(payload.clone())
|
.payload(payload.clone())
|
||||||
.send_and_await_response(5)?.unwrap();
|
.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
|
// save the zip file itself in VFS for sharing with other nodes
|
||||||
// call it <package>.zip
|
// call it <package>.zip
|
||||||
|
@ -174,6 +174,9 @@ async fn bootstrap(
|
|||||||
|
|
||||||
let mut vfs_messages = Vec::new();
|
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 {
|
for (package_name, mut package) in packages {
|
||||||
// special case tester: only load it in if in simulation mode
|
// special case tester: only load it in if in simulation mode
|
||||||
if package_name == "tester" {
|
if package_name == "tester" {
|
||||||
@ -346,7 +349,7 @@ async fn bootstrap(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// give access to package_name vfs
|
// give access to package_name vfs
|
||||||
requested_caps.insert(Capability {
|
let read_cap = Capability {
|
||||||
issuer: Address {
|
issuer: Address {
|
||||||
node: our_name.into(),
|
node: our_name.into(),
|
||||||
process: VFS_PROCESS_ID.clone(),
|
process: VFS_PROCESS_ID.clone(),
|
||||||
@ -356,8 +359,8 @@ async fn bootstrap(
|
|||||||
"drive": our_drive_name,
|
"drive": our_drive_name,
|
||||||
}))
|
}))
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
});
|
};
|
||||||
requested_caps.insert(Capability {
|
let write_cap = Capability {
|
||||||
issuer: Address {
|
issuer: Address {
|
||||||
node: our_name.into(),
|
node: our_name.into(),
|
||||||
process: VFS_PROCESS_ID.clone(),
|
process: VFS_PROCESS_ID.clone(),
|
||||||
@ -367,7 +370,11 @@ async fn bootstrap(
|
|||||||
"drive": our_drive_name,
|
"drive": our_drive_name,
|
||||||
}))
|
}))
|
||||||
.unwrap(),
|
.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;
|
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)
|
// save kernel process state. FsAction::SetState(kernel)
|
||||||
let serialized_process_map =
|
let serialized_process_map =
|
||||||
bincode::serialize(&process_map).expect("state map serialization error!");
|
bincode::serialize(&process_map).expect("state map serialization error!");
|
||||||
|
Loading…
Reference in New Issue
Block a user