Skip to content

Commit 3284a1d

Browse files
committed
selinux: enable support for bionic, add applets in config
require libsepol package (mm in external/libsepol or add package) Tested applets: getenforce, setenforce, sestatus, selinuxenabled, ls -Z, tar -c, getsebool, setsebool, runcon, matchpathcon, chcon, restorecon, setfiles Notes: matchpathcon selabel_lookup was broken by the incompatible regexec which is now in bionic libc (netbsd part), libselinux linkage used busybox one, so a rename of internal regex functions was required recovery will not use bb_regex lib, so regex commands could not work exactly like xbin or static ones (sed/less/expr/awk/pgrep) this is already the case, and can be changed by including libregex package in recovery + ifdef in xregex.h Signed-off-by: Tanguy Pruvot <[email protected]> Change-Id: Id82b8a7672a669e3f95360bb70b7b127591f2080
1 parent 2955fd1 commit 3284a1d

32 files changed

+8569
-6835
lines changed

.config-full

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
22
# Automatically generated make config: don't edit
33
# Busybox version: 1.22.1
4-
# Sun Apr 6 21:24:01 2014
4+
# Thu May 29 17:30:26 2014
55
#
66
CONFIG_HAVE_DOT_CONFIG=y
77

@@ -23,7 +23,7 @@ CONFIG_FEATURE_BUFFERS_USE_MALLOC=y
2323
CONFIG_SHOW_USAGE=y
2424
CONFIG_FEATURE_VERBOSE_USAGE=y
2525
CONFIG_FEATURE_COMPRESS_USAGE=y
26-
# CONFIG_FEATURE_INSTALLER is not set
26+
CONFIG_FEATURE_INSTALLER=y
2727
CONFIG_INSTALL_NO_USR=y
2828
# CONFIG_LOCALE_SUPPORT is not set
2929
CONFIG_UNICODE_SUPPORT=y
@@ -46,7 +46,7 @@ CONFIG_PID_FILE_PATH=""
4646
CONFIG_FEATURE_SUID=y
4747
# CONFIG_FEATURE_SUID_CONFIG is not set
4848
# CONFIG_FEATURE_SUID_CONFIG_QUIET is not set
49-
# CONFIG_SELINUX is not set
49+
CONFIG_SELINUX=y
5050
# CONFIG_FEATURE_PREFER_APPLETS is not set
5151
CONFIG_BUSYBOX_EXEC_PATH="/proc/self/exe"
5252
CONFIG_FEATURE_SYSLOG=y
@@ -167,7 +167,7 @@ CONFIG_FEATURE_TAR_LONG_OPTIONS=y
167167
CONFIG_FEATURE_TAR_TO_COMMAND=y
168168
CONFIG_FEATURE_TAR_UNAME_GNAME=y
169169
CONFIG_FEATURE_TAR_NOPRESERVE_TIME=y
170-
# CONFIG_FEATURE_TAR_SELINUX is not set
170+
CONFIG_FEATURE_TAR_SELINUX=y
171171
CONFIG_UNZIP=y
172172

173173
#
@@ -945,21 +945,25 @@ CONFIG_SV_DEFAULT_SERVICE_DIR=""
945945
# CONFIG_ENVUIDGID is not set
946946
# CONFIG_ENVDIR is not set
947947
# CONFIG_SOFTLIMIT is not set
948-
# CONFIG_CHCON is not set
949-
# CONFIG_FEATURE_CHCON_LONG_OPTIONS is not set
950-
# CONFIG_GETENFORCE is not set
951-
# CONFIG_GETSEBOOL is not set
948+
949+
#
950+
# SELinux Utilities
951+
#
952+
CONFIG_CHCON=y
953+
CONFIG_FEATURE_CHCON_LONG_OPTIONS=y
954+
CONFIG_GETENFORCE=y
955+
CONFIG_GETSEBOOL=y
952956
# CONFIG_LOAD_POLICY is not set
953-
# CONFIG_MATCHPATHCON is not set
954-
# CONFIG_RESTORECON is not set
955-
# CONFIG_RUNCON is not set
956-
# CONFIG_FEATURE_RUNCON_LONG_OPTIONS is not set
957-
# CONFIG_SELINUXENABLED is not set
958-
# CONFIG_SETENFORCE is not set
959-
# CONFIG_SETFILES is not set
957+
CONFIG_MATCHPATHCON=y
958+
CONFIG_RESTORECON=y
959+
CONFIG_RUNCON=y
960+
CONFIG_FEATURE_RUNCON_LONG_OPTIONS=y
961+
CONFIG_SELINUXENABLED=y
962+
CONFIG_SETENFORCE=y
963+
CONFIG_SETFILES=y
960964
# CONFIG_FEATURE_SETFILES_CHECK_OPTION is not set
961-
# CONFIG_SETSEBOOL is not set
962-
# CONFIG_SESTATUS is not set
965+
CONFIG_SETSEBOOL=y
966+
CONFIG_SESTATUS=y
963967

