summaryrefslogtreecommitdiff
path: root/libs/gui/BufferQueueConsumer.cpp
diff options
context:
space:
mode:
author Yifan Hong <elsk@google.com> 2017-07-26 10:47:14 -0700
committer Yifan Hong <elsk@google.com> 2017-07-26 12:54:35 -0700
commit65799c3f8363e94d7e0c248ca268382e1ecab6b1 (patch)
tree4f725c7d4c7deb3317cef752832b703f1ae61317 /libs/gui/BufferQueueConsumer.cpp
parent572aca270273e751edff03bff169726335d11f8c (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
Diffstat (limited to 'libs/gui/BufferQueueConsumer.cpp')
-rw-r--r--libs/gui/BufferQueueConsumer.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/libs/gui/BufferQueueConsumer.cpp b/libs/gui/BufferQueueConsumer.cpp
index 168d35555f..17cf677e09 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>
#include <system/window.h>
@@ -747,12 +748,19 @@ status_t BufferQueueConsumer::discardFreeBuffers() {
}
status_t BufferQueueConsumer::dumpState(const String8& prefix, String8* outResult) const {
+ struct passwd* pwd = getpwnam("shell");
+ uid_t shellUid = pwd ? pwd->pw_uid : 0;
+ if (!shellUid) {
+ int savedErrno = errno;
+ BQ_LOGE("Cannot get AID_SHELL");
+ return savedErrno ? -savedErrno : UNKNOWN_ERROR;
+ }
+
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)) {
outResult->appendFormat("Permission Denial: can't dump BufferQueueConsumer "
"from pid=%d, uid=%d\n", pid, uid);
android_errorWriteWithInfoLog(0x534e4554, "27046057",