diff options
author | joerg <joerg@pkgsrc.org> | 2010-02-20 04:40:03 +0000 |
---|---|---|
committer | joerg <joerg@pkgsrc.org> | 2010-02-20 04:40:03 +0000 |
commit | 92030a7399fe218b0032e8811bc5116d87bc9cd9 (patch) | |
tree | 5d8a297dd32d724f98590eee6f864f3b7d095ac3 /pkgtools | |
parent | 16e5199f5d6d3eed978157697f7c6d70360cd09f (diff) | |
download | pkgsrc-92030a7399fe218b0032e8811bc5116d87bc9cd9.tar.gz |
pkg_install-20100220:
Try harder to give the user an idea which file failed.
Addresses PR 42223.
Diffstat (limited to 'pkgtools')
-rw-r--r-- | pkgtools/pkg_install/files/add/perform.c | 16 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/admin/main.c | 11 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/info/perform.c | 10 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/lib/lib.h | 10 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/lib/pkg_io.c | 23 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/lib/pkg_signature.c | 35 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/lib/version.h | 4 |
7 files changed, 63 insertions, 46 deletions
diff --git a/pkgtools/pkg_install/files/add/perform.c b/pkgtools/pkg_install/files/add/perform.c index c7fcbcb8ad8..bbd379ba889 100644 --- a/pkgtools/pkg_install/files/add/perform.c +++ b/pkgtools/pkg_install/files/add/perform.c @@ -1,4 +1,4 @@ -/* $NetBSD: perform.c,v 1.94 2010/02/03 14:20:14 joerg Exp $ */ +/* $NetBSD: perform.c,v 1.95 2010/02/20 04:40:03 joerg Exp $ */ #if HAVE_CONFIG_H #include "config.h" #endif @@ -6,7 +6,7 @@ #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -__RCSID("$NetBSD: perform.c,v 1.94 2010/02/03 14:20:14 joerg Exp $"); +__RCSID("$NetBSD: perform.c,v 1.95 2010/02/20 04:40:03 joerg Exp $"); /*- * Copyright (c) 2003 Grant Beattie <grant@NetBSD.org> @@ -729,8 +729,9 @@ extract_files(struct pkg_task *pkg) r = archive_write_header(writer, pkg->entry); if (r != ARCHIVE_OK) { - warnx("Failed to write %s: %s", + warnx("Failed to write %s for %s: %s", archive_entry_pathname(pkg->entry), + pkg->pkgname, archive_error_string(writer)); goto out; } @@ -760,7 +761,8 @@ extract_files(struct pkg_task *pkg) continue; } if (r != ARCHIVE_OK) { - warnx("Failed to read from archive: %s", + warnx("Failed to read from archive for %s: %s", + pkg->pkgname, archive_error_string(pkg->archive)); goto out; } @@ -1334,6 +1336,7 @@ check_license(struct pkg_task *pkg) static int pkg_do(const char *pkgpath, int mark_automatic, int top_level) { + char *archive_name; int status, invalid_sig; struct pkg_task *pkg; @@ -1341,14 +1344,15 @@ pkg_do(const char *pkgpath, int mark_automatic, int top_level) status = -1; - pkg->archive = find_archive(pkgpath, top_level); + pkg->archive = find_archive(pkgpath, top_level, &archive_name); if (pkg->archive == NULL) { warnx("no pkg found for '%s', sorry.", pkgpath); goto clean_find_archive; } - invalid_sig = pkg_verify_signature(&pkg->archive, &pkg->entry, + invalid_sig = pkg_verify_signature(archive_name, &pkg->archive, &pkg->entry, &pkg->pkgname); + free(archive_name); if (pkg->archive == NULL) goto clean_memory; diff --git a/pkgtools/pkg_install/files/admin/main.c b/pkgtools/pkg_install/files/admin/main.c index ba63ee2306d..418e4020178 100644 --- a/pkgtools/pkg_install/files/admin/main.c +++ b/pkgtools/pkg_install/files/admin/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.59 2010/01/22 13:30:41 joerg Exp $ */ +/* $NetBSD: main.c,v 1.60 2010/02/20 04:40:03 joerg Exp $ */ #if HAVE_CONFIG_H #include "config.h" @@ -7,7 +7,7 @@ #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -__RCSID("$NetBSD: main.c,v 1.59 2010/01/22 13:30:41 joerg Exp $"); +__RCSID("$NetBSD: main.c,v 1.60 2010/02/20 04:40:03 joerg Exp $"); /*- * Copyright (c) 1999-2009 The NetBSD Foundation, Inc. @@ -614,13 +614,16 @@ main(int argc, char *argv[]) rc = 0; for (--argc, ++argv; argc > 0; --argc, ++argv) { - pkg = open_archive(*argv); + char *archive_name; + + pkg = open_archive(*argv, &archive_name); if (pkg == NULL) { warnx("%s could not be opened", *argv); continue; } - if (pkg_full_signature_check(&pkg)) + if (pkg_full_signature_check(archive_name, &pkg)) rc = 1; + free(archive_name); if (!pkg) archive_read_finish(pkg); } diff --git a/pkgtools/pkg_install/files/info/perform.c b/pkgtools/pkg_install/files/info/perform.c index 075e57f16fe..82781584a86 100644 --- a/pkgtools/pkg_install/files/info/perform.c +++ b/pkgtools/pkg_install/files/info/perform.c @@ -1,4 +1,4 @@ -/* $NetBSD: perform.c,v 1.60 2010/01/22 13:30:42 joerg Exp $ */ +/* $NetBSD: perform.c,v 1.61 2010/02/20 04:40:03 joerg Exp $ */ #if HAVE_CONFIG_H #include "config.h" @@ -13,7 +13,7 @@ #if HAVE_SYS_WAIT_H #include <sys/wait.h> #endif -__RCSID("$NetBSD: perform.c,v 1.60 2010/01/22 13:30:42 joerg Exp $"); +__RCSID("$NetBSD: perform.c,v 1.61 2010/02/20 04:40:03 joerg Exp $"); /*- * Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org>. @@ -346,16 +346,16 @@ pkg_do(const char *pkg) #else struct archive *archive; struct archive_entry *entry; - char *pkgname; + char *archive_name, *pkgname; - archive = open_archive(pkg); + archive = open_archive(pkg, &archive_name); if (archive == NULL) { warnx("can't find package `%s', skipped", pkg); return -1; } pkgname = NULL; entry = NULL; - pkg_verify_signature(&archive, &entry, &pkgname); + pkg_verify_signature(archive_name, &archive, &entry, &pkgname); if (archive == NULL) return -1; free(pkgname); diff --git a/pkgtools/pkg_install/files/lib/lib.h b/pkgtools/pkg_install/files/lib/lib.h index cedbcfa873d..1d6237171d5 100644 --- a/pkgtools/pkg_install/files/lib/lib.h +++ b/pkgtools/pkg_install/files/lib/lib.h @@ -1,4 +1,4 @@ -/* $NetBSD: lib.h,v 1.61 2010/02/03 19:28:30 joerg Exp $ */ +/* $NetBSD: lib.h,v 1.62 2010/02/20 04:40:03 joerg Exp $ */ /* from FreeBSD Id: lib.h,v 1.25 1997/10/08 07:48:03 charnier Exp */ @@ -322,8 +322,8 @@ int has_pkgdir(const char *); struct archive; struct archive_entry; -struct archive *open_archive(const char *); -struct archive *find_archive(const char *, int); +struct archive *open_archive(const char *, char **); +struct archive *find_archive(const char *, int, char **); void process_pkg_path(void); struct url *find_best_package(const char *, const char *, int); @@ -391,8 +391,8 @@ void pkg_install_config(void); void pkg_install_show_variable(const char *); /* Package signature creation and validation */ -int pkg_verify_signature(struct archive **, struct archive_entry **, char **); -int pkg_full_signature_check(struct archive **); +int pkg_verify_signature(const char *, struct archive **, struct archive_entry **, char **); +int pkg_full_signature_check(const char *, struct archive **); #ifdef HAVE_SSL void pkg_sign_x509(const char *, const char *, const char *, const char *); #endif diff --git a/pkgtools/pkg_install/files/lib/pkg_io.c b/pkgtools/pkg_install/files/lib/pkg_io.c index cf8e1329b8d..8a0a0d5f653 100644 --- a/pkgtools/pkg_install/files/lib/pkg_io.c +++ b/pkgtools/pkg_install/files/lib/pkg_io.c @@ -1,4 +1,4 @@ -/* $NetBSD: pkg_io.c,v 1.9 2009/08/16 21:10:15 joerg Exp $ */ +/* $NetBSD: pkg_io.c,v 1.10 2010/02/20 04:40:03 joerg Exp $ */ /*- * Copyright (c) 2008, 2009 Joerg Sonnenberger <joerg@NetBSD.org>. * All rights reserved. @@ -36,7 +36,7 @@ #include <sys/cdefs.h> #endif -__RCSID("$NetBSD: pkg_io.c,v 1.9 2009/08/16 21:10:15 joerg Exp $"); +__RCSID("$NetBSD: pkg_io.c,v 1.10 2010/02/20 04:40:03 joerg Exp $"); #include <archive.h> #include <archive_entry.h> @@ -98,7 +98,7 @@ fetch_archive_close(struct archive *a, void *client_data) } static struct archive * -open_archive_by_url(struct url *url) +open_archive_by_url(struct url *url, char **archive_name) { struct fetch_archive *f; struct archive *a; @@ -106,11 +106,15 @@ open_archive_by_url(struct url *url) f = xmalloc(sizeof(*f)); f->url = url; + *archive_name = fetchStringifyURL(url); + a = archive_read_new(); archive_read_support_compression_all(a); archive_read_support_format_all(a); if (archive_read_open(a, f, fetch_archive_open, fetch_archive_read, fetch_archive_close)) { + free(*archive_name); + *archive_name = NULL; archive_read_finish(a); return NULL; } @@ -119,11 +123,13 @@ open_archive_by_url(struct url *url) } struct archive * -open_archive(const char *url) +open_archive(const char *url, char **archive_name) { struct url *u; struct archive *a; + *archive_name = NULL; + if (!IS_URL(url)) { a = archive_read_new(); archive_read_support_compression_all(a); @@ -132,13 +138,14 @@ open_archive(const char *url) archive_read_close(a); return NULL; } + *archive_name = xstrdup(url); return a; } if ((u = fetchParseURL(url)) == NULL) return NULL; - a = open_archive_by_url(u); + a = open_archive_by_url(u, archive_name); fetchFreeURL(u); return a; @@ -291,7 +298,7 @@ find_best_package(const char *toplevel, const char *pattern, int do_path) } struct archive * -find_archive(const char *fname, int top_level) +find_archive(const char *fname, int top_level, char **archive_name) { struct archive *a; struct url *best_match; @@ -315,7 +322,7 @@ find_archive(const char *fname, int top_level) *last_slash = '/'; } - a = open_archive(full_fname); + a = open_archive(full_fname, archive_name); if (a != NULL) { free(full_fname); return a; @@ -333,7 +340,7 @@ find_archive(const char *fname, int top_level) if (best_match == NULL) return NULL; - a = open_archive_by_url(best_match); + a = open_archive_by_url(best_match, archive_name); fetchFreeURL(best_match); return a; } diff --git a/pkgtools/pkg_install/files/lib/pkg_signature.c b/pkgtools/pkg_install/files/lib/pkg_signature.c index e0cea4251b1..089234e010d 100644 --- a/pkgtools/pkg_install/files/lib/pkg_signature.c +++ b/pkgtools/pkg_install/files/lib/pkg_signature.c @@ -1,4 +1,4 @@ -/* $NetBSD: pkg_signature.c,v 1.9 2009/08/02 17:56:45 joerg Exp $ */ +/* $NetBSD: pkg_signature.c,v 1.10 2010/02/20 04:40:03 joerg Exp $ */ #if HAVE_CONFIG_H #include "config.h" @@ -7,7 +7,7 @@ #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -__RCSID("$NetBSD: pkg_signature.c,v 1.9 2009/08/02 17:56:45 joerg Exp $"); +__RCSID("$NetBSD: pkg_signature.c,v 1.10 2010/02/20 04:40:03 joerg Exp $"); /*- * Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org>. @@ -165,7 +165,8 @@ verify_signature_close_cb(struct archive *archive, void *cookie) } static int -read_file_from_archive(struct archive *archive, struct archive_entry **entry, +read_file_from_archive(const char *archive_name, struct archive *archive, + struct archive_entry **entry, const char *fname, char **content, size_t *len) { int r; @@ -177,10 +178,10 @@ retry: if (*entry == NULL && (r = archive_read_next_header(archive, entry)) != ARCHIVE_OK) { if (r == ARCHIVE_FATAL) { - warnx("Cannot read from archive: %s", - archive_error_string(archive)); + warnx("Cannot read from archive `%s': %s", + archive_name, archive_error_string(archive)); } else { - warnx("Premature end of archive"); + warnx("Premature end of archive `%s'", archive_name); } *entry = NULL; return -1; @@ -195,14 +196,16 @@ retry: return 1; if (archive_entry_size(*entry) > SSIZE_MAX - 1) { - warnx("signature too large to process"); + warnx("Signature of archive `%s' too large to process", + archive_name); return 1; } *len = archive_entry_size(*entry); *content = xmalloc(*len + 1); if (archive_read_data(archive, *content, *len) != (ssize_t)*len) { - warnx("cannot read complete %s from archive", fname); + warnx("Cannot read complete %s from archive `%s'", fname, + archive_name); free(*content); *len = 0; *content = NULL; @@ -310,8 +313,8 @@ cleanup: } int -pkg_verify_signature(struct archive **archive, struct archive_entry **entry, - char **pkgname) +pkg_verify_signature(const char *archive_name, struct archive **archive, + struct archive_entry **entry, char **pkgname) { struct signature_archive *state; struct archive_entry *my_entry; @@ -327,7 +330,7 @@ pkg_verify_signature(struct archive **archive, struct archive_entry **entry, state->sign_buf = NULL; state->archive = NULL; - r = read_file_from_archive(*archive, entry, HASH_FNAME, + r = read_file_from_archive(archive_name, *archive, entry, HASH_FNAME, &hash_file, &hash_len); if (r == -1) { archive_read_finish(*archive); @@ -342,7 +345,7 @@ pkg_verify_signature(struct archive **archive, struct archive_entry **entry, if (parse_hash_file(hash_file, pkgname, state)) goto no_valid_signature; - r = read_file_from_archive(*archive, entry, SIGNATURE_FNAME, + r = read_file_from_archive(archive_name, *archive, entry, SIGNATURE_FNAME, &signature_file, &signature_len); if (r == -1) { archive_read_finish(*archive); @@ -352,8 +355,8 @@ pkg_verify_signature(struct archive **archive, struct archive_entry **entry, goto no_valid_signature; } else if (r != 0) { if (*entry != NULL) - r = read_file_from_archive(*archive, entry, - GPG_SIGNATURE_FNAME, + r = read_file_from_archive(archive_name, *archive, + entry, GPG_SIGNATURE_FNAME, &signature_file, &signature_len); if (r == -1) { archive_read_finish(*archive); @@ -418,13 +421,13 @@ no_valid_signature: } int -pkg_full_signature_check(struct archive **archive) +pkg_full_signature_check(const char *archive_name, struct archive **archive) { struct archive_entry *entry = NULL; char *pkgname; int r; - if (pkg_verify_signature(archive, &entry, &pkgname)) + if (pkg_verify_signature(archive_name, archive, &entry, &pkgname)) return -1; if (pkgname == NULL) return 0; diff --git a/pkgtools/pkg_install/files/lib/version.h b/pkgtools/pkg_install/files/lib/version.h index a96a7fa7ebc..75e7a662202 100644 --- a/pkgtools/pkg_install/files/lib/version.h +++ b/pkgtools/pkg_install/files/lib/version.h @@ -1,4 +1,4 @@ -/* $NetBSD: version.h,v 1.150 2010/02/03 19:28:30 joerg Exp $ */ +/* $NetBSD: version.h,v 1.151 2010/02/20 04:40:03 joerg Exp $ */ /* * Copyright (c) 2001 Thomas Klausner. All rights reserved. @@ -27,6 +27,6 @@ #ifndef _INST_LIB_VERSION_H_ #define _INST_LIB_VERSION_H_ -#define PKGTOOLS_VERSION 20100204 +#define PKGTOOLS_VERSION 20100220 #endif /* _INST_LIB_VERSION_H_ */ |