make_ext4fs: fix sepolicy lookup for lost+found
selabel_lookup needs the full path including mountpoint.
Change-Id: Idc0641683a4e4528d94e54be1897315bf5fcdb0d
diff --git a/ext4_utils/make_ext4fs.c b/ext4_utils/make_ext4fs.c
index f4e181c..97cd26f 100644
--- a/ext4_utils/make_ext4fs.c
+++ b/ext4_utils/make_ext4fs.c
@@ -218,16 +218,20 @@
dentries = tmp;
dentries[0].filename = strdup("lost+found");
- dentries[0].path = strdup("/lost+found");
+ asprintf(&dentries[0].path, "%s/lost+found", dir_path);
dentries[0].full_path = NULL;
dentries[0].size = 0;
dentries[0].mode = S_IRWXU;
dentries[0].file_type = EXT4_FT_DIR;
dentries[0].uid = 0;
dentries[0].gid = 0;
- if (sehnd)
- if (selabel_lookup(sehnd, &dentries[0].secon, "lost+found", dentries[0].mode) < 0)
- error("cannot lookup security context for /lost+found");
+ if (sehnd) {
+ char *sepath = NULL;
+ asprintf(&sepath, "/%s", dentries[0].path);
+ if (selabel_lookup(sehnd, &dentries[0].secon, sepath, dentries[0].mode) < 0)
+ error("cannot lookup security context for %s", dentries[0].path);
+ free(sepath);
+ }
entries++;
dirs++;
}