Avoid crash when user denies keychain access

Co-Authored-By: Antonio Scandurra <me@as-cii.com>
This commit is contained in:
Max Brunsfeld 2021-06-11 09:47:24 -07:00
parent 4efebdaa52
commit 71d64a837e

View file

@ -523,7 +523,7 @@ impl platform::Platform for MacPlatform {
let status = SecItemCopyMatching(attrs.as_concrete_TypeRef(), &mut result);
match status {
security::errSecSuccess => {}
security::errSecItemNotFound => return None,
security::errSecItemNotFound | security::errSecUserCanceled => return None,
_ => panic!("reading password failed: {}", status),
}
@ -657,6 +657,7 @@ mod security {
}
pub const errSecSuccess: OSStatus = 0;
pub const errSecUserCanceled: OSStatus = -128;
pub const errSecItemNotFound: OSStatus = -25300;
}