diff options
Diffstat (limited to 'minzip/DirUtil.c')
-rw-r--r-- | minzip/DirUtil.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/minzip/DirUtil.c b/minzip/DirUtil.c index 8dd5da1da..c120fa3cd 100644 --- a/minzip/DirUtil.c +++ b/minzip/DirUtil.c @@ -23,6 +23,7 @@ #include <errno.h> #include <dirent.h> #include <limits.h> +#include <selinux/selinux.h> #include "DirUtil.h" @@ -237,7 +238,7 @@ dirUnlinkHierarchy(const char *path) int dirSetHierarchyPermissions(const char *path, - int uid, int gid, int dirMode, int fileMode) + int uid, int gid, int dirMode, int fileMode, const char* secontext) { struct stat st; if (lstat(path, &st)) { @@ -255,6 +256,10 @@ dirSetHierarchyPermissions(const char *path, return -1; } + if ((secontext != NULL) && lsetfilecon(path, secontext) && (errno != ENOTSUP)) { + return -1; + } + /* recurse over directory components */ if (S_ISDIR(st.st_mode)) { DIR *dir = opendir(path); @@ -271,7 +276,7 @@ dirSetHierarchyPermissions(const char *path, char dn[PATH_MAX]; snprintf(dn, sizeof(dn), "%s/%s", path, de->d_name); - if (!dirSetHierarchyPermissions(dn, uid, gid, dirMode, fileMode)) { + if (!dirSetHierarchyPermissions(dn, uid, gid, dirMode, fileMode, secontext)) { errno = 0; } else if (errno == 0) { errno = -1; |