diff options
author | 2023-10-09 19:54:20 +0000 | |
---|---|---|
committer | 2023-10-12 16:07:17 +0000 | |
commit | b8ebcca6826ee6e746c0b2aec5a36f9a5402bef2 (patch) | |
tree | b137f7e12751be1dc4ae93e574b696a00104b6ee | |
parent | 32746ae275593e2532a99c19b2c2e8858a042e3a (diff) |
Don't depend on private/android_filesystem_config.h
Bug: 302723053
Test: mma
Change-Id: I855fedd40dc51fd3a6378f5d011a80797d590092
-rw-r--r-- | libs/binder/Binder.cpp | 9 | ||||
-rw-r--r-- | libs/binder/ndk/ibinder.cpp | 8 |
2 files changed, 12 insertions, 5 deletions
diff --git a/libs/binder/Binder.cpp b/libs/binder/Binder.cpp index aa67869649..9f091ef756 100644 --- a/libs/binder/Binder.cpp +++ b/libs/binder/Binder.cpp @@ -29,7 +29,6 @@ #include <binder/Parcel.h> #include <binder/RecordedTransaction.h> #include <binder/RpcServer.h> -#include <private/android_filesystem_config.h> #include <pthread.h> #include <utils/misc.h> @@ -45,6 +44,8 @@ namespace android { +constexpr uid_t kUidRoot = 0; + // Service implementations inherit from BBinder and IBinder, and this is frozen // in prebuilts. #ifdef __LP64__ @@ -300,7 +301,7 @@ status_t BBinder::startRecordingTransactions(const Parcel& data) { return INVALID_OPERATION; } uid_t uid = IPCThreadState::self()->getCallingUid(); - if (uid != AID_ROOT) { + if (uid != kUidRoot) { ALOGE("Binder recording not allowed because client %" PRIu32 " is not root", uid); return PERMISSION_DENIED; } @@ -330,7 +331,7 @@ status_t BBinder::stopRecordingTransactions() { return INVALID_OPERATION; } uid_t uid = IPCThreadState::self()->getCallingUid(); - if (uid != AID_ROOT) { + if (uid != kUidRoot) { ALOGE("Binder recording not allowed because client %" PRIu32 " is not root", uid); return PERMISSION_DENIED; } @@ -634,7 +635,7 @@ status_t BBinder::setRpcClientDebug(const Parcel& data) { return INVALID_OPERATION; } uid_t uid = IPCThreadState::self()->getCallingUid(); - if (uid != AID_ROOT) { + if (uid != kUidRoot) { ALOGE("%s: not allowed because client %" PRIu32 " is not root", __PRETTY_FUNCTION__, uid); return PERMISSION_DENIED; } diff --git a/libs/binder/ndk/ibinder.cpp b/libs/binder/ndk/ibinder.cpp index f7dd9c9715..47da296b70 100644 --- a/libs/binder/ndk/ibinder.cpp +++ b/libs/binder/ndk/ibinder.cpp @@ -21,7 +21,9 @@ #include <android/binder_status.h> #include <binder/IPCThreadState.h> #include <binder/IResultReceiver.h> +#if __has_include(<private/android_filesystem_config.h>) #include <private/android_filesystem_config.h> +#endif #include "ibinder_internal.h" #include "parcel_internal.h" @@ -229,7 +231,11 @@ status_t ABBinder::onTransact(transaction_code_t code, const Parcel& data, Parce // Shell commands should only be callable by ADB. uid_t uid = AIBinder_getCallingUid(); - if (uid != AID_ROOT && uid != AID_SHELL) { + if (uid != 0 /* root */ +#ifdef AID_SHELL + && uid != AID_SHELL +#endif + ) { if (resultReceiver != nullptr) { resultReceiver->send(-1); } |