X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/6b200bc335dc93c5516ccb52f14bd896d8c7fad7..refs/heads/master:/securityd/src/notifications.cpp?ds=sidebyside diff --git a/securityd/src/notifications.cpp b/securityd/src/notifications.cpp index 26440052..2b846445 100644 --- a/securityd/src/notifications.cpp +++ b/securityd/src/notifications.cpp @@ -109,33 +109,6 @@ void Listener::sendNotification(Notification *message) } } - -// -// Handle a port death or deallocation by removing all Listeners using that port. -// Returns true iff we had one. -// -bool Listener::remove(Port port) -{ - typedef ListenerMap::iterator Iterator; - StLock _(setLock); - pair range = listeners.equal_range(port); - if (range.first == range.second) - return false; // not one of ours - - assert(range.first != listeners.end()); - secinfo("notify", "remove port %d", port.port()); -#if !defined(NDEBUG) - for (Iterator it = range.first; it != range.second; it++) { - assert(it->first == port); - secinfo("notify", "%p listener removed", it->second.get()); - } -#endif //NDEBUG - listeners.erase(range.first, range.second); - port.destroy(); - return true; // got it -} - - // // Notification message objects // @@ -204,13 +177,8 @@ bool Listener::testPredicate(const std::function SharedMemoryListener::SharedMemoryListener(const char* segmentName, SegmentOffsetType segmentSize, uid_t uid, gid_t gid) : Listener (kNotificationDomainAll, kNotificationAllEvents), SharedMemoryServer (segmentName, segmentSize, uid, gid), - mActive (false) + mActive (false), mMutex() { - if (segmentName == NULL) - { - secerror("Attempted to start securityd with a NULL segmentName"); - abort(); - } } SharedMemoryListener::~SharedMemoryListener () @@ -304,10 +272,10 @@ bool SharedMemoryListener::needsPrivacyFilter(Notification *notification) { case kSecUnlockEvent: // kNotificationEventUnlocked case kSecPasswordChangedEvent: // kNotificationEventPassphraseChanged case kSecDefaultChangedEvent: - case kSecDataAccessEvent: case kSecKeychainListChangedEvent: case kSecTrustSettingsChangedEvent: return false; + case kSecDataAccessEvent: case kSecAddEvent: case kSecDeleteEvent: case kSecUpdateEvent: @@ -372,6 +340,7 @@ void SharedMemoryListener::notifyMe(Notification* notification) WriteMessage (notification->domain, notification->event, data, int_cast(length)); + StLock lock(mMutex); if (!mActive) { Server::active().setTimer (this, Time::Interval(kServerWait)); @@ -381,9 +350,10 @@ void SharedMemoryListener::notifyMe(Notification* notification) void SharedMemoryListener::action () { + StLock lock(mMutex); + notify_post (mSegmentName.c_str ()); secinfo("notify", "Posted notification to clients."); secdebug("MDSPRIVACY","[%03d] Posted notification to clients", mUID); - notify_post (mSegmentName.c_str ()); mActive = false; }