summaryrefslogtreecommitdiffstats
path: root/src/archive.c
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2009-01-17 08:06:23 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2009-01-17 08:06:23 +0000
commitf88f8205a7ef27209b8a0231892ce66e96169d42 (patch)
tree5038c0f46729a08693e72a4b729fae3eddca2af0 /src/archive.c
parent1a9cc552a536e15083e5eceaad39f0f8019392c5 (diff)
downloadapk-tools-f88f8205a7ef27209b8a0231892ce66e96169d42.tar.bz2
apk-tools-f88f8205a7ef27209b8a0231892ce66e96169d42.tar.xz
archive: set suid bit after chown if needed
chown will reset the suid bit so we need to set it again.
Diffstat (limited to 'src/archive.c')
-rw-r--r--src/archive.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/archive.c b/src/archive.c
index 765b786..8ffb921 100644
--- a/src/archive.c
+++ b/src/archive.c
@@ -241,6 +241,12 @@ int apk_archive_entry_extract(const struct apk_file_info *ae,
if (r < 0)
apk_error("Failed to set ownership on %s: %s", fn,
strerror(errno));
+ /* chown resets suid bit so we need set it again */
+ if (ae->mode & 07000)
+ r = chmod(fn, ae->mode & 07777);
+ if (r < 0)
+ apk_error("Failed to set file permissions on %s: %s",
+ fn, strerror(errno));
} else {
apk_error("Failed to extract %s\n", ae->name);
}