fs_config: remove -S option.
mkfs warns about unknown "selabel=" fields, and this should be coming
from the file_contexts file, not here.
Test: treehugger
Change-Id: I63f3f616a2588438017e609a1a08c9dd7bf0c2ed
diff --git a/core/Makefile b/core/Makefile
index 0215fda..96c0705 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -6084,7 +6084,7 @@
# $1: root directory
# $2: add prefix
define fs_config
-(cd $(1); find . -type d | sed 's,$$,/,'; find . \! -type d) | cut -c 3- | sort | sed 's,^,$(2),' | $(HOST_OUT_EXECUTABLES)/fs_config -C -D $(TARGET_OUT) -S $(SELINUX_FC) -R "$(2)"
+(cd $(1); find . -type d | sed 's,$$,/,'; find . \! -type d) | cut -c 3- | sort | sed 's,^,$(2),' | $(HOST_OUT_EXECUTABLES)/fs_config -C -D $(TARGET_OUT) -R "$(2)"
endef
define filter-out-missing-vendor
diff --git a/tools/fs_config/Android.bp b/tools/fs_config/Android.bp
index 55fdca4..bd9543a 100644
--- a/tools/fs_config/Android.bp
+++ b/tools/fs_config/Android.bp
@@ -35,7 +35,6 @@
srcs: ["fs_config.c"],
shared_libs: [
"libcutils",
- "libselinux",
],
cflags: ["-Werror"],
}
diff --git a/tools/fs_config/fs_config.c b/tools/fs_config/fs_config.c
index 2a75add..80bd3c1 100644
--- a/tools/fs_config/fs_config.c
+++ b/tools/fs_config/fs_config.c
@@ -22,9 +22,6 @@
#include <string.h>
#include <inttypes.h>
-#include <selinux/selinux.h>
-#include <selinux/label.h>
-
#include "private/android_filesystem_config.h"
#include "private/fs_config.h"
@@ -35,8 +32,8 @@
//
// After the first 4 columns, optional key=value pairs are emitted
// for each file. Currently, the following keys are supported:
-// * -S: selabel=[selinux_label]
-// * -C: capabilities=[hex capabilities value]
+//
+// -C: capabilities=[hex capabilities value]
//
// Example input:
//
@@ -48,45 +45,24 @@
// system/etc/dbus.conf 1002 1002 440
// data/app 1000 1000 771
//
-// or if, for example, -S is used:
-//
-// system/etc/dbus.conf 1002 1002 440 selabel=u:object_r:system_file:s0
-// data/app 1000 1000 771 selabel=u:object_r:apk_data_file:s0
-//
// Note that the output will omit the trailing slash from
// directories.
-static struct selabel_handle* get_sehnd(const char* context_file) {
- struct selinux_opt seopts[] = { { SELABEL_OPT_PATH, context_file } };
- struct selabel_handle* sehnd = selabel_open(SELABEL_CTX_FILE, seopts, 1);
-
- if (!sehnd) {
- perror("error running selabel_open");
- exit(EXIT_FAILURE);
- }
- return sehnd;
-}
-
static void usage() {
- fprintf(stderr, "Usage: fs_config [-D product_out_path] [-S context_file] [-R root] [-C]\n");
+ fprintf(stderr, "Usage: fs_config [-D product_out_path] [-R root] [-C]\n");
}
int main(int argc, char** argv) {
char buffer[1024];
- const char* context_file = NULL;
const char* product_out_path = NULL;
char* root_path = NULL;
- struct selabel_handle* sehnd = NULL;
int print_capabilities = 0;
int opt;
- while((opt = getopt(argc, argv, "CS:R:D:")) != -1) {
+ while((opt = getopt(argc, argv, "CR:D:")) != -1) {
switch(opt) {
case 'C':
print_capabilities = 1;
break;
- case 'S':
- context_file = optarg;
- break;
case 'R':
root_path = optarg;
break;
@@ -99,10 +75,6 @@
}
}
- if (context_file != NULL) {
- sehnd = get_sehnd(context_file);
- }
-
if (root_path != NULL) {
size_t root_len = strlen(root_path);
/* Trim any trailing slashes from the root path. */
@@ -141,33 +113,6 @@
}
printf("%s %d %d %o", buffer, uid, gid, mode);
- if (sehnd != NULL) {
- size_t buffer_strlen = strnlen(buffer, sizeof(buffer));
- if (buffer_strlen >= sizeof(buffer)) {
- fprintf(stderr, "non null terminated buffer, aborting\n");
- exit(EXIT_FAILURE);
- }
- size_t full_name_size = buffer_strlen + 2;
- char* full_name = (char*) malloc(full_name_size);
- if (full_name == NULL) {
- perror("malloc");
- exit(EXIT_FAILURE);
- }
-
- full_name[0] = '/';
- strncpy(full_name + 1, buffer, full_name_size - 1);
- full_name[full_name_size - 1] = '\0';
-
- char* secontext;
- if (selabel_lookup(sehnd, &secontext, full_name, ( mode | (is_dir ? S_IFDIR : S_IFREG)))) {
- secontext = strdup("u:object_r:unlabeled:s0");
- }
-
- printf(" selabel=%s", secontext);
- free(full_name);
- freecon(secontext);
- }
-
if (print_capabilities) {
printf(" capabilities=0x%" PRIx64, capabilities);
}