- return update() && signature == mBlob.signature;
-}
-
-bool SystemKeychainKey::update()
-{
- // if we checked recently, just assume it's okay
- if (mValid && mUpdateThreshold > Time::now())
- return mValid;
-
- // check the file
- struct stat st;
- if (::stat(mPath.c_str(), &st)) {
- // something wrong with the file; can't use it
- mUpdateThreshold = Time::now() + Time::Interval(checkDelay);
- return mValid = false;
- }
- if (mValid && Time::Absolute(st.st_mtimespec) == mCachedDate)
- return true;
- mUpdateThreshold = Time::now() + Time::Interval(checkDelay);
-
- try {
- secdebug("syskc", "reading system unlock record from %s", mPath.c_str());
- AutoFileDesc fd(mPath, O_RDONLY);
- if (fd.read(mBlob) != sizeof(mBlob))
- return false;
- if (mBlob.isValid()) {
- mCachedDate = st.st_mtimespec;
- return mValid = true;
- } else
- return mValid = false;
- } catch (...) {
- secdebug("syskc", "system unlock record not available");
- return false;
- }