summaryrefslogtreecommitdiffstats
path: root/minzip/DirUtil.c
diff options
context:
space:
mode:
authorNick Kralevich <nnk@google.com>2013-09-11 20:37:10 +0200
committerNick Kralevich <nnk@google.com>2013-09-17 19:20:45 +0200
commit46ab1b6138bf911120280f1095ff9479dceee3df (patch)
treefa6091faa4986f4528859c6c234b4b62a80d4f9e /minzip/DirUtil.c
parentam cc2958fd: fix secure adb in recovery (diff)
downloadandroid_bootable_recovery-46ab1b6138bf911120280f1095ff9479dceee3df.tar
android_bootable_recovery-46ab1b6138bf911120280f1095ff9479dceee3df.tar.gz
android_bootable_recovery-46ab1b6138bf911120280f1095ff9479dceee3df.tar.bz2
android_bootable_recovery-46ab1b6138bf911120280f1095ff9479dceee3df.tar.lz
android_bootable_recovery-46ab1b6138bf911120280f1095ff9479dceee3df.tar.xz
android_bootable_recovery-46ab1b6138bf911120280f1095ff9479dceee3df.tar.zst
android_bootable_recovery-46ab1b6138bf911120280f1095ff9479dceee3df.zip
Diffstat (limited to '')
-rw-r--r--minzip/DirUtil.c58
1 files changed, 0 insertions, 58 deletions
diff --git a/minzip/DirUtil.c b/minzip/DirUtil.c
index 8dd5da1da..fe2c880ac 100644
--- a/minzip/DirUtil.c
+++ b/minzip/DirUtil.c
@@ -234,61 +234,3 @@ dirUnlinkHierarchy(const char *path)
/* delete target directory */
return rmdir(path);
}
-
-int
-dirSetHierarchyPermissions(const char *path,
- int uid, int gid, int dirMode, int fileMode)
-{
- struct stat st;
- if (lstat(path, &st)) {
- return -1;
- }
-
- /* ignore symlinks */
- if (S_ISLNK(st.st_mode)) {
- return 0;
- }
-
- /* directories and files get different permissions */
- if (chown(path, uid, gid) ||
- chmod(path, S_ISDIR(st.st_mode) ? dirMode : fileMode)) {
- return -1;
- }
-
- /* recurse over directory components */
- if (S_ISDIR(st.st_mode)) {
- DIR *dir = opendir(path);
- if (dir == NULL) {
- return -1;
- }
-
- errno = 0;
- const struct dirent *de;
- while (errno == 0 && (de = readdir(dir)) != NULL) {
- if (!strcmp(de->d_name, "..") || !strcmp(de->d_name, ".")) {
- continue;
- }
-
- char dn[PATH_MAX];
- snprintf(dn, sizeof(dn), "%s/%s", path, de->d_name);
- if (!dirSetHierarchyPermissions(dn, uid, gid, dirMode, fileMode)) {
- errno = 0;
- } else if (errno == 0) {
- errno = -1;
- }
- }
-
- if (errno != 0) {
- int save = errno;
- closedir(dir);
- errno = save;
- return -1;
- }
-
- if (closedir(dir)) {
- return -1;
- }
- }
-
- return 0;
-}