Export dummy functions for libselinux_vendor

The following functions are exported in libselinux_vendor, but
simply returns an error:

selinux_android_prop_context_handle
selinux_android_restorecon

Bug: 62886649
Test: BOARD_VNDK_VERSION=current m libselinux_vendor -j
Test: m libselinux_vendor -j
Test: device boots
Change-Id: If42b6cb1bf9ffb3dd04f557279efdc37e1ac259a
Merged-In: If42b6cb1bf9ffb3dd04f557279efdc37e1ac259a
(cherry picked from commit 1e8760189d)
This commit is contained in:
Yifan Hong 2017-07-05 12:00:24 -07:00
parent 4b5cfdcd0a
commit 7e29d17754
5 changed files with 55 additions and 36 deletions

View file

@ -102,6 +102,10 @@ cc_library_shared {
version_script: "exported_vendor.map",
},
},
srcs: [
"src/android/android_vendor.c",
],
}
cc_library {

View file

@ -13,6 +13,8 @@
selabel_close;
selabel_lookup;
selabel_open;
selinux_android_prop_context_handle;
selinux_android_restorecon;
selinux_android_service_context_handle;
selinux_android_vendor_service_context_handle;
selinux_check_access;

View file

@ -6,16 +6,6 @@
#endif // LOG_EVENT_STRING
#endif // __ANDROID_VNDK__
static const struct selinux_opt seopts_prop_split[] = {
{ SELABEL_OPT_PATH, "/system/etc/selinux/plat_property_contexts" },
{ SELABEL_OPT_PATH, "/vendor/etc/selinux/nonplat_property_contexts"}
};
static const struct selinux_opt seopts_prop_rootfs[] = {
{ SELABEL_OPT_PATH, "/plat_property_contexts" },
{ SELABEL_OPT_PATH, "/nonplat_property_contexts"}
};
static const struct selinux_opt seopts_service_split[] = {
{ SELABEL_OPT_PATH, "/system/etc/selinux/plat_service_contexts" },
{ SELABEL_OPT_PATH, "/vendor/etc/selinux/nonplat_service_contexts" }
@ -42,32 +32,6 @@ static const struct selinux_opt seopts_vndservice =
static const struct selinux_opt seopts_vndservice_rootfs =
{ SELABEL_OPT_PATH, "/vndservice_contexts" };
struct selabel_handle* selinux_android_prop_context_handle(void)
{
struct selabel_handle* sehandle;
const struct selinux_opt* seopts_prop;
// Prefer files from /system & /vendor, fall back to files from /
if (access(seopts_prop_split[0].value, R_OK) != -1) {
seopts_prop = seopts_prop_split;
} else {
seopts_prop = seopts_prop_rootfs;
}
sehandle = selabel_open(SELABEL_CTX_ANDROID_PROP,
seopts_prop, 2);
if (!sehandle) {
selinux_log(SELINUX_ERROR, "%s: Error getting property context handle (%s)\n",
__FUNCTION__, strerror(errno));
return NULL;
}
selinux_log(SELINUX_INFO, "SELinux: Loaded property_contexts from %s & %s.\n",
seopts_prop[0].value, seopts_prop[1].value);
return sehandle;
}
struct selabel_handle* selinux_android_service_open_context_handle(const struct selinux_opt* seopts_service,
unsigned nopts)
{

View file

@ -12,6 +12,16 @@ static const struct selinux_opt seopts_file_rootfs[] = {
{ SELABEL_OPT_PATH, "/file_contexts.bin" }
};
static const struct selinux_opt seopts_prop_split[] = {
{ SELABEL_OPT_PATH, "/system/etc/selinux/plat_property_contexts" },
{ SELABEL_OPT_PATH, "/vendor/etc/selinux/nonplat_property_contexts"}
};
static const struct selinux_opt seopts_prop_rootfs[] = {
{ SELABEL_OPT_PATH, "/plat_property_contexts" },
{ SELABEL_OPT_PATH, "/nonplat_property_contexts"}
};
/*
* XXX Where should this configuration file be located?
* Needs to be accessible by zygote and installd when
@ -133,6 +143,31 @@ struct selabel_handle* selinux_android_file_context_handle(void)
}
}
struct selabel_handle* selinux_android_prop_context_handle(void)
{
struct selabel_handle* sehandle;
const struct selinux_opt* seopts_prop;
// Prefer files from /system & /vendor, fall back to files from /
if (access(seopts_prop_split[0].value, R_OK) != -1) {
seopts_prop = seopts_prop_split;
} else {
seopts_prop = seopts_prop_rootfs;
}
sehandle = selabel_open(SELABEL_CTX_ANDROID_PROP,
seopts_prop, 2);
if (!sehandle) {
selinux_log(SELINUX_ERROR, "%s: Error getting property context handle (%s)\n",
__FUNCTION__, strerror(errno));
return NULL;
}
selinux_log(SELINUX_INFO, "SELinux: Loaded property_contexts from %s & %s.\n",
seopts_prop[0].value, seopts_prop[1].value);
return sehandle;
}
enum levelFrom {
LEVELFROM_NONE,
LEVELFROM_APP,

View file

@ -0,0 +1,14 @@
#include "android_common.h"
int selinux_android_restorecon(const char *file __attribute__((unused)),
unsigned int flags __attribute__((unused)))
{
selinux_log(SELINUX_ERROR, "%s: not implemented for libselinux_vendor\n", __FUNCTION__);
return -1;
}
struct selabel_handle* selinux_android_prop_context_handle(void)
{
selinux_log(SELINUX_ERROR, "%s: not implemented for libselinux_vendor\n", __FUNCTION__);
return NULL;
}