diff options
author | rpcraig <rpcraig@tycho.ncsc.mil> | 2012-07-16 07:37:30 -0400 |
---|---|---|
committer | rpcraig <rpcraig@tycho.ncsc.mil> | 2012-07-18 13:19:14 -0400 |
commit | bd009e4d493deaf90c38da1cdbaa1db69db073ba (patch) | |
tree | 2b043c30be3376d5ae6095aa7170fde73ffe024f | |
parent | 64a7dfb5cd56d758a74a4f98e29724e84a276acc (diff) | |
download | yaffs2-bd009e4d493deaf90c38da1cdbaa1db69db073ba.tar.gz |
Modiy mkyaffsimage for SELinux.
We need to ensure that a leading '/' is present for
selabel_lookups so they match file_context entries.
Change-Id: If39df42b73141bed0851a6b74c6f2c2da0c1658f
Signed-off-by: rpcraig <rpcraig@tycho.ncsc.mil>
-rw-r--r-- | yaffs2/utils/mkyaffs2image.c | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/yaffs2/utils/mkyaffs2image.c b/yaffs2/utils/mkyaffs2image.c index 2b152e6..f4e5745 100644 --- a/yaffs2/utils/mkyaffs2image.c +++ b/yaffs2/utils/mkyaffs2image.c @@ -382,12 +382,26 @@ static int process_directory(int parent, const char *path, int fixstats) mntpoint, suffix); exit(1); } + + char *sepath = NULL; + if (dest_name[0] == '/') + sepath = strdup(dest_name); + else if (asprintf(&sepath, "/%s", dest_name) < 0) + sepath = NULL; + + if (!sepath) { + perror("malloc"); + exit(1); + } + if (selabel_lookup(sehnd, &secontext, - dest_name, + sepath, stats.st_mode) < 0) { - perror("selabel_lookup"); - exit(1); + perror("selabel_lookup"); + free(sepath); + exit(1); } + free(sepath); } #endif @@ -636,10 +650,25 @@ int main(int argc, char *argv[]) //printf("Processing directory %s into image file %s\n",dir,image); #ifdef HAVE_SELINUX if (sehnd) { - if (selabel_lookup(sehnd, &secontext, mntpoint, stats.st_mode) < 0) { - perror("selabel_lookup"); - exit(1); - } + + char *sepath = NULL; + if (mntpoint[0] == '/') + sepath = strdup(mntpoint); + else if (asprintf(&sepath, "/%s", mntpoint) < 0) + sepath = NULL; + + if (!sepath) { + perror("malloc"); + exit(1); + } + + if (selabel_lookup(sehnd, &secontext, sepath, stats.st_mode) < 0) { + perror("selabel_lookup"); + free(sepath); + exit(1); + } + + free(sepath); } #endif |