// // Find and store database objects (primitive layer) // bool CodeSignatures::find(Identity &id, uid_t user) { if (id.mState != Identity::untried) return id.mState == Identity::valid; try { DbKey userKey('H', id.getHash(), true, user); CssmData linkValue; if (mDb.get(userKey, linkValue)) { id.mName = string(linkValue.interpretedAs<const char>(), linkValue.length()); IFDUMPING("equiv", id.debugDump("found/user")); id.mState = Identity::valid; return true; } DbKey sysKey('H', id.getHash()); if (mDb.get(sysKey, linkValue)) { id.mName = string(linkValue.interpretedAs<const char>(), linkValue.length()); IFDUMPING("equiv", id.debugDump("found/system")); id.mState = Identity::valid; return true; } } catch (...) { secdebug("codesign", "exception validating identity for %s - marking failed", id.path().c_str()); id.mState = Identity::invalid; } return id.mState == Identity::valid; }
void CodeSignatures::makeLink(Identity &id, const string &ident, bool forUser, uid_t user) { DbKey key('H', id.getHash(), forUser, user); if (!mDb.put(key, StringData(ident))) UnixError::throwMe(); }