summaryrefslogtreecommitdiff
path: root/pkgtools/pkg_install
diff options
context:
space:
mode:
authoragc <agc>2004-04-07 22:44:23 +0000
committeragc <agc>2004-04-07 22:44:23 +0000
commit4d5aa40724b023d8ea08c9151ed6248b1efd1944 (patch)
tree916bb47f05d892d4674245240f70c78f9a8f1447 /pkgtools/pkg_install
parent48ff3966ed94f182a99598e51278e89329f04d3d (diff)
downloadpkgsrc-4d5aa40724b023d8ea08c9151ed6248b1efd1944.tar.gz
Bring over a fix from main sources:
revision 1.5 date: 2004/04/06 05:56:07; author: agc; state: Exp; lines: +14 -11 Fix signature verification after pkg_add and friends were changed to use fexec() - trying to exec "gpg --verify %s" won't work with fexec, so split up the command into separate words.
Diffstat (limited to 'pkgtools/pkg_install')
-rw-r--r--pkgtools/pkg_install/files/add/verify.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/pkgtools/pkg_install/files/add/verify.c b/pkgtools/pkg_install/files/add/verify.c
index e6b1c95d9b6..91da3475c54 100644
--- a/pkgtools/pkg_install/files/add/verify.c
+++ b/pkgtools/pkg_install/files/add/verify.c
@@ -1,4 +1,4 @@
-/* $NetBSD: verify.c,v 1.5 2003/09/23 13:22:38 grant Exp $ */
+/* $NetBSD: verify.c,v 1.6 2004/04/07 22:44:23 agc Exp $ */
/*
* Copyright (c) 2001 Alistair G. Crooks. All rights reserved.
@@ -41,7 +41,7 @@
#ifndef lint
__COPYRIGHT("@(#) Copyright (c) 1999 \
The NetBSD Foundation, Inc. All rights reserved.");
-__RCSID("$NetBSD: verify.c,v 1.5 2003/09/23 13:22:38 grant Exp $");
+__RCSID("$NetBSD: verify.c,v 1.6 2004/04/07 22:44:23 agc Exp $");
#endif
#if HAVE_SYS_TYPES_H
@@ -77,7 +77,8 @@ enum {
/* this struct defines a verification type */
typedef struct ver_t {
const char *name; /* name of type */
- const char *command; /* command to execute to verify */
+ const char *command1; /* command to execute to verify */
+ const char *command2; /* command to execute to verify */
const char *extensions[MaxExtensions]; /* signature file extensions */
} ver_t;
@@ -85,22 +86,24 @@ static char *verification_type; /* the verification type which has been selected
/* called when gpg verification type is selected */
static int
-do_verify(const char *pkgname, const char *cmd, const char *const *extensions)
+do_verify(const char *pkgname, const char *cmd1, const char *cmd2, const char *const *extensions)
{
struct stat st;
const char *const *ep;
char buf[BUFSIZ];
char f[FILENAME_MAX];
+ int ret;
int i;
- if (cmd == NULL) {
+ if (cmd1 == NULL) {
return 1;
}
for (i = 0, ep = extensions ; i < MaxExtensions && *ep ; ep++, i++) {
(void) snprintf(f, sizeof(f), "%s%s", pkgname, *ep);
if (stat(f, &st) == 0) {
(void) fprintf(stderr, "pkg_add: Using signature file: %s\n", f);
- if (fexec(cmd, f, NULL) != 0) {
+ ret = (cmd2 == NULL) ? fexec(cmd1, f, NULL) : fexec(cmd1, cmd2, f, NULL);
+ if (ret != 0) {
(void) fprintf(stderr, "*** WARNING ***: `%s' has a bad signature\n", f);
return 0;
}
@@ -125,9 +128,9 @@ do_verify(const char *pkgname, const char *cmd, const char *const *extensions)
/* table holding possible verifications which can be made */
static const ver_t vertab[] = {
- { "none", NULL, { NULL } },
- { "gpg", "gpg --verify %s", { ".sig", ".asc", NULL } },
- { "pgp5", "pgpv %s", { ".sig", ".asc", ".pgp", NULL } },
+ { "none", NULL, NULL, { NULL } },
+ { "gpg", "gpg", "--verify", { ".sig", ".asc", NULL } },
+ { "pgp5", "pgpv", NULL, { ".sig", ".asc", ".pgp", NULL } },
{ NULL }
};
@@ -164,11 +167,11 @@ verify(const char *pkg)
const ver_t *vp;
if (verification_type == NULL) {
- return do_verify(pkg, NULL, NULL);
+ return do_verify(pkg, NULL, NULL, NULL);
}
for (vp = vertab ; vp->name ; vp++) {
if (strcasecmp(verification_type, vp->name) == 0) {
- return do_verify(pkg, vp->command, vp->extensions);
+ return do_verify(pkg, vp->command1, vp->command2, vp->extensions);
}
}
(void) fprintf(stderr, "Can't find `%s' verification details\n", verification_type);