static char *mountpoint = "";
static time_t fixed_time = -1;
static char *fs_config_file;
-static char *file_contexts;
+static struct selinux_opt seopt_file[8];
+static int max_nr_opt = (int)sizeof(seopt_file) / sizeof(seopt_file[0]);
static char *product_out;
static char *src_dir;
static int android_configure;
io_manager io_mgr;
ext2_filsys fs = NULL;
struct fs_ops_callbacks fs_callbacks = { NULL, NULL };
+ char *token;
+ int nr_opt = 0;
add_error_table(&et_ext2_error_table);
android_configure = 1;
break;
case 'S':
- file_contexts = absolute_path(optarg);
+ token = strtok(optarg, ",");
+ while (token) {
+ if (nr_opt == max_nr_opt) {
+ fprintf(stderr, "Expected at most %d selinux opts\n",
+ max_nr_opt);
+ exit(EXIT_FAILURE);
+ }
+ seopt_file[nr_opt].type = SELABEL_OPT_PATH;
+ seopt_file[nr_opt].value = absolute_path(token);
+ nr_opt++;
+ token = strtok(NULL, ",");
+ }
android_configure = 1;
break;
case 'p':
if (android_configure) {
retval = android_configure_fs(fs, src_dir, product_out, mountpoint,
- file_contexts, fs_config_file, fixed_time);
+ seopt_file, nr_opt, fs_config_file, fixed_time);
if (retval) {
com_err(prog_name, retval, "%s",
"while configuring the file system");
errcode_t android_configure_fs(ext2_filsys fs, char *src_dir, char *target_out,
char *mountpoint,
- char *file_contexts,
+ struct selinux_opt *seopts,
+ unsigned int nopt,
char *fs_config_file, time_t fixed_time)
{
errcode_t retval;
struct selabel_handle *sehnd = NULL;
/* Retrieve file contexts */
- if (file_contexts) {
- struct selinux_opt seopts[] = { { SELABEL_OPT_PATH, "" } };
- seopts[0].value = file_contexts;
- sehnd = selabel_open(SELABEL_CTX_FILE, seopts, 1);
+ if (nopt > 0) {
+ sehnd = selabel_open(SELABEL_CTX_FILE, seopts, nopt);
if (!sehnd) {
com_err(__func__, -EINVAL,
_("while opening file contexts \"%s\""),