diff options
Diffstat (limited to 'drm/drmserver/DrmManagerService.cpp')
| -rw-r--r-- | drm/drmserver/DrmManagerService.cpp | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/drm/drmserver/DrmManagerService.cpp b/drm/drmserver/DrmManagerService.cpp index dad599b42e..2600a2c23e 100644 --- a/drm/drmserver/DrmManagerService.cpp +++ b/drm/drmserver/DrmManagerService.cpp @@ -58,22 +58,26 @@ const char *DrmManagerService::get_perm_label(drm_perm_t perm) { return drm_perm_labels[index]; } -bool DrmManagerService::selinuxIsProtectedCallAllowed(pid_t spid, drm_perm_t perm) { +bool DrmManagerService::selinuxIsProtectedCallAllowed(pid_t spid, const char* ssid, drm_perm_t perm) { if (selinux_enabled <= 0) { return true; } - char *sctx; + char *sctx = NULL; const char *selinux_class = "drmservice"; const char *str_perm = get_perm_label(perm); - if (getpidcon(spid, &sctx) != 0) { - ALOGE("SELinux: getpidcon(pid=%d) failed.\n", spid); - return false; + if (ssid == NULL) { + android_errorWriteLog(0x534e4554, "121035042"); + + if (getpidcon(spid, &sctx) != 0) { + ALOGE("SELinux: getpidcon(pid=%d) failed.\n", spid); + return false; + } } - bool allowed = (selinux_check_access(sctx, drmserver_context, selinux_class, - str_perm, NULL) == 0); + bool allowed = (selinux_check_access(ssid ? ssid : sctx, drmserver_context, + selinux_class, str_perm, NULL) == 0); freecon(sctx); return allowed; @@ -86,10 +90,11 @@ bool DrmManagerService::isProtectedCallAllowed(drm_perm_t perm) { IPCThreadState* ipcState = IPCThreadState::self(); uid_t uid = ipcState->getCallingUid(); pid_t spid = ipcState->getCallingPid(); + const char* ssid = ipcState->getCallingSid(); for (unsigned int i = 0; i < trustedUids.size(); ++i) { if (trustedUids[i] == uid) { - return selinuxIsProtectedCallAllowed(spid, perm); + return selinuxIsProtectedCallAllowed(spid, ssid, perm); } } return false; @@ -97,7 +102,9 @@ bool DrmManagerService::isProtectedCallAllowed(drm_perm_t perm) { void DrmManagerService::instantiate() { ALOGV("instantiate"); - defaultServiceManager()->addService(String16("drm.drmManager"), new DrmManagerService()); + sp<DrmManagerService> service = new DrmManagerService(); + service->setRequestingSid(true); + defaultServiceManager()->addService(String16("drm.drmManager"), service); if (0 >= trustedUids.size()) { // TODO @@ -206,7 +213,7 @@ int DrmManagerService::checkRightsStatus( } status_t DrmManagerService::consumeRights( - int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) { + int uniqueId, sp<DecryptHandle>& decryptHandle, int action, bool reserve) { ALOGV("Entering consumeRights"); if (!isProtectedCallAllowed(CONSUME_RIGHTS)) { return DRM_ERROR_NO_PERMISSION; @@ -215,7 +222,7 @@ status_t DrmManagerService::consumeRights( } status_t DrmManagerService::setPlaybackStatus( - int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position) { + int uniqueId, sp<DecryptHandle>& decryptHandle, int playbackStatus, int64_t position) { ALOGV("Entering setPlaybackStatus"); if (!isProtectedCallAllowed(SET_PLAYBACK_STATUS)) { return DRM_ERROR_NO_PERMISSION; @@ -262,7 +269,7 @@ status_t DrmManagerService::getAllSupportInfo( return mDrmManager->getAllSupportInfo(uniqueId, length, drmSupportInfoArray); } -DecryptHandle* DrmManagerService::openDecryptSession( +sp<DecryptHandle> DrmManagerService::openDecryptSession( int uniqueId, int fd, off64_t offset, off64_t length, const char* mime) { ALOGV("Entering DrmManagerService::openDecryptSession"); if (isProtectedCallAllowed(OPEN_DECRYPT_SESSION)) { @@ -272,7 +279,7 @@ DecryptHandle* DrmManagerService::openDecryptSession( return NULL; } -DecryptHandle* DrmManagerService::openDecryptSession( +sp<DecryptHandle> DrmManagerService::openDecryptSession( int uniqueId, const char* uri, const char* mime) { ALOGV("Entering DrmManagerService::openDecryptSession with uri"); if (isProtectedCallAllowed(OPEN_DECRYPT_SESSION)) { @@ -282,7 +289,7 @@ DecryptHandle* DrmManagerService::openDecryptSession( return NULL; } -DecryptHandle* DrmManagerService::openDecryptSession( +sp<DecryptHandle> DrmManagerService::openDecryptSession( int uniqueId, const DrmBuffer& buf, const String8& mimeType) { ALOGV("Entering DrmManagerService::openDecryptSession for streaming"); if (isProtectedCallAllowed(OPEN_DECRYPT_SESSION)) { @@ -292,7 +299,7 @@ DecryptHandle* DrmManagerService::openDecryptSession( return NULL; } -status_t DrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) { +status_t DrmManagerService::closeDecryptSession(int uniqueId, sp<DecryptHandle>& decryptHandle) { ALOGV("Entering closeDecryptSession"); if (!isProtectedCallAllowed(CLOSE_DECRYPT_SESSION)) { return DRM_ERROR_NO_PERMISSION; @@ -300,7 +307,7 @@ status_t DrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* dec return mDrmManager->closeDecryptSession(uniqueId, decryptHandle); } -status_t DrmManagerService::initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, +status_t DrmManagerService::initializeDecryptUnit(int uniqueId, sp<DecryptHandle>& decryptHandle, int decryptUnitId, const DrmBuffer* headerInfo) { ALOGV("Entering initializeDecryptUnit"); if (!isProtectedCallAllowed(INITIALIZE_DECRYPT_UNIT)) { @@ -310,7 +317,7 @@ status_t DrmManagerService::initializeDecryptUnit(int uniqueId, DecryptHandle* d } status_t DrmManagerService::decrypt( - int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId, + int uniqueId, sp<DecryptHandle>& decryptHandle, int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) { ALOGV("Entering decrypt"); if (!isProtectedCallAllowed(DECRYPT)) { @@ -320,7 +327,7 @@ status_t DrmManagerService::decrypt( } status_t DrmManagerService::finalizeDecryptUnit( - int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) { + int uniqueId, sp<DecryptHandle>& decryptHandle, int decryptUnitId) { ALOGV("Entering finalizeDecryptUnit"); if (!isProtectedCallAllowed(FINALIZE_DECRYPT_UNIT)) { return DRM_ERROR_NO_PERMISSION; @@ -328,7 +335,7 @@ status_t DrmManagerService::finalizeDecryptUnit( return mDrmManager->finalizeDecryptUnit(uniqueId, decryptHandle, decryptUnitId); } -ssize_t DrmManagerService::pread(int uniqueId, DecryptHandle* decryptHandle, +ssize_t DrmManagerService::pread(int uniqueId, sp<DecryptHandle>& decryptHandle, void* buffer, ssize_t numBytes, off64_t offset) { ALOGV("Entering pread"); if (!isProtectedCallAllowed(PREAD)) { |
