summaryrefslogtreecommitdiff
path: root/src/archive.c
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2009-11-06 16:16:49 +0200
committerTimo Teras <timo.teras@iki.fi>2009-11-06 16:16:49 +0200
commit98de5353550b1750591d4469429563f5537519ed (patch)
tree46b63478fbcc74c1ed223282cf39ca2aea49430c /src/archive.c
parent4dd183f3c1cd093af0fc1382bd9d822423bbb748 (diff)
downloadapk-tools-98de5353550b1750591d4469429563f5537519ed.tar.gz
apk-tools-98de5353550b1750591d4469429563f5537519ed.tar.bz2
apk-tools-98de5353550b1750591d4469429563f5537519ed.tar.xz
apk-tools-98de5353550b1750591d4469429563f5537519ed.zip
archive: overwrite protection needs to use real filename
otherwise we always extract the file as .apk-new and the database side just overwrites.
Diffstat (limited to 'src/archive.c')
-rw-r--r--src/archive.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/archive.c b/src/archive.c
index 0ba17c5..a2707cd 100644
--- a/src/archive.c
+++ b/src/archive.c
@@ -344,8 +344,14 @@ int apk_archive_entry_extract(int atfd, const struct apk_file_info *ae,
(ae->link_target != NULL)) {
/* non-standard entries need to be deleted first */
if (apk_flags & APK_NEVER_OVERWRITE) {
- if (faccessat(atfd, fn, F_OK, AT_SYMLINK_NOFOLLOW) == 0)
+ if (faccessat(atfd, ae->name, F_OK,
+ AT_SYMLINK_NOFOLLOW) == 0) {
+ /* destination exists, but we are not supposed
+ * to overwrite, just clean the temp file */
+ if (suffix != NULL)
+ unlinkat(atfd, fn, 0);
return 0;
+ }
} else {
unlinkat(atfd, fn, 0);
}