summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJanis Danisevskis <jdanis@google.com>2019-03-15 14:57:10 -0700
committerJanis Danisevskis <jdanis@google.com>2019-03-15 15:01:33 -0700
commit8196b8c937a7ea2beb112c365b1ffd26e6ac50e0 (patch)
tree98d8c7c7ca5d87591feabccd31eb7855453ef43b
parente534419c71e1dc8772df41eb2aba1a509431bd76 (diff)
downloadsecurity-8196b8c937a7ea2beb112c365b1ffd26e6ac50e0.tar.gz
Add logging around access calls.
We saw evidence, that the keystore exist method may be flaky. This patch adds logging around the access calls used to check for key blobs. Also adds a retry loop in case access return EAGAIN. (Although access should not return EAGAIN). Bug: 128318105 Test: Only logging added. Change-Id: Ib07396f590c2f58e227f85869ada8c6d6dd46df4
-rw-r--r--keystore/blob.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/keystore/blob.cpp b/keystore/blob.cpp
index 9dd85d62..eac8f11d 100644
--- a/keystore/blob.cpp
+++ b/keystore/blob.cpp
@@ -676,10 +676,27 @@ std::string KeyBlobEntry::getCharacteristicsBlobPath() const {
}
bool KeyBlobEntry::hasKeyBlob() const {
- return !access(getKeyBlobPath().c_str(), R_OK | W_OK);
+ int trys = 3;
+ while (trys--) {
+ if (!access(getKeyBlobPath().c_str(), R_OK | W_OK)) return true;
+ if (errno == ENOENT) return false;
+ LOG(WARNING) << "access encountered " << strerror(errno) << " (" << errno << ")"
+ << " while checking for key blob";
+ if (errno != EAGAIN) break;
+ }
+ return false;
}
+
bool KeyBlobEntry::hasCharacteristicsBlob() const {
- return !access(getCharacteristicsBlobPath().c_str(), R_OK | W_OK);
+ int trys = 3;
+ while (trys--) {
+ if (!access(getCharacteristicsBlobPath().c_str(), R_OK | W_OK)) return true;
+ if (errno == ENOENT) return false;
+ LOG(WARNING) << "access encountered " << strerror(errno) << " (" << errno << ")"
+ << " while checking for key characteristics blob";
+ if (errno != EAGAIN) break;
+ }
+ return false;
}
static std::tuple<bool, uid_t, std::string> filename2UidAlias(const std::string& filepath) {