mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
WIP: #334
I don't have a way to test this, but maybe you can give it a try and see if it fixes as described in the issue.
This commit is contained in:
parent
f4fabc3f8e
commit
cd0269036d
1 changed files with 68 additions and 64 deletions
132
apps/vault/src/env/xous/mod.rs
vendored
132
apps/vault/src/env/xous/mod.rs
vendored
|
|
@ -307,81 +307,85 @@ impl XousEnv {
|
||||||
};
|
};
|
||||||
let update = buf.to_original::<Ctap1Request, _>().unwrap();
|
let update = buf.to_original::<Ctap1Request, _>().unwrap();
|
||||||
let app_id_str = hex::encode(update.app_id);
|
let app_id_str = hex::encode(update.app_id);
|
||||||
// note the access
|
if update.app_id != [0u8; 32] {
|
||||||
let mut info = {
|
// note the access
|
||||||
// fetch the application info, if it exists
|
let mut info = {
|
||||||
log::info!("Updating U2F record {}", app_id_str);
|
// fetch the application info, if it exists
|
||||||
// add code to query the PDDB here to look for the k/v mapping of this app ID
|
log::info!("Updating U2F record {}", app_id_str);
|
||||||
match pddb.get(
|
// add code to query the PDDB here to look for the k/v mapping of this app ID
|
||||||
U2F_APP_DICT,
|
match pddb.get(
|
||||||
&app_id_str,
|
U2F_APP_DICT,
|
||||||
None, true, false,
|
&app_id_str,
|
||||||
Some(256), Some(basis_change)
|
None, true, false,
|
||||||
) {
|
Some(256), Some(basis_change)
|
||||||
Ok(mut app_data) => {
|
) {
|
||||||
let app_attr = app_data.attributes().unwrap();
|
Ok(mut app_data) => {
|
||||||
if app_attr.len != 0 {
|
let app_attr = app_data.attributes().unwrap();
|
||||||
let mut descriptor = Vec::<u8>::new();
|
if app_attr.len != 0 {
|
||||||
match app_data.read_to_end(&mut descriptor) {
|
let mut descriptor = Vec::<u8>::new();
|
||||||
Ok(_) => {
|
match app_data.read_to_end(&mut descriptor) {
|
||||||
deserialize_app_info(descriptor)
|
Ok(_) => {
|
||||||
|
deserialize_app_info(descriptor)
|
||||||
|
}
|
||||||
|
Err(e) => {log::error!("Couldn't read app info: {:?}", e); None}
|
||||||
}
|
}
|
||||||
Err(e) => {log::error!("Couldn't read app info: {:?}", e); None}
|
} else {
|
||||||
|
None
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
_ => {
|
||||||
|
log::info!("couldn't find key {}", app_id_str);
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
}.unwrap_or_else(
|
||||||
log::info!("couldn't find key {}", app_id_str);
|
|| {
|
||||||
None
|
// otherwise, create it
|
||||||
}
|
match modals
|
||||||
}
|
.alert_builder(t!("vault.u2f.give_app_name", xous::LANG))
|
||||||
}.unwrap_or_else(
|
.field(None, None)
|
||||||
|| {
|
.build()
|
||||||
// otherwise, create it
|
{
|
||||||
match modals
|
Ok(name) => {
|
||||||
.alert_builder(t!("vault.u2f.give_app_name", xous::LANG))
|
let info = AppInfo {
|
||||||
.field(None, None)
|
name: name.content()[0].content.to_string(),
|
||||||
.build()
|
notes: t!("vault.notes", xous::LANG).to_string(),
|
||||||
{
|
id: update.app_id,
|
||||||
Ok(name) => {
|
ctime: crate::utc_now().timestamp() as u64,
|
||||||
let info = AppInfo {
|
atime: 0,
|
||||||
name: name.content()[0].content.to_string(),
|
count: 0,
|
||||||
notes: t!("vault.notes", xous::LANG).to_string(),
|
};
|
||||||
id: update.app_id,
|
info
|
||||||
ctime: crate::utc_now().timestamp() as u64,
|
}
|
||||||
atime: 0,
|
_ => {
|
||||||
count: 0,
|
log::error!("couldn't get name for app");
|
||||||
};
|
panic!("couldn't get name for app");
|
||||||
info
|
}
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
log::error!("couldn't get name for app");
|
|
||||||
panic!("couldn't get name for app");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
);
|
||||||
);
|
|
||||||
|
|
||||||
info.atime = crate::utc_now().timestamp() as u64;
|
info.atime = crate::utc_now().timestamp() as u64;
|
||||||
info.count = info.count.saturating_add(1);
|
info.count = info.count.saturating_add(1);
|
||||||
let ser = serialize_app_info(&info);
|
let ser = serialize_app_info(&info);
|
||||||
|
|
||||||
// update the access time, by deleting the key and writing it back into the PDDB
|
// update the access time, by deleting the key and writing it back into the PDDB
|
||||||
pddb.delete_key(U2F_APP_DICT, &app_id_str, None).ok();
|
pddb.delete_key(U2F_APP_DICT, &app_id_str, None).ok();
|
||||||
match pddb.get(
|
match pddb.get(
|
||||||
U2F_APP_DICT,
|
U2F_APP_DICT,
|
||||||
&app_id_str,
|
&app_id_str,
|
||||||
None, true, true,
|
None, true, true,
|
||||||
Some(256), Some(basis_change)
|
Some(256), Some(basis_change)
|
||||||
) {
|
) {
|
||||||
Ok(mut app_data) => {
|
Ok(mut app_data) => {
|
||||||
app_data.write(&ser).expect("couldn't update atime");
|
app_data.write(&ser).expect("couldn't update atime");
|
||||||
|
}
|
||||||
|
_ => log::error!("Error updating app atime"),
|
||||||
}
|
}
|
||||||
_ => log::error!("Error updating app atime"),
|
pddb.sync().ok();
|
||||||
|
} else {
|
||||||
|
log::warn!("app_id is all 0's; bypassing name association");
|
||||||
}
|
}
|
||||||
pddb.sync().ok();
|
|
||||||
|
|
||||||
log::debug!("sycing UI state...");
|
log::debug!("sycing UI state...");
|
||||||
xous::send_message(
|
xous::send_message(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue