mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
fix basis search order issues
at least, it passes some simple tests. much more testing is needed.
This commit is contained in:
parent
e62c9bf3d3
commit
9f409fda2d
5 changed files with 49 additions and 18 deletions
|
|
@ -109,11 +109,13 @@ pub(crate) fn start_actions_thread(
|
|||
Some(ActionOp::MenuUnlockBasis) => {
|
||||
manager.activate();
|
||||
manager.unlock_basis();
|
||||
manager.retrieve_db();
|
||||
manager.deactivate();
|
||||
},
|
||||
Some(ActionOp::MenuManageBasis) => {
|
||||
manager.activate();
|
||||
manager.manage_basis();
|
||||
manager.retrieve_db();
|
||||
manager.deactivate();
|
||||
}
|
||||
Some(ActionOp::MenuClose) => {
|
||||
|
|
@ -346,10 +348,12 @@ impl ActionManager {
|
|||
Ok(mut data) => {
|
||||
match data.write(&ser) {
|
||||
Ok(len) => log::debug!("wrote {} bytes", len),
|
||||
Err(e) => self.report_err(t!("vault.error.internal_error", xous::LANG), Some(e)),
|
||||
Err(e) => {log::error!("internal error");
|
||||
self.report_err(t!("vault.error.internal_error", xous::LANG), Some(e))},
|
||||
}
|
||||
}
|
||||
Err(e) => self.report_err(t!("vault.error.internal_error", xous::LANG), Some(e)),
|
||||
Err(e) => { log::error!("internal error");
|
||||
self.report_err(t!("vault.error.internal_error", xous::LANG), Some(e))},
|
||||
}
|
||||
log::debug!("syncing...");
|
||||
self.pddb.borrow().sync().ok();
|
||||
|
|
@ -498,23 +502,31 @@ impl ActionManager {
|
|||
pw.notes = edit_data.content()[3].content.as_str().unwrap().to_string();
|
||||
pw.atime = utc_now().timestamp() as u64;
|
||||
Some(pw)
|
||||
} else { self.report_err(t!("vault.error.record_error", xous::LANG), None::<std::io::Error>); None }
|
||||
} else { log::error!("record error");
|
||||
self.report_err(t!("vault.error.record_error", xous::LANG), None::<std::io::Error>); None }
|
||||
}
|
||||
Err(e) => { self.report_err(t!("vault.error.internal_error", xous::LANG), Some(e)); None }
|
||||
Err(e) => { log::error!("internal error"); self.report_err(t!("vault.error.internal_error", xous::LANG), Some(e)); None }
|
||||
};
|
||||
maybe_update
|
||||
}
|
||||
Err(e) => {
|
||||
match e.kind() {
|
||||
std::io::ErrorKind::NotFound => self.report_err(t!("vault.error.not_found", xous::LANG), None::<std::io::Error>),
|
||||
_ => self.report_err(t!("vault.error.internal_error", xous::LANG), Some(e)),
|
||||
std::io::ErrorKind::NotFound => {
|
||||
log::error!("not found");
|
||||
self.report_err(t!("vault.error.not_found", xous::LANG), None::<std::io::Error>)
|
||||
},
|
||||
_ => {
|
||||
log::error!("internal error");
|
||||
self.report_err(t!("vault.error.internal_error", xous::LANG), Some(e))
|
||||
},
|
||||
}
|
||||
None
|
||||
}
|
||||
};
|
||||
if let Some(update) = maybe_update {
|
||||
self.pddb.borrow().delete_key(dict, entry.key_name.as_str().unwrap(), None)
|
||||
.unwrap_or_else(|e| self.report_err(t!("vault.error.internal_error", xous::LANG), Some(e)));
|
||||
.unwrap_or_else(|e| {log::error!("internal error");
|
||||
self.report_err(t!("vault.error.internal_error", xous::LANG), Some(e))});
|
||||
match self.pddb.borrow().get(
|
||||
dict, entry.key_name.as_str().unwrap(), None,
|
||||
false, true, Some(VAULT_ALLOC_HINT),
|
||||
|
|
@ -524,9 +536,13 @@ impl ActionManager {
|
|||
let ser = serialize_password(&update);
|
||||
record.write(&ser)
|
||||
.unwrap_or_else(|e| {
|
||||
log::error!("internal error");
|
||||
self.report_err(t!("vault.error.internal_error", xous::LANG), Some(e)); 0});
|
||||
}
|
||||
Err(e) => self.report_err(t!("vault.error.internal_error", xous::LANG), Some(e)),
|
||||
Err(e) => {
|
||||
log::error!("internal error");
|
||||
self.report_err(t!("vault.error.internal_error", xous::LANG), Some(e))
|
||||
},
|
||||
}
|
||||
}
|
||||
self.pddb.borrow().sync().ok();
|
||||
|
|
@ -695,7 +711,10 @@ impl ActionManager {
|
|||
std::io::ErrorKind::NotFound => {
|
||||
log::debug!("Password dictionary not yet created");
|
||||
}
|
||||
_ => self.report_err("Dictionary error accessing password database", Some(e)),
|
||||
_ => {
|
||||
log::error!("Dictionary error accessing password database");
|
||||
self.report_err("Dictionary error accessing password database", Some(e))
|
||||
},
|
||||
}
|
||||
Vec::new()
|
||||
}
|
||||
|
|
@ -727,13 +746,20 @@ impl ActionManager {
|
|||
};
|
||||
il.push(li);
|
||||
} else {
|
||||
log::error!("Couldn't deserialize password");
|
||||
self.report_err("Couldn't deserialize password:", Some(key));
|
||||
}
|
||||
}
|
||||
Err(e) => self.report_err("Couldn't access password key", Some(e)),
|
||||
Err(e) => {
|
||||
log::error!("Couldn't access password key");
|
||||
self.report_err("Couldn't access password key", Some(e))
|
||||
},
|
||||
}
|
||||
}
|
||||
Err(e) => self.report_err("Couldn't access password key", Some(e)),
|
||||
Err(e) => {
|
||||
log::error!("Couldn't access password key");
|
||||
self.report_err("Couldn't access password key", Some(e))
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -471,6 +471,7 @@ fn check_user_presence(_cid: ChannelID) -> Result<(), Ctap2StatusCode> {
|
|||
}
|
||||
|
||||
pub(crate) fn basis_change() {
|
||||
log::info!("got basis change");
|
||||
xous::send_message(SELF_CONN.load(Ordering::SeqCst),
|
||||
Message::new_scalar(VaultOp::BasisChange.to_usize().unwrap(), 0, 0, 0, 0)
|
||||
).unwrap();
|
||||
|
|
|
|||
|
|
@ -238,7 +238,7 @@ impl VaultUx {
|
|||
let style = match self.pddb.borrow().get(
|
||||
VAULT_CONFIG_DICT,
|
||||
VAULT_CONFIG_KEY_FONT,
|
||||
None, true, true,
|
||||
Some(pddb::PDDB_DEFAULT_SYSTEM_BASIS), true, true,
|
||||
Some(32), Some(crate::basis_change)
|
||||
) {
|
||||
Ok(mut style_key) => {
|
||||
|
|
@ -269,13 +269,13 @@ impl VaultUx {
|
|||
self.items_per_screen = available_height / self.item_height;
|
||||
}
|
||||
pub(crate) fn set_glyph_style(&mut self, style: GlyphStyle) {
|
||||
self.pddb.borrow().delete_key(VAULT_CONFIG_DICT, VAULT_CONFIG_KEY_FONT, None)
|
||||
self.pddb.borrow().delete_key(VAULT_CONFIG_DICT, VAULT_CONFIG_KEY_FONT, Some(pddb::PDDB_DEFAULT_SYSTEM_BASIS))
|
||||
.expect("couldn't delete previous setting");
|
||||
|
||||
match self.pddb.borrow().get(
|
||||
VAULT_CONFIG_DICT,
|
||||
VAULT_CONFIG_KEY_FONT,
|
||||
None, true, true,
|
||||
Some(pddb::PDDB_DEFAULT_SYSTEM_BASIS), true, true,
|
||||
Some(32), Some(crate::basis_change)
|
||||
) {
|
||||
Ok(mut style_key) => {
|
||||
|
|
|
|||
|
|
@ -789,6 +789,7 @@ fn main() -> ! {
|
|||
};
|
||||
let dict = req.dict.as_str().expect("dict utf-8 decode error");
|
||||
let key = req.key.as_str().expect("key utf-8 decode error");
|
||||
log::info!("get: {:?} {}", bname, key);
|
||||
if basis_cache.dict_attributes(&mut pddb_os, dict, bname).is_err() {
|
||||
if req.create_dict {
|
||||
match basis_cache.dict_add(&mut pddb_os, dict, bname) {
|
||||
|
|
@ -848,6 +849,7 @@ fn main() -> ! {
|
|||
req.token = Some(token);
|
||||
req.result = PddbRequestCode::NoErr;
|
||||
buffer.replace(req).unwrap();
|
||||
break; // if we got here, entry was found, stop searching
|
||||
}
|
||||
}
|
||||
Some(Opcode::KeyDrop) => msg_blocking_scalar_unpack!(msg, t0, t1, t2, _, {
|
||||
|
|
@ -1128,7 +1130,7 @@ fn main() -> ! {
|
|||
if let Some(rec) = token_dict.get(&token) {
|
||||
for basis in basis_cache.access_list().iter() {
|
||||
let temp = if let Some (name) = &rec.basis {Some(name)} else {Some(basis)};
|
||||
log::info!("accessing {:?}", temp);
|
||||
log::info!("read (spec: {:?}){:?} {}", rec.basis, temp, rec.key);
|
||||
match basis_cache.key_read(&mut pddb_os,
|
||||
&rec.dict, &rec.key,
|
||||
&mut pbuf.data[..pbuf.len as usize], Some(pbuf.position as usize),
|
||||
|
|
@ -1161,6 +1163,8 @@ fn main() -> ! {
|
|||
let token = pbuf.token;
|
||||
if let Some(rec) = token_dict.get(&token) {
|
||||
for basis in basis_cache.access_list().iter() {
|
||||
let temp = if let Some (name) = &rec.basis {Some(name)} else {Some(basis)};
|
||||
log::info!("write (spec: {:?}){:?} {}", rec.basis, temp, rec.key);
|
||||
match basis_cache.key_update(&mut pddb_os,
|
||||
&rec.dict, &rec.key,
|
||||
&pbuf.data[..pbuf.len as usize], Some(pbuf.position as usize),
|
||||
|
|
|
|||
|
|
@ -245,7 +245,7 @@ pub fn start_time_server() {
|
|||
let mut offset_key = offset_handle.get(
|
||||
TIME_SERVER_DICT,
|
||||
TIME_SERVER_UTC_OFFSET,
|
||||
None, true, true,
|
||||
Some(pddb::PDDB_DEFAULT_SYSTEM_BASIS), true, true,
|
||||
Some(8),
|
||||
None::<fn()>
|
||||
).expect("couldn't open UTC offset key");
|
||||
|
|
@ -253,7 +253,7 @@ pub fn start_time_server() {
|
|||
let mut tz_key = tz_handle.get(
|
||||
TIME_SERVER_DICT,
|
||||
TIME_SERVER_TZ_OFFSET,
|
||||
None, true, true,
|
||||
Some(pddb::PDDB_DEFAULT_SYSTEM_BASIS), true, true,
|
||||
Some(8),
|
||||
None::<fn()>
|
||||
).expect("couldn't open TZ offset key");
|
||||
|
|
@ -532,7 +532,7 @@ pub fn start_time_ux(sid: xous::SID) {
|
|||
let maybe_tz_set_key = tz_set_handle.get(
|
||||
TIME_SERVER_DICT,
|
||||
TIME_SERVER_TZ_OFFSET,
|
||||
None, false, false,
|
||||
Some(pddb::PDDB_DEFAULT_SYSTEM_BASIS), false, false,
|
||||
None,
|
||||
None::<fn()>
|
||||
).ok();
|
||||
|
|
|
|||
Loading…
Reference in a new issue