]> git.saurik.com Git - apple/security.git/blobdiff - securityd/src/notifications.cpp
Security-59754.80.3.tar.gz
[apple/security.git] / securityd / src / notifications.cpp
index 264400521cfe0e75df2915dc7130b4ba1b0d56ba..2b846445e863948df1725866492a95a7bd1369ef 100644 (file)
@@ -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<Mutex> _(setLock);
-    pair<Iterator, Iterator> 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<bool(const Listener& listener)>
 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<size_t, UInt32>(length));
 
+    StLock<Mutex> lock(mMutex);
     if (!mActive)
     {
         Server::active().setTimer (this, Time::Interval(kServerWait));
@@ -381,9 +350,10 @@ void SharedMemoryListener::notifyMe(Notification* notification)
 
 void SharedMemoryListener::action ()
 {
+    StLock<Mutex> 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;
 }