diff options
| author | 2017-07-26 10:47:14 -0700 | |
|---|---|---|
| committer | 2017-08-02 17:01:24 -0700 | |
| commit | fc8d8850ab5164c26386210db2e3fe1bc286b40d (patch) | |
| tree | 3bf312a583d430c9f6395e7690765aa707e6cf23 /libs/gui/BufferQueueConsumer.cpp | |
| parent | 3f68cca4d606454b7b3c5104ff01414630f5cae3 (diff) | |
Use getpwnam()/getgrnam() instead of AID_* macros (libgui)
AID_* values are defined in libcutils private headers and hence
is not exported. Use getpwnam() instead to get these values.
Test: device boots
Bug: 63135587
Change-Id: I417d0472df2170ab190c1c1622117df58292125c
Merged-In: I417d0472df2170ab190c1c1622117df58292125c
Diffstat (limited to 'libs/gui/BufferQueueConsumer.cpp')
| -rw-r--r-- | libs/gui/BufferQueueConsumer.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/libs/gui/BufferQueueConsumer.cpp b/libs/gui/BufferQueueConsumer.cpp index ee4c58cfce..17ff24983c 100644 --- a/libs/gui/BufferQueueConsumer.cpp +++ b/libs/gui/BufferQueueConsumer.cpp @@ -15,6 +15,8 @@ */ #include <inttypes.h> +#include <pwd.h> +#include <sys/types.h> #define LOG_TAG "BufferQueueConsumer" #define ATRACE_TAG ATRACE_TAG_GRAPHICS @@ -34,7 +36,6 @@ #include <binder/IPCThreadState.h> #include <binder/PermissionCache.h> -#include <private/android_filesystem_config.h> namespace android { @@ -734,12 +735,18 @@ status_t BufferQueueConsumer::discardFreeBuffers() { } void BufferQueueConsumer::dumpState(String8& result, const char* prefix) const { + struct passwd* pwd = getpwnam("shell"); + uid_t shellUid = pwd ? pwd->pw_uid : 0; + if (!shellUid) { + BQ_LOGE("Cannot get AID_SHELL"); + return; + } + const IPCThreadState* ipc = IPCThreadState::self(); const pid_t pid = ipc->getCallingPid(); const uid_t uid = ipc->getCallingUid(); - if ((uid != AID_SHELL) - && !PermissionCache::checkPermission(String16( - "android.permission.DUMP"), pid, uid)) { + if ((uid != shellUid) && + !PermissionCache::checkPermission(String16("android.permission.DUMP"), pid, uid)) { result.appendFormat("Permission Denial: can't dump BufferQueueConsumer " "from pid=%d, uid=%d\n", pid, uid); android_errorWriteWithInfoLog(0x534e4554, "27046057", |