summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArve Hjønnevåg <arve@android.com>2016-08-18 15:42:35 -0700
committerJessica Wagantall <jwagantall@cyngn.com>2016-10-04 16:01:05 -0700
commit3410f246f26b3aaea6d219c9e8c76cd218ec65f4 (patch)
tree76492bce232e4d3d29f77896df3d5b1e734f1321
parent5f31ee56f97f98d220abe61a3979ac662b2da9b9 (diff)
downloadandroid_frameworks_native-stable/cm-13.0-ZNH2K.tar.gz
android_frameworks_native-stable/cm-13.0-ZNH2K.tar.bz2
android_frameworks_native-stable/cm-13.0-ZNH2K.zip
ServiceManager: Allow system services running as secondary users to add servicesstable/cm-13.0-ZNH2K
This should be reverted when all system services have been cleaned up to not do this. A process looking up a service while running in the background will see the service registered by the active user (assuming the service is registered on every user switch), not the service registered by the user that the process itself belongs to. CYNGNOS-3286 BUG: 30795333 Change-Id: I1b74d58be38ed358f43c163692f9e704f8f31dbe (cherry picked from commit e6bbe69ba739c8a08837134437aaccfea5f1d943) (cherry picked from commit 2f2de7479538e05af5b7a99b7cc674f6cfbb45d1)
-rw-r--r--cmds/servicemanager/Android.mk2
-rw-r--r--cmds/servicemanager/service_manager.c4
2 files changed, 4 insertions, 2 deletions
diff --git a/cmds/servicemanager/Android.mk b/cmds/servicemanager/Android.mk
index 155cfc503..5bafd5343 100644
--- a/cmds/servicemanager/Android.mk
+++ b/cmds/servicemanager/Android.mk
@@ -18,7 +18,7 @@ LOCAL_MODULE_TAGS := optional
include $(BUILD_EXECUTABLE)
include $(CLEAR_VARS)
-LOCAL_SHARED_LIBRARIES := liblog libselinux
+LOCAL_SHARED_LIBRARIES := liblog libcutils libselinux
LOCAL_SRC_FILES := service_manager.c binder.c
LOCAL_CFLAGS += $(svc_c_flags)
LOCAL_MODULE := servicemanager
diff --git a/cmds/servicemanager/service_manager.c b/cmds/servicemanager/service_manager.c
index 4c993c236..031f84897 100644
--- a/cmds/servicemanager/service_manager.c
+++ b/cmds/servicemanager/service_manager.c
@@ -8,6 +8,8 @@
#include <stdlib.h>
#include <string.h>
+#include <cutils/multiuser.h>
+
#include <private/android_filesystem_config.h>
#include <selinux/android.h>
@@ -111,7 +113,7 @@ static int svc_can_register(const uint16_t *name, size_t name_len, pid_t spid, u
{
const char *perm = "add";
- if (uid >= AID_APP) {
+ if (multiuser_get_app_id(uid) >= AID_APP) {
return 0; /* Don't allow apps to register services */
}