-//
-// Authorization subsystem entry
-//
-void ClientSession::authCreate(const AuthorizationItemSet *rights,
- const AuthorizationItemSet *environment, AuthorizationFlags flags,
- AuthorizationBlob &result)
-{
- void *rightSet = NULL; mach_msg_size_t rightSet_size = 0;
- void *environ = NULL; mach_msg_size_t environ_size = 0;
-
- if ((rights &&
- !copyin_AuthorizationItemSet(rights, &rightSet, &rightSet_size)) ||
- (environment &&
- !copyin_AuthorizationItemSet(environment, &environ, &environ_size)))
- CssmError::throwMe(errAuthorizationInternal);
-
- activate();
- IPCSTART(ucsp_client_authorizationCreate(UCSP_ARGS,
- rightSet, rightSet_size,
- flags,
- environ, environ_size,
- &result));
-
- free(rightSet);
- free(environ);
-
- if (rcode == CSSMERR_CSSM_NO_USER_INTERACTION)
- CssmError::throwMe(errAuthorizationInteractionNotAllowed);
- IPCEND_CHECK;
-}
-
-void ClientSession::authRelease(const AuthorizationBlob &auth,
- AuthorizationFlags flags)
-{
- activate();
- IPCSTART(ucsp_client_authorizationRelease(UCSP_ARGS, auth, flags));
- if (rcode == CSSMERR_CSSM_NO_USER_INTERACTION)
- CssmError::throwMe(errAuthorizationInteractionNotAllowed);
- IPCEND_CHECK;
-}
-
-void ClientSession::authCopyRights(const AuthorizationBlob &auth,
- const AuthorizationItemSet *rights, const AuthorizationItemSet *environment,
- AuthorizationFlags flags,
- AuthorizationItemSet **grantedRights)
-{
- void *rightSet = NULL; mach_msg_size_t rightSet_size = 0;
- void *environ = NULL; mach_msg_size_t environ_size = 0;
- void *result = NULL; mach_msg_type_number_t resultLength = 0;
-
- if ((rights && !copyin_AuthorizationItemSet(rights, &rightSet, &rightSet_size)) ||
- (environment && !copyin_AuthorizationItemSet(environment, &environ, &environ_size)))
- CssmError::throwMe(errAuthorizationInternal); // allocation error probably
-
- activate();
- IPCSTART(ucsp_client_authorizationCopyRights(UCSP_ARGS,
- auth,
- rightSet, rightSet_size,
- flags | (grantedRights ? 0 : kAuthorizationFlagNoData),
- environ, environ_size,
- &result, &resultLength));
-
- free(rightSet);
- free(environ);
-
- // XXX/cs return error when copyout returns false
- if (rcode == CSSM_OK && grantedRights)
- copyout_AuthorizationItemSet(result, resultLength, grantedRights);
-
- if (result)
- mig_deallocate(reinterpret_cast<vm_address_t>(result), resultLength);
- if (rcode == CSSMERR_CSSM_NO_USER_INTERACTION)
- CssmError::throwMe(errAuthorizationInteractionNotAllowed);
- IPCEND_CHECK;
-}
-
-void ClientSession::authCopyInfo(const AuthorizationBlob &auth,
- const char *tag,
- AuthorizationItemSet * &info)
-{
- if (tag == NULL)
- tag = "";
- else if (tag[0] == '\0')
- MacOSError::throwMe(errAuthorizationInvalidTag);
-
- activate();
- void *result; mach_msg_type_number_t resultLength;
- IPCSTART(ucsp_client_authorizationCopyInfo(UCSP_ARGS, auth, tag, &result, &resultLength));
-
- // XXX/cs return error when copyout returns false
- if (rcode == CSSM_OK)
- copyout_AuthorizationItemSet(result, resultLength, &info);
-
- if (result)
- mig_deallocate(reinterpret_cast<vm_address_t>(result), resultLength);
-
- if (rcode == CSSMERR_CSSM_NO_USER_INTERACTION)
- CssmError::throwMe(errAuthorizationInteractionNotAllowed);
- IPCEND_CHECK;
-}
-
-void ClientSession::authExternalize(const AuthorizationBlob &auth,
- AuthorizationExternalForm &extForm)
-{
- activate();
- IPCSTART(ucsp_client_authorizationExternalize(UCSP_ARGS, auth, &extForm));
- if (rcode == CSSMERR_CSSM_NO_USER_INTERACTION)
- CssmError::throwMe(errAuthorizationInteractionNotAllowed);
- IPCEND_CHECK;
-}
-
-void ClientSession::authInternalize(const AuthorizationExternalForm &extForm,
- AuthorizationBlob &auth)
-{
- activate();
- IPCSTART(ucsp_client_authorizationInternalize(UCSP_ARGS, extForm, &auth));
- if (rcode == CSSMERR_CSSM_NO_USER_INTERACTION)
- CssmError::throwMe(errAuthorizationInteractionNotAllowed);
- IPCEND_CHECK;
-}
-
-
-//
-// Push user preferences from an app in user space to securityd
-//
-void ClientSession::setSessionUserPrefs(SecuritySessionId sessionId, uint32_t userPreferencesLength, const void *userPreferences)
-{
- IPC(ucsp_client_setSessionUserPrefs(UCSP_ARGS, sessionId, const_cast<void *>(userPreferences), userPreferencesLength));
-}
-
-