- SECURITYD_CLIENT_CHANGE_SESSION(this, &this->session());
-}
-
-
-//
-// Authorization set maintainance
-//
-void Process::addAuthorization(AuthorizationToken *auth)
-{
- assert(auth);
- StLock<Mutex> _(*this);
- mAuthorizations.insert(auth);
- auth->addProcess(*this);
-}
-
-void Process::checkAuthorization(AuthorizationToken *auth)
-{
- assert(auth);
- StLock<Mutex> _(*this);
- if (mAuthorizations.find(auth) == mAuthorizations.end())
- MacOSError::throwMe(errAuthorizationInvalidRef);
-}
-
-bool Process::removeAuthorization(AuthorizationToken *auth)
-{
- assert(auth);
- StLock<Mutex> _(*this);
- // we do everything with a single set lookup call...
- typedef AuthorizationSet::iterator Iter;
- Iter it = mAuthorizations.lower_bound(auth);
- bool isLast;
- if (it == mAuthorizations.end() || auth != *it) {
- isLast = true;
- } else {
- Iter next = it; ++next; // following element
- isLast = (next == mAuthorizations.end()) || auth != *next;
- mAuthorizations.erase(it); // remove first match
- }
- if (isLast) {
- if (auth->endProcess(*this)) // ... tell it to remove us,
- return true; // ... and tell the caller
- }
- return false; // keep the auth; it's still in use