66 lines
2.1 KiB
Diff
66 lines
2.1 KiB
Diff
From d11230a29de77ff5ab121134b5b7f083b10dca52 Mon Sep 17 00:00:00 2001
|
|
From: Juan RP <xtraeme@gmail.com>
|
|
Date: Sun, 18 Jan 2015 10:22:05 +0100
|
|
Subject: [PATCH 1/2] libxbps: abort pkg unpacking as soon as a file cannot be
|
|
written.
|
|
|
|
Close #74
|
|
---
|
|
NEWS | 4 ++++
|
|
lib/package_unpack.c | 17 +++++++++++------
|
|
2 files changed, 15 insertions(+), 6 deletions(-)
|
|
|
|
--- lib/package_unpack.c
|
|
+++ lib/package_unpack.c
|
|
@@ -86,7 +86,7 @@ unpack_archive(struct xbps_handle *xhp,
|
|
ssize_t entry_size;
|
|
const char *file, *entry_pname, *transact;
|
|
char *pkgname, *buf;
|
|
- int ar_rv, rv, entry_type, flags;
|
|
+ int ar_rv, rv, error, entry_type, flags;
|
|
bool preserve, update, file_exists, skip_obsoletes;
|
|
bool skip_extract, force, xucd_stats;
|
|
uid_t euid;
|
|
@@ -94,7 +94,7 @@ unpack_archive(struct xbps_handle *xhp,
|
|
binpkg_filesd = pkg_filesd = NULL;
|
|
force = preserve = update = file_exists = false;
|
|
skip_obsoletes = xucd_stats = false;
|
|
- ar_rv = rv = entry_type = flags = 0;
|
|
+ ar_rv = rv = error = entry_type = flags = 0;
|
|
|
|
xbps_dictionary_get_bool(pkg_repod, "preserve", &preserve);
|
|
xbps_dictionary_get_bool(pkg_repod, "skip-obsoletes", &skip_obsoletes);
|
|
@@ -403,10 +403,12 @@ unpack_archive(struct xbps_handle *xhp,
|
|
* Extract entry from archive.
|
|
*/
|
|
if (archive_read_extract(ar, entry, flags) != 0) {
|
|
+ error = archive_errno(ar);
|
|
xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL,
|
|
- archive_errno(ar), pkgver,
|
|
+ error, pkgver,
|
|
"%s: [unpack] failed to extract file `%s': %s",
|
|
- pkgver, entry_pname, archive_error_string(ar));
|
|
+ pkgver, entry_pname, strerror(error));
|
|
+ break;
|
|
} else {
|
|
if (xhp->unpack_cb != NULL) {
|
|
xucd.entry_extract_count++;
|
|
@@ -417,10 +419,13 @@ unpack_archive(struct xbps_handle *xhp,
|
|
/*
|
|
* If there was any error extracting files from archive, error out.
|
|
*/
|
|
- if (ar_rv == ARCHIVE_FATAL) {
|
|
+ if (error || ar_rv == ARCHIVE_FATAL) {
|
|
+ rv = error;
|
|
+ if (!rv)
|
|
+ rv = ar_rv;
|
|
xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL, rv, pkgver,
|
|
"%s: [unpack] failed to extract files: %s",
|
|
- pkgver, archive_error_string(ar));
|
|
+ pkgver, strerror(rv));
|
|
goto out;
|
|
}
|
|
/*
|
|
--
|
|
2.2.2
|
|
|