diff options
author | rpcraig <rpcraig@tycho.ncsc.mil> | 2012-09-21 11:46:20 -0400 |
---|---|---|
committer | Kenny Root <kroot@google.com> | 2012-10-17 12:08:35 -0700 |
commit | 5da2f366f8714eafff0337c32f10c314488cfdef (patch) | |
tree | 05921ee9e42271a01b4ec64683a2f42698f2ae8a | |
parent | 50d42703936b87ffdd5b9ec135d7e0e4af8aa31f (diff) | |
download | extras-5da2f366f8714eafff0337c32f10c314488cfdef.tar.gz |
Add automatic file_contexts handle to make_ext4fs.
Normal make_ext4 use requires a -S option to
pass a correct file_contexts path for labeling.
This becomes impractical under certain conditions
when used on a target device. For instance, with
the creation of ext4 containers for asec images.
This patch will create a proper sehandle only
if the -S option is not used and only when
run on a target device.
Change-Id: I9bdc8659aae7037ccebbf4464500b79b4b2f56af
-rw-r--r-- | ext4_utils/Android.mk | 1 | ||||
-rw-r--r-- | ext4_utils/make_ext4fs.h | 1 | ||||
-rw-r--r-- | ext4_utils/make_ext4fs_main.c | 12 |
3 files changed, 14 insertions, 0 deletions
diff --git a/ext4_utils/Android.mk b/ext4_utils/Android.mk index f9b571e2..1fef7353 100644 --- a/ext4_utils/Android.mk +++ b/ext4_utils/Android.mk @@ -41,6 +41,7 @@ ifeq ($(HOST_OS),windows) LOCAL_LDLIBS += -lws2_32 else LOCAL_STATIC_LIBRARIES += libselinux + LOCAL_CFLAGS := -DHOST endif include $(BUILD_HOST_EXECUTABLE) diff --git a/ext4_utils/make_ext4fs.h b/ext4_utils/make_ext4fs.h index 577157ac..e80e6367 100644 --- a/ext4_utils/make_ext4fs.h +++ b/ext4_utils/make_ext4fs.h @@ -27,6 +27,7 @@ extern "C" { #ifndef USE_MINGW #include <selinux/selinux.h> #include <selinux/label.h> +#include <selinux/android.h> #else struct selabel_handle; #endif diff --git a/ext4_utils/make_ext4fs_main.c b/ext4_utils/make_ext4fs_main.c index c54618db..000b857d 100644 --- a/ext4_utils/make_ext4fs_main.c +++ b/ext4_utils/make_ext4fs_main.c @@ -136,6 +136,18 @@ int main(int argc, char **argv) } } +#if !defined(HOST) + // Use only if -S option not requested + if (!sehnd && mountpoint[0] != '\0') { + sehnd = selinux_android_file_context_handle(); + + if (!sehnd) { + perror(optarg); + exit(EXIT_FAILURE); + } + } +#endif + if (wipe && sparse) { fprintf(stderr, "Cannot specifiy both wipe and sparse\n"); usage(argv[0]); |