964968
#
965969
# Shells

.config-minimal

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
22
# Automatically generated make config: don't edit
33
# Busybox version: 1.22.1
4-
# Sun Apr 6 21:23:53 2014
4+
# Thu May 29 17:30:21 2014
55
#
66
CONFIG_HAVE_DOT_CONFIG=y
77

@@ -46,7 +46,7 @@ CONFIG_PID_FILE_PATH=""
4646
CONFIG_FEATURE_SUID=y
4747
# CONFIG_FEATURE_SUID_CONFIG is not set
4848
# CONFIG_FEATURE_SUID_CONFIG_QUIET is not set
49-
# CONFIG_SELINUX is not set
49+
CONFIG_SELINUX=y
5050
# CONFIG_FEATURE_PREFER_APPLETS is not set
5151
CONFIG_BUSYBOX_EXEC_PATH="/proc/self/exe"
5252
# CONFIG_FEATURE_SYSLOG is not set
@@ -167,7 +167,7 @@ CONFIG_FEATURE_TAR_LONG_OPTIONS=y
167167
# CONFIG_FEATURE_TAR_TO_COMMAND is not set
168168
# CONFIG_FEATURE_TAR_UNAME_GNAME is not set
169169
CONFIG_FEATURE_TAR_NOPRESERVE_TIME=y
170-
# CONFIG_FEATURE_TAR_SELINUX is not set
170+
CONFIG_FEATURE_TAR_SELINUX=y
171171
CONFIG_UNZIP=y
172172

173173
#
@@ -941,21 +941,25 @@ CONFIG_SV_DEFAULT_SERVICE_DIR=""
941941
# CONFIG_ENVUIDGID is not set
942942
# CONFIG_ENVDIR is not set
943943
# CONFIG_SOFTLIMIT is not set
944-
# CONFIG_CHCON is not set
944+
945+
#
946+
# SELinux Utilities
947+
#
948+
CONFIG_CHCON=y
945949
# CONFIG_FEATURE_CHCON_LONG_OPTIONS is not set
946-
# CONFIG_GETENFORCE is not set
947-
# CONFIG_GETSEBOOL is not set
950+
CONFIG_GETENFORCE=y
951+
CONFIG_GETSEBOOL=y
948952
# CONFIG_LOAD_POLICY is not set
949-
# CONFIG_MATCHPATHCON is not set
950-
# CONFIG_RESTORECON is not set
953+
CONFIG_MATCHPATHCON=y
954+
CONFIG_RESTORECON=y
951955
# CONFIG_RUNCON is not set
952956
# CONFIG_FEATURE_RUNCON_LONG_OPTIONS is not set
953-
# CONFIG_SELINUXENABLED is not set
954-
# CONFIG_SETENFORCE is not set
955-
# CONFIG_SETFILES is not set
957+
CONFIG_SELINUXENABLED=y
958+
CONFIG_SETENFORCE=y
959+
CONFIG_SETFILES=y
956960
# CONFIG_FEATURE_SETFILES_CHECK_OPTION is not set
957-
# CONFIG_SETSEBOOL is not set
958-
# CONFIG_SESTATUS is not set
961+
CONFIG_SETSEBOOL=y
962+
CONFIG_SESTATUS=y
959963

960964
#
961965
# Shells

Android.mk

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ BIONIC_ICS := true
77

88
# Make a static library for regex.
99
include $(CLEAR_VARS)
10-
LOCAL_SRC_FILES := android/regex/regex.c
10+
LOCAL_SRC_FILES := android/regex/bb_regex.c
1111
LOCAL_C_INCLUDES := $(BB_PATH)/android/regex
1212
LOCAL_CFLAGS := -Wno-sign-compare
1313
LOCAL_MODULE := libclearsilverregex
@@ -113,6 +113,8 @@ BUSYBOX_C_INCLUDES = \
113113
bionic/libm/include \
114114
bionic/libm \
115115
libc/kernel/common \
116+
external/libselinux/include \
117+
external/libsepol/include \
116118
$(BB_PATH)/android/regex \
117119
$(BB_PATH)/android/librpc
118120

