Add BusyBox SELinux support

Close #1523
This commit is contained in:
topjohnwu 2020-01-20 20:48:05 +08:00
parent fb60bea659
commit c3e77b1ec1
5 changed files with 111 additions and 1 deletions

3
.gitmodules vendored
View File

@ -22,6 +22,9 @@
[submodule "mincrypt"]
path = native/jni/external/mincrypt
url = https://github.com/topjohnwu/mincrypt.git
[submodule "pcre"]
path = native/jni/external/pcre
url = https://android.googlesource.com/platform/external/pcre
[submodule "termux-elf-cleaner"]
path = tools/termux-elf-cleaner
url = https://github.com/termux/termux-elf-cleaner.git

View File

@ -14,6 +14,7 @@ LIBSYSTEMPROPERTIES := jni/systemproperties/include
LIBUTILS := jni/utils/include
LIBMINCRYPT := $(EXT_PATH)/mincrypt/include
LIBXZ := $(EXT_PATH)/xz-embedded
LIBPCRE2 := $(EXT_PATH)/pcre/include
########################
# Binaries

View File

@ -234,4 +234,109 @@ LOCAL_SRC_FILES := \
LOCAL_CFLAGS += -Dgetline=__getline -Wno-implicit-function-declaration
include $(BUILD_STATIC_LIBRARY)
# libpcre2.a
include $(CLEAR_VARS)
LOCAL_MODULE:= libpcre2
LOCAL_CFLAGS := -DHAVE_CONFIG_H
LOCAL_C_INCLUDES := $(LIBPCRE2) $(LIBPCRE2)_internal
LOCAL_SRC_FILES := \
pcre/dist2/src/pcre2_auto_possess.c \
pcre/dist2/src/pcre2_chartables.c \
pcre/dist2/src/pcre2_compile.c \
pcre/dist2/src/pcre2_config.c \
pcre/dist2/src/pcre2_context.c \
pcre/dist2/src/pcre2_convert.c \
pcre/dist2/src/pcre2_dfa_match.c \
pcre/dist2/src/pcre2_error.c \
pcre/dist2/src/pcre2_extuni.c \
pcre/dist2/src/pcre2_find_bracket.c \
pcre/dist2/src/pcre2_fuzzsupport.c \
pcre/dist2/src/pcre2_jit_compile.c \
pcre/dist2/src/pcre2_maketables.c \
pcre/dist2/src/pcre2_match.c \
pcre/dist2/src/pcre2_match_data.c \
pcre/dist2/src/pcre2_newline.c \
pcre/dist2/src/pcre2_ord2utf.c \
pcre/dist2/src/pcre2_pattern_info.c \
pcre/dist2/src/pcre2_script_run.c \
pcre/dist2/src/pcre2_serialize.c \
pcre/dist2/src/pcre2_string_utils.c \
pcre/dist2/src/pcre2_study.c \
pcre/dist2/src/pcre2_substitute.c \
pcre/dist2/src/pcre2_substring.c \
pcre/dist2/src/pcre2_tables.c \
pcre/dist2/src/pcre2_ucd.c \
pcre/dist2/src/pcre2_valid_utf.c \
pcre/dist2/src/pcre2_xclass.c
include $(BUILD_STATIC_LIBRARY)
# libselinux.a
include $(CLEAR_VARS)
LOCAL_MODULE:= libselinux
LOCAL_C_INCLUDES := $(LIBSELINUX) $(LIBPCRE2)
LOCAL_STATIC_LIBRARIES := libpcre2
LOCAL_CFLAGS := \
-Wno-implicit-function-declaration -Wno-int-conversion -Wno-unused-function \
-D_GNU_SOURCE -DUSE_PCRE2 \
-DNO_PERSISTENTLY_STORED_PATTERNS -DDISABLE_SETRANS -DDISABLE_BOOL \
-DNO_MEDIA_BACKEND -DNO_X_BACKEND -DNO_DB_BACKEND -DNO_ANDROID_BACKEND
LOCAL_SRC_FILES := \
selinux/libselinux/src/avc.c \
selinux/libselinux/src/avc_internal.c \
selinux/libselinux/src/avc_sidtab.c \
selinux/libselinux/src/booleans.c \
selinux/libselinux/src/callbacks.c \
selinux/libselinux/src/canonicalize_context.c \
selinux/libselinux/src/checkAccess.c \
selinux/libselinux/src/check_context.c \
selinux/libselinux/src/checkreqprot.c \
selinux/libselinux/src/compute_av.c \
selinux/libselinux/src/compute_create.c \
selinux/libselinux/src/compute_member.c \
selinux/libselinux/src/compute_relabel.c \
selinux/libselinux/src/compute_user.c \
selinux/libselinux/src/context.c \
selinux/libselinux/src/deny_unknown.c \
selinux/libselinux/src/disable.c \
selinux/libselinux/src/enabled.c \
selinux/libselinux/src/fgetfilecon.c \
selinux/libselinux/src/freecon.c \
selinux/libselinux/src/freeconary.c \
selinux/libselinux/src/fsetfilecon.c \
selinux/libselinux/src/get_context_list.c \
selinux/libselinux/src/get_default_type.c \
selinux/libselinux/src/get_initial_context.c \
selinux/libselinux/src/getenforce.c \
selinux/libselinux/src/getfilecon.c \
selinux/libselinux/src/getpeercon.c \
selinux/libselinux/src/init.c \
selinux/libselinux/src/is_customizable_type.c \
selinux/libselinux/src/label.c \
selinux/libselinux/src/label_file.c \
selinux/libselinux/src/label_support.c \
selinux/libselinux/src/lgetfilecon.c \
selinux/libselinux/src/load_policy.c \
selinux/libselinux/src/lsetfilecon.c \
selinux/libselinux/src/mapping.c \
selinux/libselinux/src/matchmediacon.c \
selinux/libselinux/src/matchpathcon.c \
selinux/libselinux/src/policyvers.c \
selinux/libselinux/src/procattr.c \
selinux/libselinux/src/query_user_context.c \
selinux/libselinux/src/regex.c \
selinux/libselinux/src/reject_unknown.c \
selinux/libselinux/src/selinux_check_securetty_context.c \
selinux/libselinux/src/selinux_config.c \
selinux/libselinux/src/selinux_restorecon.c \
selinux/libselinux/src/sestatus.c \
selinux/libselinux/src/setenforce.c \
selinux/libselinux/src/setexecfilecon.c \
selinux/libselinux/src/setfilecon.c \
selinux/libselinux/src/setrans_client.c \
selinux/libselinux/src/seusers.c \
selinux/libselinux/src/sha1.c \
selinux/libselinux/src/stringrep.c \
selinux/libselinux/src/validatetrans.c
include $(BUILD_STATIC_LIBRARY)
include $(EXT_PATH)/mincrypt/Android.mk

@ -1 +1 @@
Subproject commit 23132f3d45089f9c0e495ec5365993f4b2ef348c
Subproject commit d5fcb3daedcc5481296c0002889c5d7cdd957a43

1
native/jni/external/pcre vendored Submodule

@ -0,0 +1 @@
Subproject commit 986dc24ace8aea66189a95510813747155fa3800