summaryrefslogtreecommitdiffstats
path: root/minzip/Zip.c
diff options
context:
space:
mode:
authorStephen Smalley <sds@tycho.nsa.gov>2012-02-09 20:13:23 +0100
committerStephen Smalley <sds@tycho.nsa.gov>2012-03-30 15:32:46 +0200
commit779701db515d1a0d363d5a8896252f331bc4e22a (patch)
tree46aacb687e7126a5a64949dd7ade2f284ee57c15 /minzip/Zip.c
parentAdd libselinux to LOCAL_STATIC_LIBRARIES wherever libext4_utils is used. (diff)
downloadandroid_bootable_recovery-779701db515d1a0d363d5a8896252f331bc4e22a.tar
android_bootable_recovery-779701db515d1a0d363d5a8896252f331bc4e22a.tar.gz
android_bootable_recovery-779701db515d1a0d363d5a8896252f331bc4e22a.tar.bz2
android_bootable_recovery-779701db515d1a0d363d5a8896252f331bc4e22a.tar.lz
android_bootable_recovery-779701db515d1a0d363d5a8896252f331bc4e22a.tar.xz
android_bootable_recovery-779701db515d1a0d363d5a8896252f331bc4e22a.tar.zst
android_bootable_recovery-779701db515d1a0d363d5a8896252f331bc4e22a.zip
Diffstat (limited to '')
-rw-r--r--minzip/Zip.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/minzip/Zip.c b/minzip/Zip.c
index 46d2f829e..54d5d55a3 100644
--- a/minzip/Zip.c
+++ b/minzip/Zip.c
@@ -930,7 +930,8 @@ static const char *targetEntryPath(MzPathHelper *helper, ZipEntry *pEntry)
bool mzExtractRecursive(const ZipArchive *pArchive,
const char *zipDir, const char *targetDir,
int flags, const struct utimbuf *timestamp,
- void (*callback)(const char *fn, void *), void *cookie)
+ void (*callback)(const char *fn, void *), void *cookie,
+ struct selabel_handle *sehnd)
{
if (zipDir[0] == '/') {
LOGE("mzExtractRecursive(): zipDir must be a relative path.\n");
@@ -1045,7 +1046,7 @@ bool mzExtractRecursive(const ZipArchive *pArchive,
if (pEntry->fileName[pEntry->fileNameLen-1] == '/') {
if (!(flags & MZ_EXTRACT_FILES_ONLY)) {
int ret = dirCreateHierarchy(
- targetFile, UNZIP_DIRMODE, timestamp, false);
+ targetFile, UNZIP_DIRMODE, timestamp, false, sehnd);
if (ret != 0) {
LOGE("Can't create containing directory for \"%s\": %s\n",
targetFile, strerror(errno));
@@ -1059,7 +1060,7 @@ bool mzExtractRecursive(const ZipArchive *pArchive,
* the containing directory exists.
*/
int ret = dirCreateHierarchy(
- targetFile, UNZIP_DIRMODE, timestamp, true);
+ targetFile, UNZIP_DIRMODE, timestamp, true, sehnd);
if (ret != 0) {
LOGE("Can't create containing directory for \"%s\": %s\n",
targetFile, strerror(errno));
@@ -1113,7 +1114,25 @@ bool mzExtractRecursive(const ZipArchive *pArchive,
/* The entry is a regular file.
* Open the target for writing.
*/
+
+#ifdef HAVE_SELINUX
+ char *secontext = NULL;
+
+ if (sehnd) {
+ selabel_lookup(sehnd, &secontext, targetFile, UNZIP_FILEMODE);
+ setfscreatecon(secontext);
+ }
+#endif
+
int fd = creat(targetFile, UNZIP_FILEMODE);
+
+#ifdef HAVE_SELINUX
+ if (secontext) {
+ freecon(secontext);
+ setfscreatecon(NULL);
+ }
+#endif
+
if (fd < 0) {
LOGE("Can't create target file \"%s\": %s\n",
targetFile, strerror(errno));