@@ -139,6 +141,7 @@ LOCAL_SRC_FILES := $(BUSYBOX_SRC_FILES)
139141
LOCAL_C_INCLUDES := $(BUSYBOX_C_INCLUDES)
140142
LOCAL_CFLAGS := -Dmain=busybox_driver $(BUSYBOX_CFLAGS)
141143
LOCAL_CFLAGS += \
144+
-DRECOVERY_VERSION \
142145
-Dgetusershell=busybox_getusershell \
143146
-Dsetusershell=busybox_setusershell \
144147
-Dendusershell=busybox_endusershell \
@@ -148,7 +151,7 @@ LOCAL_CFLAGS += \
148151
-Dgenerate_uuid=busybox_generate_uuid
149152
LOCAL_MODULE := libbusybox
150153
LOCAL_MODULE_TAGS := eng debug
151-
LOCAL_STATIC_LIBRARIES := libcutils libc libm
154+
LOCAL_STATIC_LIBRARIES := libcutils libc libm libselinux libsepol
152155
$(LOCAL_MODULE): busybox_prepare
153156
include $(BUILD_STATIC_LIBRARY)
154157

@@ -171,7 +174,7 @@ LOCAL_MODULE := busybox
171174
LOCAL_MODULE_TAGS := eng debug
172175
LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
173176
LOCAL_SHARED_LIBRARIES := libc libcutils libm
174-
LOCAL_STATIC_LIBRARIES := libclearsilverregex libuclibcrpc
177+
LOCAL_STATIC_LIBRARIES := libclearsilverregex libuclibcrpc libselinux libsepol
175178
$(LOCAL_MODULE): busybox_prepare
176179
include $(BUILD_EXECUTABLE)
177180

@@ -217,7 +220,7 @@ LOCAL_FORCE_STATIC_EXECUTABLE := true
217220
LOCAL_MODULE := static_busybox
218221
LOCAL_MODULE_STEM := busybox
219222
LOCAL_MODULE_TAGS := optional
220-
LOCAL_STATIC_LIBRARIES := libclearsilverregex libc libcutils libm libuclibcrpc
223+
LOCAL_STATIC_LIBRARIES := libclearsilverregex libc libcutils libm libuclibcrpc libselinux libsepol
221224
LOCAL_MODULE_CLASS := UTILITY_EXECUTABLES
222225
LOCAL_MODULE_PATH := $(PRODUCT_OUT)/utilities
223226
LOCAL_UNSTRIPPED_PATH := $(PRODUCT_OUT)/symbols/utilities
Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ init_syntax_once ()
161161
#endif /* not emacs */
162162

163163
/* Get the interface, including the syntax bits. */
164-
#include "regex.h"
164+
#include "bb_regex.h"
165165

166166
/* isalpha etc. are used for the character classes. */
167167
#include <ctype.h>
@@ -922,7 +922,7 @@ reg_syntax_t re_syntax_options;
922922
defined in regex.h. We return the old syntax. */
923923

924924
reg_syntax_t
925-
re_set_syntax (syntax)
925+
bb_re_set_syntax (syntax)
926926
reg_syntax_t syntax;
927927
{
928928
reg_syntax_t ret = re_syntax_options;
@@ -2917,7 +2917,7 @@ compile_range (p_ptr, pend, translate, syntax, b)
29172917
Returns 0 if we succeed, -2 if an internal error. */
29182918

29192919
int
2920-
re_compile_fastmap (bufp)
2920+
bb_re_compile_fastmap (bufp)
29212921
struct re_pattern_buffer *bufp;
29222922
{
29232923
int j, k;
@@ -3223,7 +3223,7 @@ re_compile_fastmap (bufp)
32233223
freeing the old data. */
32243224

32253225
void
3226-
re_set_registers (bufp, regs, num_regs, starts, ends)
3226+
bb_re_set_registers (bufp, regs, num_regs, starts, ends)
32273227
struct re_pattern_buffer *bufp;
32283228
struct re_registers *regs;
32293229
unsigned num_regs;
@@ -3250,13 +3250,13 @@ re_set_registers (bufp, regs, num_regs, starts, ends)
32503250
doesn't let you say where to stop matching. */
32513251

32523252
int
3253-
re_search (bufp, string, size, startpos, range, regs)
3253+
bb_re_search (bufp, string, size, startpos, range, regs)
32543254
struct re_pattern_buffer *bufp;
32553255
const char *string;
32563256
int size, startpos, range;
32573257
struct re_registers *regs;
32583258
{
3259-
return re_search_2 (bufp, NULL, 0, string, size, startpos, range,
3259+
return bb_re_search_2 (bufp, NULL, 0, string, size, startpos, range,
32603260
regs, size);
32613261
}
32623262

@@ -3283,7 +3283,7 @@ re_search (bufp, string, size, startpos, range, regs)
32833283
stack overflow). */
32843284

32853285
int
3286-
re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop)
3286+
bb_re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop)
32873287
struct re_pattern_buffer *bufp;
32883288
const char *string1, *string2;
32893289
int size1, size2;
@@ -3334,7 +3334,7 @@ re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop)
33343334

