Build android_seapp.c for the host am: 65fe8e161f

Original change: https://android-review.googlesource.com/c/platform/external/selinux/+/2254489

Change-Id: I7b1df9296e6e9b77e341ab45c45176723d11d6d3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Thiébaud Weksteen 2022-10-19 07:04:21 +00:00 committed by Automerger Merge Worker
commit 7d6e2e26b8
2 changed files with 9 additions and 12 deletions

View file

@ -57,6 +57,7 @@ cc_defaults {
srcs: [
"src/android/android.c",
"src/android/android_seapp.c",
"src/avc.c",
"src/avc_internal.c",
"src/avc_sidtab.c",
@ -110,7 +111,6 @@ cc_defaults {
android: {
srcs: [
"src/android/android_device.c",
"src/android/android_seapp.c",
],
static: {
whole_static_libs: [

View file

@ -658,7 +658,7 @@ int set_range_from_level(context_t ctx, enum levelFrom levelFrom, uid_t userid,
char level[255];
switch (levelFrom) {
case LEVELFROM_NONE:
strlcpy(level, "s0", sizeof level);
strncpy(level, "s0", sizeof level);
break;
case LEVELFROM_APP:
snprintf(level, sizeof level, "s0:c%u,c%u",
@ -686,6 +686,12 @@ int set_range_from_level(context_t ctx, enum levelFrom levelFrom, uid_t userid,
return 0;
}
/*
* This code is Android specific, bionic guarantees that
* calls to non-reentrant getpwuid() are thread safe.
*/
struct passwd *(*seapp_getpwuid)(__uid_t uid) = getpwuid;
int seapp_context_lookup(enum seapp_kind kind,
uid_t uid,
bool isSystemServer,
@ -726,19 +732,10 @@ int seapp_context_lookup(enum seapp_kind kind,
userid = uid / AID_USER_OFFSET;
appid = uid % AID_USER_OFFSET;
if (appid < AID_APP_START) {
/*
* This code is Android specific, bionic guarantees that
* calls to non-reentrant getpwuid() are thread safe.
*/
#ifndef __BIONIC__
#warning "This code assumes that getpwuid is thread safe, only true with Bionic!"
#endif
pwd = getpwuid(appid);
pwd = seapp_getpwuid(appid);
if (!pwd)
goto err;
username = pwd->pw_name;
} else if (appid < AID_SDK_SANDBOX_PROCESS_START) {
username = "_app";
appid -= AID_APP_START;