summaryrefslogtreecommitdiff
path: root/tar/read.c
diff options
context:
space:
mode:
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>2014-10-04 15:55:34 +0900
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>2014-10-04 19:33:46 +0900
commitb5af190b7eb85efebcd06c971fa03549436572f2 (patch)
treebbd5e0e965a1ab32e2676a335f302d6506051dc3 /tar/read.c
parentc1732828cd802c26e18891c4c95f49c15819c985 (diff)
downloadlibarchive-b5af190b7eb85efebcd06c971fa03549436572f2.tar.gz
Do not ask passphrases when a passphrase was already specified with
--passphrase option.
Diffstat (limited to 'tar/read.c')
-rw-r--r--tar/read.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/tar/read.c b/tar/read.c
index 1085771d..83815eda 100644
--- a/tar/read.c
+++ b/tar/read.c
@@ -205,12 +205,13 @@ read_archive(struct bsdtar *bsdtar, char mode, struct archive *writer)
if (archive_read_set_options(a,
"read_concatenated_archives") != ARCHIVE_OK)
lafe_errc(1, 0, "%s", archive_error_string(a));
- if (bsdtar->passphrase != NULL) {
- if (archive_read_add_passphrase(a,
- bsdtar->passphrase) != ARCHIVE_OK)
- lafe_errc(1, 0, "%s", archive_error_string(a));
- }
- archive_read_set_passphrase_callback(a, bsdtar, &passphrase_callback);
+ if (bsdtar->passphrase != NULL)
+ r = archive_read_add_passphrase(a, bsdtar->passphrase);
+ else
+ r = archive_read_set_passphrase_callback(a, bsdtar,
+ &passphrase_callback);
+ if (r != ARCHIVE_OK)
+ lafe_errc(1, 0, "%s", archive_error_string(a));
if (archive_read_open_filename(a, bsdtar->filename,
bsdtar->bytes_per_block))
lafe_errc(1, 0, "Error opening archive: %s",