33353335
/* Update the fastmap now if not correct already. */
33363336
if (fastmap && !bufp->fastmap_accurate)
3337-
if (re_compile_fastmap (bufp) == -2)
3337+
if (bb_re_compile_fastmap (bufp) == -2)
33383338
return -2;
33393339

33403340
/* See whether the pattern is anchored. */
@@ -3526,7 +3526,7 @@ static boolean alt_match_null_string_p (),
35263526
/* re_match is like re_match_2 except it takes only a single string. */
35273527

35283528
int
3529-
re_match (bufp, string, size, pos, regs)
3529+
bb_re_match (bufp, string, size, pos, regs)
35303530
struct re_pattern_buffer *bufp;
35313531
const char *string;
35323532
int size, pos;
@@ -3554,7 +3554,7 @@ re_match (bufp, string, size, pos, regs)
35543554
matched substring. */
35553555

35563556
int
3557-
re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
3557+
bb_re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
35583558
struct re_pattern_buffer *bufp;
35593559
const char *string1, *string2;
35603560
int size1, size2;
@@ -5186,7 +5186,7 @@ bcmp_translate (s1, s2, len, translate)
51865186
We call regex_compile to do the actual compilation. */
51875187

51885188
const char *
5189-
re_compile_pattern (pattern, length, bufp)
5189+
bb_re_compile_pattern (pattern, length, bufp)
51905190
const char *pattern;
51915191
int length;
51925192
struct re_pattern_buffer *bufp;
@@ -5227,7 +5227,7 @@ char *
52275227
regcomp/regexec below without link errors. */
52285228
weak_function
52295229
#endif
5230-
re_comp (s)
5230+
bb_re_comp (s)
52315231
const char *s;
52325232
{
52335233
reg_errcode_t ret;
@@ -5271,12 +5271,12 @@ int
52715271
#ifdef _LIBC
52725272
weak_function
52735273
#endif
5274-
re_exec (s)
5274+
bb_re_exec (s)
52755275
const char *s;
52765276
{
52775277
const int len = strlen (s);
52785278
return
5279-
0 <= re_search (&re_comp_buf, s, len, 0, len, (struct re_registers *) 0);
5279+
0 <= bb_re_search (&re_comp_buf, s, len, 0, len, (struct re_registers *) 0);
52805280
}
52815281
#endif /* _REGEX_RE_COMP */
52825282

@@ -5321,7 +5321,7 @@ int
53215321
#ifdef _LIBC
53225322
weak_function
53235323
#endif
5324-
regcomp (preg, pattern, cflags)
5324+
bb_regcomp (preg, pattern, cflags)
53255325
regex_t *preg;
53265326
const char *pattern;
53275327
int cflags;
@@ -5401,7 +5401,7 @@ int
54015401
#ifdef _LIBC
54025402
weak_function
54035403
#endif
5404-
regexec (preg, string, nmatch, pmatch, eflags)
5404+
bb_regexec (preg, string, nmatch, pmatch, eflags)
54055405
const regex_t *preg;
54065406
const char *string;
54075407
size_t nmatch;
@@ -5434,7 +5434,7 @@ regexec (preg, string, nmatch, pmatch, eflags)
54345434
}
54355435

54365436
/* Perform the searching operation. */
5437-
ret = re_search (&private_preg, string, len,
5437+
ret = bb_re_search (&private_preg, string, len,
54385438
/* start: */ 0, /* range: */ len,
54395439
want_reg_info ? &regs : (struct re_registers *) 0);
54405440

@@ -5471,7 +5471,7 @@ size_t
54715471
regcomp/regexec below without link errors. */
54725472
weak_function
54735473
#endif
5474-
regerror (errcode, preg, errbuf, errbuf_size)
5474+
bb_regerror (errcode, preg, errbuf, errbuf_size)
54755475
int errcode;
54765476
const regex_t *preg;
54775477
char *errbuf;
@@ -5516,7 +5516,7 @@ void
55165516
regcomp/regexec below without link errors. */
55175517
weak_function
55185518
#endif
5519-
regfree (preg)
5519+
bb_regfree (preg)
55205520
regex_t *preg;
55215521
{
55225522
if (preg->buffer != NULL)

0 commit comments

Comments
 (0)