diff options
author | Nick Kralevich <nnk@google.com> | 2012-07-19 01:13:15 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2012-07-19 01:13:15 -0700 |
commit | 9c64cac7542658f85417d651d8b9422e054d5e72 (patch) | |
tree | c16bdb133105abf576b8506caac93a0c79aae491 | |
parent | bef82d3047426701ca3df4e392c1c63285fbebc9 (diff) | |
parent | d66b3e8898579431a5eb66e4470989e534ef3e73 (diff) | |
download | yaffs2-9c64cac7542658f85417d651d8b9422e054d5e72.tar.gz |
am d66b3e88: Merge "Modiy mkyaffsimage for SELinux."android-sdk-support_r11android-cts-4.2_r2android-cts-4.2_r1android-4.2_r1android-4.2_pre3android-4.2_pre2.2android-4.2_pre2.1android-4.2_pre2android-4.2_pre1.1android-4.2_pre1android-4.2.2_r1.2android-4.2.2_r1.1android-4.2.2_r1android-4.2.1_r1.2android-4.2.1_r1.1android-4.2.1_r1jb-mr1.1-releasejb-mr1.1-devjb-mr1-releasejb-mr1-factory-releasejb-mr1-dev
* commit 'd66b3e8898579431a5eb66e4470989e534ef3e73':
Modiy mkyaffsimage for SELinux.
-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 |