summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES2
-rw-r--r--build/pack.c10
-rw-r--r--lib/package.c50
-rw-r--r--lib/psm.c68
-rw-r--r--lib/psm.h2
-rw-r--r--lib/query.c27
-rw-r--r--lib/rpmchecksig.c47
-rw-r--r--lib/rpminstall.c192
-rw-r--r--lib/rpmlead.c14
-rw-r--r--lib/rpmlead.h8
-rw-r--r--lib/rpmlib.h17
-rw-r--r--lib/rpmts.c29
-rw-r--r--lib/rpmts.h4
-rw-r--r--lib/signature.c95
-rw-r--r--lib/transaction.c6
-rw-r--r--python/rpmts-py.c34
-rw-r--r--rpm.spec.in6
-rw-r--r--rpm2cpio.c4
-rw-r--r--tools/Makefile.am2
-rw-r--r--tools/rpmgraph.c26
20 files changed, 339 insertions, 304 deletions
diff --git a/CHANGES b/CHANGES
index e3b9767e9..54bdf04d9 100644
--- a/CHANGES
+++ b/CHANGES
@@ -260,6 +260,8 @@
- fix: region trailer offset sanity check wrong (#71996).
- fix: don't stop if db1 database is currently in /var/lib/rpm (#72224).
- add a macro to create a sub-package with debugging symbols.
+ - merge signature returns into rpmRC.
+ - python: exceptions on NOKEY/NOTTRUSTED.
4.0.3 -> 4.0.4:
- solaris: translate i86pc to i386 (#57182).
diff --git a/build/pack.c b/build/pack.c
index 329f8dd89..72790698e 100644
--- a/build/pack.c
+++ b/build/pack.c
@@ -338,15 +338,15 @@ int readRPM(const char *fileName, Spec *specp, struct rpmlead *lead,
}
switch (rc) {
+ case RPMRC_OK:
+ case RPMRC_NOKEY:
+ case RPMRC_NOTTRUSTED:
+ break;
case RPMRC_NOTFOUND:
rpmError(RPMERR_BADMAGIC, _("readRPM: %s is not an RPM package\n"),
(fileName ? fileName : "<stdin>"));
return RPMERR_BADMAGIC;
- case RPMRC_OK:
- break;
case RPMRC_FAIL:
- case RPMRC_BADSIZE:
- case RPMRC_SHORTREAD:
default:
rpmError(RPMERR_BADMAGIC, _("readRPM: reading header from %s\n"),
(fileName ? fileName : "<stdin>"));
@@ -624,7 +624,7 @@ int writeRPM(Header *hdrp, const char *fileName, int type,
strncpy(lead.name, buf, sizeof(lead.name));
}
- if (writeLead(fd, &lead)) {
+ if (writeLead(fd, &lead) != RPMRC_OK) {
rc = RPMERR_NOSPACE;
rpmError(RPMERR_NOSPACE, _("Unable to write package: %s\n"),
Fstrerror(fd));
diff --git a/lib/package.c b/lib/package.c
index 923e3deb2..e355cfcf6 100644
--- a/lib/package.c
+++ b/lib/package.c
@@ -563,22 +563,7 @@ verifyinfo_exit:
/*@-boundswrite@*/
buf[0] = '\0';
/*@=boundswrite@*/
- switch (rpmVerifySignature(ts, buf)) {
- case RPMSIG_OK: /* Signature is OK. */
- rc = RPMRC_OK;
- break;
- case RPMSIG_NOTTRUSTED: /* Signature is OK, but key is not trusted. */
- case RPMSIG_NOKEY: /* Key is unavailable. */
- rc = RPMRC_OK;
- break;
- case RPMSIG_UNKNOWN: /* Signature is unknown type. */
- rc = RPMRC_OK;
- break;
- default:
- case RPMSIG_BAD: /* Signature does not verify. */
- rc = RPMRC_FAIL;
- break;
- }
+ rc = rpmVerifySignature(ts, buf);
/*@-boundswrite@*/
if (msg != NULL)
@@ -619,7 +604,8 @@ int rpmReadPackageFile(rpmts ts, FD_t fd,
}
memset(l, 0, sizeof(*l));
- if (readLead(fd, l)) {
+ rc = readLead(fd, l);
+ if (rc != RPMRC_OK) {
rc = RPMRC_NOTFOUND;
goto exit;
}
@@ -643,14 +629,18 @@ int rpmReadPackageFile(rpmts ts, FD_t fd,
/* Read the signature header. */
rc = rpmReadSignature(fd, &sigh, l->signature_type);
- if (!(rc == RPMRC_OK || rc == RPMRC_BADSIZE)) {
+ switch (rc) {
+ default:
rpmError(RPMERR_SIGGEN, _("%s: rpmReadSignature failed\n"), fn);
goto exit;
- }
- if (sigh == NULL) {
- rpmError(RPMERR_SIGGEN, _("%s: No signature available\n"), fn);
- rc = RPMRC_FAIL;
- goto exit;
+ /*@notreached@*/ break;
+ case RPMRC_OK:
+ if (sigh == NULL) {
+ rpmError(RPMERR_SIGGEN, _("%s: No signature available\n"), fn);
+ rc = RPMRC_FAIL;
+ goto exit;
+ }
+ break;
}
#define _chk(_mask) (sigtag == 0 && !(vsflags & (_mask)))
@@ -818,24 +808,24 @@ int rpmReadPackageFile(rpmts ts, FD_t fd,
/*@-boundswrite@*/
buf[0] = '\0';
/*@=boundswrite@*/
- switch (rpmVerifySignature(ts, buf)) {
- case RPMSIG_OK: /* Signature is OK. */
+ rc = rpmVerifySignature(ts, buf);
+ switch (rc) {
+ case RPMRC_OK: /* Signature is OK. */
rpmMessage(RPMMESS_DEBUG, "%s: %s", fn, buf);
- rc = RPMRC_OK;
break;
- case RPMSIG_NOTTRUSTED: /* Signature is OK, but key is not trusted. */
- case RPMSIG_NOKEY: /* Key is unavailable. */
+ case RPMRC_NOTTRUSTED: /* Signature is OK, but key is not trusted. */
+ case RPMRC_NOKEY: /* Public key is unavailable. */
/* XXX Print NOKEY/NOTTRUSTED warning only once. */
{ int lvl = (rpmtsStashKeyid(ts) ? RPMMESS_DEBUG : RPMMESS_WARNING);
rpmMessage(lvl, "%s: %s", fn, buf);
rc = RPMRC_OK;
} break;
- case RPMSIG_UNKNOWN: /* Signature is unknown type. */
+ case RPMRC_NOTFOUND: /* Signature is unknown type. */
rpmMessage(RPMMESS_WARNING, "%s: %s", fn, buf);
rc = RPMRC_OK;
break;
default:
- case RPMSIG_BAD: /* Signature does not verify. */
+ case RPMRC_FAIL: /* Signature does not verify. */
rpmMessage(RPMMESS_ERROR, "%s: %s", fn, buf);
rc = RPMRC_FAIL;
break;
diff --git a/lib/psm.c b/lib/psm.c
index c1698a184..439969596 100644
--- a/lib/psm.c
+++ b/lib/psm.c
@@ -155,10 +155,10 @@ static int rpmInstallLoadMacros(rpmfi fi, Header h)
* @param fi transaction element file info
* @param h header from
* @param newH header to
- * @return 0 on success, 1 on failure
+ * @return 0 on success
*/
/*@-boundswrite@*/
-static int mergeFiles(rpmfi fi, Header h, Header newH)
+static rpmRC mergeFiles(rpmfi fi, Header h, Header newH)
/*@modifies h @*/
{
HGE_t hge = (HGE_t)fi->hge;
@@ -249,7 +249,7 @@ static int mergeFiles(rpmfi fi, Header h, Header newH)
default:
rpmError(RPMERR_DATATYPE, _("Data type %d not supported\n"),
(int) type);
- return 1;
+ return RPMRC_FAIL;
/*@notreached@*/ /*@switchbreak@*/ break;
}
data = hfd(data, type);
@@ -333,7 +333,7 @@ static int mergeFiles(rpmfi fi, Header h, Header newH)
newEVR = hfd(newEVR, nvt);
Names = hfd(Names, rnt);
}
- return 0;
+ return RPMRC_OK;
}
/*@=boundswrite@*/
@@ -343,7 +343,7 @@ static int mergeFiles(rpmfi fi, Header h, Header newH)
* @return 0 always
*/
/*@-bounds@*/
-static int markReplacedFiles(const rpmpsm psm)
+static rpmRC markReplacedFiles(const rpmpsm psm)
/*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
/*@modifies psm, rpmGlobalMacroContext, fileSystem, internalState @*/
{
@@ -359,7 +359,7 @@ static int markReplacedFiles(const rpmpsm psm)
int num, xx;
if (!(rpmfiFC(fi) > 0 && fi->replaced))
- return 0;
+ return RPMRC_OK;
num = prev = 0;
for (sfi = replaced; sfi->otherPkg; sfi++) {
@@ -369,7 +369,7 @@ static int markReplacedFiles(const rpmpsm psm)
num++;
}
if (num == 0)
- return 0;
+ return RPMRC_OK;
offsets = alloca(num * sizeof(*offsets));
offsets[0] = 0;
@@ -414,7 +414,7 @@ static int markReplacedFiles(const rpmpsm psm)
}
mi = rpmdbFreeIterator(mi);
- return 0;
+ return RPMRC_OK;
}
/*@=bounds@*/
@@ -436,10 +436,20 @@ rpmRC rpmInstallSourcePackage(rpmts ts, FD_t fd,
int i;
rc = rpmReadPackageFile(ts, fd, "InstallSourcePackage", &h);
- if (!(rc == RPMRC_OK || rc == RPMRC_BADSIZE) || h == NULL) {
+ switch (rc) {
+ case RPMRC_NOTTRUSTED:
+ case RPMRC_NOKEY:
+ case RPMRC_OK:
+ break;
+ default:
goto exit;
+ /*@notreached@*/ break;
}
- rc = RPMRC_OK; /* XXX HACK */
+ if (h == NULL)
+ goto exit;
+
+ rc = RPMRC_OK;
+
isSource = headerIsEntry(h, RPMTAG_SOURCEPACKAGE);
if (!isSource) {
@@ -934,9 +944,9 @@ static const char * ldconfig_path = "/sbin/ldconfig";
* @param arg1 no. instances of package installed after scriptlet exec
* (-1 is no arg)
* @param arg2 ditto, but for the target package
- * @return 0 on success, 1 on error
+ * @return 0 on success
*/
-static int runScript(rpmpsm psm, Header h,
+static rpmRC runScript(rpmpsm psm, Header h,
const char * sln,
int progArgc, const char ** progArgv,
const char * script, int arg1, int arg2)
@@ -967,7 +977,7 @@ static int runScript(rpmpsm psm, Header h,
const char *n, *v, *r;
if (progArgv == NULL && script == NULL)
- return 0;
+ return rc;
psm->child = 0;
psm->reaped = 0;
@@ -1030,7 +1040,7 @@ static int runScript(rpmpsm psm, Header h,
/*@-branchstate@*/
if (makeTempFile((!rpmtsChrootDone(ts) ? rootDir : "/"), &fn, &fd)) {
if (freePrefixes) free(prefixes);
- return 1;
+ return RPMRC_FAIL;
}
/*@=branchstate@*/
@@ -1083,7 +1093,7 @@ static int runScript(rpmpsm psm, Header h,
} else {
out = fdDup(STDOUT_FILENO);
}
- if (out == NULL) return 1; /* XXX can't happen */
+ if (out == NULL) return RPMRC_FAIL; /* XXX can't happen */
/*@-branchstate@*/
if (!psmFork(psm)) {
@@ -1259,7 +1269,8 @@ exit:
* @param triggersAlreadyRun
* @return
*/
-static int handleOneTrigger(const rpmpsm psm, Header sourceH, Header triggeredH,
+static rpmRC handleOneTrigger(const rpmpsm psm,
+ Header sourceH, Header triggeredH,
int arg2, unsigned char * triggersAlreadyRun)
/*@globals rpmGlobalMacroContext, fileSystem, internalState@*/
/*@modifies psm, sourceH, triggeredH, *triggersAlreadyRun,
@@ -1356,9 +1367,9 @@ static int handleOneTrigger(const rpmpsm psm, Header sourceH, Header triggeredH,
/**
* Run trigger scripts in the database that are fired by this header.
* @param psm package state machine data
- * @return 0 on success, 1 on error
+ * @return 0 on success
*/
-static int runTriggers(rpmpsm psm)
+static rpmRC runTriggers(rpmpsm psm)
/*@globals rpmGlobalMacroContext,
fileSystem, internalState @*/
/*@modifies psm, rpmGlobalMacroContext,
@@ -1397,9 +1408,9 @@ static int runTriggers(rpmpsm psm)
/**
* Run triggers from this header that are fired by headers in the database.
* @param psm package state machine data
- * @return 0 on success, 1 on error
+ * @return 0 on success
*/
-static int runImmedTriggers(rpmpsm psm)
+static rpmRC runImmedTriggers(rpmpsm psm)
/*@globals rpmGlobalMacroContext,
fileSystem, internalState @*/
/*@modifies psm, rpmGlobalMacroContext,
@@ -1417,14 +1428,14 @@ static int runImmedTriggers(rpmpsm psm)
unsigned char * triggersRun;
rpmRC rc = RPMRC_OK;
- if (fi->h == NULL) return 0; /* XXX can't happen */
+ if (fi->h == NULL) return rc; /* XXX can't happen */
if (!( hge(fi->h, RPMTAG_TRIGGERNAME, &tnt,
(void **) &triggerNames, &numTriggers) &&
hge(fi->h, RPMTAG_TRIGGERINDEX, &tit,
(void **) &triggerIndices, &numTriggerIndices))
)
- return 0;
+ return rc;
triggersRun = alloca(sizeof(*triggersRun) * numTriggerIndices);
memset(triggersRun, 0, sizeof(*triggersRun) * numTriggerIndices);
@@ -1571,7 +1582,7 @@ rpmpsm rpmpsmNew(rpmts ts, rpmte te, rpmfi fi)
* on install with -v.
*/
/*@-bounds -nullpass@*/ /* FIX: testing null annotation for fi->h */
-int rpmpsmStage(rpmpsm psm, pkgStage stage)
+rpmRC rpmpsmStage(rpmpsm psm, pkgStage stage)
{
const rpmts ts = psm->ts;
rpmfi fi = psm->fi;
@@ -1642,8 +1653,8 @@ assert(psm->mi == NULL);
* need the leading / stripped.
*/
{ const char * p;
- rc = hge(fi->h, RPMTAG_DEFAULTPREFIX, NULL, (void **) &p, NULL);
- fi->striplen = (rc ? strlen(p) + 1 : 1);
+ xx = hge(fi->h, RPMTAG_DEFAULTPREFIX, NULL, (void **) &p, NULL);
+ fi->striplen = (xx ? strlen(p) + 1 : 1);
}
fi->mapflags =
CPIO_MAP_PATH | CPIO_MAP_MODE | CPIO_MAP_UID | CPIO_MAP_GID;
@@ -1670,7 +1681,7 @@ assert(psm->mi == NULL);
/* Retrieve installed header. */
rc = rpmpsmStage(psm, PSM_RPMDB_LOAD);
-if (rc == 0)
+if (rc == RPMRC_OK)
if (psm->te)
psm->te->h = headerLink(fi->h);
}
@@ -1710,7 +1721,7 @@ psm->te->h = headerLink(fi->h);
if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_NOPRE)) {
rc = rpmpsmStage(psm, PSM_SCRIPT);
- if (rc) {
+ if (rc != RPMRC_OK) {
rpmError(RPMERR_SCRIPT,
_("%s: %s scriptlet failed (%d), skipping %s\n"),
psm->stepName, tag2sln(psm->scriptTag), rc,
@@ -1808,10 +1819,9 @@ psm->te->h = headerLink(fi->h);
strncpy(lead.name, rpmteNEVR(psm->te), sizeof(lead.name));
rc = writeLead(psm->fd, &lead);
- if (rc) {
+ if (rc != RPMRC_OK) {
rpmError(RPMERR_NOSPACE, _("Unable to write package: %s\n"),
Fstrerror(psm->fd));
- rc = RPMRC_FAIL;
break;
}
}
diff --git a/lib/psm.h b/lib/psm.h
index 33d4d9b1d..58931687c 100644
--- a/lib/psm.h
+++ b/lib/psm.h
@@ -174,7 +174,7 @@ rpmpsm rpmpsmNew(rpmts ts, /*@null@*/ rpmte te, rpmfi fi)
* @param stage next stage
* @return 0 on success
*/
-int rpmpsmStage(rpmpsm psm, pkgStage stage)
+rpmRC rpmpsmStage(rpmpsm psm, pkgStage stage)
/*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
/*@modifies psm, rpmGlobalMacroContext, fileSystem, internalState @*/;
diff --git a/lib/query.c b/lib/query.c
index c2aaf35e0..d87077308 100644
--- a/lib/query.c
+++ b/lib/query.c
@@ -573,25 +573,32 @@ restart:
(void) Fclose(fd);
- if (!(rpmrc == RPMRC_OK || rpmrc == RPMRC_NOTFOUND)) {
+ res = 0;
+ switch (rpmrc) {
+ default:
rpmError(RPMERR_QUERY, _("query of %s failed\n"), fileURL);
res = 1;
- /*@loopbreak@*/ break;
- }
- if (rpmrc == RPMRC_OK && h == NULL) {
- rpmError(RPMERR_QUERY,
+ /*@switchbreak@*/ break;
+ case RPMRC_OK:
+ if (h == NULL) {
+ rpmError(RPMERR_QUERY,
_("old format source packages cannot be queried\n"));
- res = 1;
- /*@loopbreak@*/ break;
- }
+ res = 1;
+ /*@switchbreak@*/ break;
+ }
- /* Query a package file. */
- if (rpmrc == RPMRC_OK) {
+ /* Query a package file. */
res = qva->qva_showPackage(qva, ts, h);
h = headerFree(h);
rpmtsEmpty(ts);
continue;
+ /*@notreached@*/ /*@switchbreak@*/ break;
+ case RPMRC_NOTFOUND:
+ res = 0;
+ /*@switchbreak@*/ break;
}
+ if (res)
+ /*@loopbreak@*/ break;
/* Try to read a package manifest. */
fd = Fopen(fileURL, "r.fpio");
diff --git a/lib/rpmchecksig.c b/lib/rpmchecksig.c
index 008340f4d..01be70d6a 100644
--- a/lib/rpmchecksig.c
+++ b/lib/rpmchecksig.c
@@ -204,7 +204,8 @@ static int rpmReSign(/*@unused@*/ rpmts ts,
/*@-boundswrite@*/
memset(l, 0, sizeof(*l));
/*@=boundswrite@*/
- if (readLead(fd, l)) {
+ rc = readLead(fd, l);
+ if (rc != RPMRC_OK) {
rpmError(RPMERR_READLEAD, _("%s: not an rpm package\n"), rpm);
goto exit;
}
@@ -222,13 +223,17 @@ static int rpmReSign(/*@unused@*/ rpmts ts,
}
rc = rpmReadSignature(fd, &sigh, l->signature_type);
- if (!(rc == RPMRC_OK || rc == RPMRC_BADSIZE)) {
+ switch (rc) {
+ default:
rpmError(RPMERR_SIGGEN, _("%s: rpmReadSignature failed\n"), rpm);
goto exit;
- }
- if (sigh == NULL) {
- rpmError(RPMERR_SIGGEN, _("%s: No signature available\n"), rpm);
- goto exit;
+ /*@notreached@*/ /*@switchbreak@*/ break;
+ case RPMRC_OK:
+ if (sigh == NULL) {
+ rpmError(RPMERR_SIGGEN, _("%s: No signature available\n"), rpm);
+ goto exit;
+ }
+ /*@switchbreak@*/ break;
}
/* Write the header and archive to a temp file */
@@ -343,7 +348,8 @@ static int rpmReSign(/*@unused@*/ rpmts ts,
goto exit;
l->signature_type = RPMSIGTYPE_HEADERSIG;
- if (writeLead(ofd, l)) {
+ rc = writeLead(ofd, l);
+ if (rc != RPMRC_OK) {
rpmError(RPMERR_WRITELEAD, _("%s: writeLead failed: %s\n"), trpm,
Fstrerror(ofd));
goto exit;
@@ -687,7 +693,8 @@ int rpmVerifySignatures(QVA_t qva, rpmts ts, FD_t fd,
/*@-boundswrite@*/
memset(l, 0, sizeof(*l));
/*@=boundswrite@*/
- if (readLead(fd, l)) {
+ rc = readLead(fd, l);
+ if (rc != RPMRC_OK) {
rpmError(RPMERR_READLEAD, _("%s: not an rpm package\n"), fn);
res++;
goto exit;
@@ -703,15 +710,19 @@ int rpmVerifySignatures(QVA_t qva, rpmts ts, FD_t fd,
}
rc = rpmReadSignature(fd, &sigh, l->signature_type);
- if (!(rc == RPMRC_OK || rc == RPMRC_BADSIZE)) {
+ switch (rc) {
+ default:
rpmError(RPMERR_SIGGEN, _("%s: rpmReadSignature failed\n"), fn);
res++;
goto exit;
- }
- if (sigh == NULL) {
- rpmError(RPMERR_SIGGEN, _("%s: No signature available\n"), fn);
- res++;
- goto exit;
+ /*@notreached@*/ /*@switchbreak@*/ break;
+ case RPMRC_OK:
+ if (sigh == NULL) {
+ rpmError(RPMERR_SIGGEN, _("%s: No signature available\n"), fn);
+ res++;
+ goto exit;
+ }
+ /*@switchbreak@*/ break;
}
/* Grab a hint of what needs doing to avoid duplication. */
@@ -844,10 +855,10 @@ int rpmVerifySignatures(QVA_t qva, rpmts ts, FD_t fd,
case RPMSIGTAG_PGP5: /* XXX legacy */
case RPMSIGTAG_PGP:
switch (res3) {
- case RPMSIG_NOKEY:
+ case RPMRC_NOKEY:
res2 = 1;
/*@fallthrough@*/
- case RPMSIG_NOTTRUSTED:
+ case RPMRC_NOTTRUSTED:
{ int offset = 6;
b = stpcpy(b, "(MD5) (PGP) ");
tempKey = strstr(result, "ey ID");
@@ -856,7 +867,7 @@ int rpmVerifySignatures(QVA_t qva, rpmts ts, FD_t fd,
offset = 9;
}
if (tempKey) {
- if (res3 == RPMSIG_NOKEY) {
+ if (res3 == RPMRC_NOKEY) {
m = stpcpy(m, " PGP#");
m = stpncpy(m, tempKey + offset, 8);
*m = '\0';
@@ -880,7 +891,7 @@ int rpmVerifySignatures(QVA_t qva, rpmts ts, FD_t fd,
case RPMSIGTAG_GPG:
/* Do not consider this a failure */
switch (res3) {
- case RPMSIG_NOKEY:
+ case RPMRC_NOKEY:
b = stpcpy(b, "(GPG) ");
m = stpcpy(m, " GPG#");
tempKey = strstr(result, "ey ID");
diff --git a/lib/rpminstall.c b/lib/rpminstall.c
index 7bc250502..7832b7a10 100644
--- a/lib/rpminstall.c
+++ b/lib/rpminstall.c
@@ -463,20 +463,26 @@ if (fileURL[0] == '=') {
tvsflags = rpmtsSetVSFlags(ts, vsflags);
eiu->rpmrc = rpmReadPackageFile(ts, eiu->fd, *eiu->fnp, &eiu->h);
tvsflags = rpmtsSetVSFlags(ts, tvsflags);
-
- eiu->isSource = headerIsEntry(eiu->h, RPMTAG_SOURCEPACKAGE);
-
xx = Fclose(eiu->fd);
eiu->fd = NULL;
- if (eiu->rpmrc == RPMRC_FAIL || eiu->rpmrc == RPMRC_SHORTREAD) {
+ switch (eiu->rpmrc) {
+ case RPMRC_FAIL:
+ rpmMessage(RPMMESS_ERROR, _("%s cannot be installed\n"), *eiu->fnp);
eiu->numFailed++; *eiu->fnp = NULL;
continue;
+ /*@notreached@*/ /*@switchbreak@*/ break;
+ case RPMRC_NOTFOUND:
+ goto maybe_manifest;
+ /*@notreached@*/ /*@switchbreak@*/ break;
+ case RPMRC_OK:
+ default:
+ /*@switchbreak@*/ break;
}
- if (eiu->isSource &&
- (eiu->rpmrc == RPMRC_OK || eiu->rpmrc == RPMRC_BADSIZE))
- {
+ eiu->isSource = headerIsEntry(eiu->h, RPMTAG_SOURCEPACKAGE);
+
+ if (eiu->isSource) {
rpmMessage(RPMMESS_DEBUG, "\tadded source package [%d]\n",
eiu->numSRPMS);
eiu->sourceURL = xrealloc(eiu->sourceURL,
@@ -488,95 +494,87 @@ if (fileURL[0] == '=') {
continue;
}
- if (eiu->rpmrc == RPMRC_OK || eiu->rpmrc == RPMRC_BADSIZE) {
-
- if (eiu->relocations) {
- const char ** paths;
- int pft;
- int c;
+ if (eiu->relocations) {
+ const char ** paths;
+ int pft;
+ int c;
- if (headerGetEntry(eiu->h, RPMTAG_PREFIXES, &pft,
+ if (headerGetEntry(eiu->h, RPMTAG_PREFIXES, &pft,
(void **) &paths, &c) && (c == 1))
- {
- eiu->relocations->oldPath = xstrdup(paths[0]);
- paths = headerFreeData(paths, pft);
- } else {
- const char * name;
- xx = headerNVR(eiu->h, &name, NULL, NULL);
- rpmMessage(RPMMESS_ERROR,
+ {
+ eiu->relocations->oldPath = xstrdup(paths[0]);
+ paths = headerFreeData(paths, pft);
+ } else {
+ const char * name;
+ xx = headerNVR(eiu->h, &name, NULL, NULL);
+ rpmMessage(RPMMESS_ERROR,
_("package %s is not relocateable\n"), name);
- eiu->numFailed++;
- goto exit;
- /*@notreached@*/
- }
+ eiu->numFailed++;
+ goto exit;
+ /*@notreached@*/
}
+ }
- /* On --freshen, verify package is installed and newer */
- if (ia->installInterfaceFlags & INSTALL_FRESHEN) {
- rpmdbMatchIterator mi;
- const char * name;
- Header oldH;
- int count;
-
- xx = headerNVR(eiu->h, &name, NULL, NULL);
- mi = rpmtsInitIterator(ts, RPMTAG_NAME, name, 0);
- count = rpmdbGetIteratorCount(mi);
- while ((oldH = rpmdbNextIterator(mi)) != NULL) {
- if (rpmVersionCompare(oldH, eiu->h) < 0)
- /*@innercontinue@*/ continue;
- /* same or newer package already installed */
- count = 0;
- /*@innerbreak@*/ break;
- }
- mi = rpmdbFreeIterator(mi);
- if (count == 0) {
- eiu->h = headerFree(eiu->h);
- continue;
- }
- /* Package is newer than those currently installed. */
+ /* On --freshen, verify package is installed and newer */
+ if (ia->installInterfaceFlags & INSTALL_FRESHEN) {
+ rpmdbMatchIterator mi;
+ const char * name;
+ Header oldH;
+ int count;
+
+ xx = headerNVR(eiu->h, &name, NULL, NULL);
+ mi = rpmtsInitIterator(ts, RPMTAG_NAME, name, 0);
+ count = rpmdbGetIteratorCount(mi);
+ while ((oldH = rpmdbNextIterator(mi)) != NULL) {
+ if (rpmVersionCompare(oldH, eiu->h) < 0)
+ /*@innercontinue@*/ continue;
+ /* same or newer package already installed */
+ count = 0;
+ /*@innerbreak@*/ break;
+ }
+ mi = rpmdbFreeIterator(mi);
+ if (count == 0) {
+ eiu->h = headerFree(eiu->h);
+ continue;
}
+ /* Package is newer than those currently installed. */
+ }
- /*@-abstract@*/
- rc = rpmtsAddInstallElement(ts, eiu->h, (fnpyKey)fileName,
+ /*@-abstract@*/
+ rc = rpmtsAddInstallElement(ts, eiu->h, (fnpyKey)fileName,
(ia->installInterfaceFlags & INSTALL_UPGRADE) != 0,
relocations);
- /*@=abstract@*/
+ /*@=abstract@*/
- /* XXX reference held by transaction set */
- eiu->h = headerFree(eiu->h);
- if (eiu->relocations)
- eiu->relocations->oldPath = _free(eiu->relocations->oldPath);
+ /* XXX reference held by transaction set */
+ eiu->h = headerFree(eiu->h);
+ if (eiu->relocations)
+ eiu->relocations->oldPath = _free(eiu->relocations->oldPath);
- switch(rc) {
- case 0:
- rpmMessage(RPMMESS_DEBUG, "\tadded binary package [%d]\n",
+ switch(rc) {
+ case 0:
+ rpmMessage(RPMMESS_DEBUG, "\tadded binary package [%d]\n",
eiu->numRPMS);
- /*@switchbreak@*/ break;
- case 1:
- rpmMessage(RPMMESS_ERROR,
+ /*@switchbreak@*/ break;
+ case 1:
+ rpmMessage(RPMMESS_ERROR,
_("error reading from file %s\n"), *eiu->fnp);
- eiu->numFailed++;
- goto exit;
- /*@notreached@*/ /*@switchbreak@*/ break;
- case 2:
- rpmMessage(RPMMESS_ERROR,
+ eiu->numFailed++;
+ goto exit;
+ /*@notreached@*/ /*@switchbreak@*/ break;
+ case 2:
+ rpmMessage(RPMMESS_ERROR,
_("file %s requires a newer version of RPM\n"),
*eiu->fnp);
- eiu->numFailed++;
- goto exit;
- /*@notreached@*/ /*@switchbreak@*/ break;
- }
-
- eiu->numRPMS++;
- continue;
+ eiu->numFailed++;
+ goto exit;
+ /*@notreached@*/ /*@switchbreak@*/ break;
}
- if (eiu->rpmrc != RPMRC_NOTFOUND) {
- rpmMessage(RPMMESS_ERROR, _("%s cannot be installed\n"), *eiu->fnp);
- eiu->numFailed++; *eiu->fnp = NULL;
- break;
- }
+ eiu->numRPMS++;
+ continue;
+maybe_manifest:
/* Try to read a package manifest. */
eiu->fd = Fopen(*eiu->fnp, "r.fpio");
if (eiu->fd == NULL || Ferror(eiu->fd)) {
@@ -599,7 +597,7 @@ if (fileURL[0] == '=') {
eiu->fd = NULL;
/* If successful, restart the query loop. */
- if (rc == 0) {
+ if (rc == RPMRC_OK) {
eiu->prevx++;
goto restart;
}
@@ -971,19 +969,18 @@ IDTX IDTXglob(rpmts ts, const char * globstr, rpmTag tag)
FD_t fd;
const char ** av = NULL;
int ac = 0;
- int rc;
+ rpmRC rpmrc;
int xx;
int i;
av = NULL; ac = 0;
- rc = rpmGlob(globstr, &ac, &av);
+ xx = rpmGlob(globstr, &ac, &av);
- if (rc == 0)
+ if (xx == 0)
for (i = 0; i < ac; i++) {
rpmTagType type;
int_32 count;
int isSource;
- rpmRC rpmrc;
fd = Fopen(av[i], "r.ufdio");
if (fd == NULL || Ferror(fd)) {
@@ -993,13 +990,17 @@ IDTX IDTXglob(rpmts ts, const char * globstr, rpmTag tag)
continue;
}
- xx = rpmReadPackageFile(ts, fd, av[i], &h);
- rpmrc = (xx ? RPMRC_FAIL : RPMRC_OK); /* XXX HACK */
- isSource = headerIsEntry(h, RPMTAG_SOURCEPACKAGE);
-
- if (rpmrc != RPMRC_OK || isSource) {
- (void) Fclose(fd);
- continue;
+ rpmrc = rpmReadPackageFile(ts, fd, av[i], &h);
+ (void) Fclose(fd);
+ switch (rpmrc) {
+ default:
+ goto bottom;
+ /*@notreached@*/ /*@switchbreak@*/ break;
+ case RPMRC_OK:
+ isSource = headerIsEntry(h, RPMTAG_SOURCEPACKAGE);
+ if (isSource)
+ goto bottom;
+ /*@switchbreak@*/ break;
}
tidp = NULL;
@@ -1007,11 +1008,9 @@ IDTX IDTXglob(rpmts ts, const char * globstr, rpmTag tag)
if (hge(h, tag, &type, (void **) &tidp, &count) && tidp) {
idtx = IDTXgrow(idtx, 1);
- if (idtx == NULL || idtx->idt == NULL) {
- h = headerFree(h);
- (void) Fclose(fd);
- continue;
- }
+ if (idtx == NULL || idtx->idt == NULL)
+ goto bottom;
+
{ IDT idt;
idt = idtx->idt + idtx->nidt;
idt->h = headerLink(h);
@@ -1023,9 +1022,8 @@ IDTX IDTXglob(rpmts ts, const char * globstr, rpmTag tag)
idtx->nidt++;
}
/*@=branchstate@*/
-
+bottom:
h = headerFree(h);
- (void) Fclose(fd);
}
for (i = 0; i < ac; i++)
diff --git a/lib/rpmlead.c b/lib/rpmlead.c
index 65fa3af0c..348517856 100644
--- a/lib/rpmlead.c
+++ b/lib/rpmlead.c
@@ -22,7 +22,7 @@ static unsigned char lead_magic[] = {
/* The lead needs to be 8 byte aligned */
-int writeLead(FD_t fd, const struct rpmlead *lead)
+rpmRC writeLead(FD_t fd, const struct rpmlead *lead)
{
struct rpmlead l;
@@ -38,13 +38,13 @@ int writeLead(FD_t fd, const struct rpmlead *lead)
/*@-boundswrite@*/
if (Fwrite(&l, 1, sizeof(l), fd) != sizeof(l))
- return 1;
+ return RPMRC_FAIL;
/*@=boundswrite@*/
- return 0;
+ return RPMRC_OK;
}
-int readLead(FD_t fd, struct rpmlead *lead)
+rpmRC readLead(FD_t fd, struct rpmlead *lead)
{
/*@-boundswrite@*/
memset(lead, 0, sizeof(*lead));
@@ -53,12 +53,12 @@ int readLead(FD_t fd, struct rpmlead *lead)
if (timedRead(fd, (char *)lead, sizeof(*lead)) != sizeof(*lead)) {
rpmError(RPMERR_READ, _("read failed: %s (%d)\n"), Fstrerror(fd),
errno);
- return 1;
+ return RPMRC_FAIL;
}
/*@=type@*/
if (memcmp(lead->magic, lead_magic, sizeof(lead_magic)))
- return 1;
+ return RPMRC_FAIL;
lead->type = ntohs(lead->type);
lead->archnum = ntohs(lead->archnum);
@@ -67,5 +67,5 @@ int readLead(FD_t fd, struct rpmlead *lead)
if (lead->major >= 2)
lead->signature_type = ntohs(lead->signature_type);
- return 0;
+ return RPMRC_OK;
}
diff --git a/lib/rpmlead.h b/lib/rpmlead.h
index 543d89d3b..48cb6f479 100644
--- a/lib/rpmlead.h
+++ b/lib/rpmlead.h
@@ -13,9 +13,9 @@ extern "C" {
* Write lead to file handle.
* @param fd file handle
* @param lead data address
- * @return 0 on success, 1 on error
+ * @return 0 on success
*/
-int writeLead(FD_t fd, const struct rpmlead *lead)
+rpmRC writeLead(FD_t fd, const struct rpmlead *lead)
/*@globals fileSystem @*/
/*@modifies fd, fileSystem @*/;
@@ -23,9 +23,9 @@ int writeLead(FD_t fd, const struct rpmlead *lead)
* Read lead from file handle.
* @param fd file handle
* @retval lead data address
- * @return 0 on success, 1 on error
+ * @return 0 on success
*/
-int readLead(FD_t fd, /*@out@*/ struct rpmlead *lead)
+rpmRC readLead(FD_t fd, /*@out@*/ struct rpmlead *lead)
/*@modifies fd, *lead @*/;
#ifdef __cplusplus
diff --git a/lib/rpmlib.h b/lib/rpmlib.h
index 11dd02f0f..431e82ca6 100644
--- a/lib/rpmlib.h
+++ b/lib/rpmlib.h
@@ -18,8 +18,8 @@ typedef enum rpmRC_e {
RPMRC_OK = 0, /*!< Generic success code */
RPMRC_NOTFOUND = 1, /*!< Generic not found code. */
RPMRC_FAIL = 2, /*!< Generic failure code. */
- RPMRC_BADSIZE = 3,
- RPMRC_SHORTREAD = 4
+ RPMRC_NOTTRUSTED = 3, /*!< Signature is OK, but key is not trusted. */
+ RPMRC_NOKEY = 4 /*!< Public key is unavailable. */
} rpmRC;
/*@-redecl@*/
@@ -1129,17 +1129,6 @@ enum rpmtagSignature {
RPMSIGTAG_RSA = RPMTAG_RSAHEADER /*!< internal RSA header signature. */
};
-/**
- * Return codes from verifySignature().
- */
-typedef enum rpmVerifySignatureReturn_e {
- RPMSIG_OK = 0, /*!< Signature is OK. */
- RPMSIG_UNKNOWN = 1, /*!< Signature is unknown. */
- RPMSIG_BAD = 2, /*!< Signature does not verify. */
- RPMSIG_NOKEY = 3, /*!< Key is unavailable. */
- RPMSIG_NOTTRUSTED = 4 /*!< Signature is OK, but key is not trusted. */
-} rpmVerifySignatureReturn;
-
/** \ingroup signature
* Verify a signature from a package.
*
@@ -1153,7 +1142,7 @@ typedef enum rpmVerifySignatureReturn_e {
* @retval result detailed text result of signature verification
* @return result of signature verification
*/
-rpmVerifySignatureReturn rpmVerifySignature(const rpmts ts,
+rpmRC rpmVerifySignature(const rpmts ts,
/*@out@*/ char * result)
/*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
/*@modifies ts, *result, rpmGlobalMacroContext,
diff --git a/lib/rpmts.c b/lib/rpmts.c
index 70d7d5489..8b5e7f13b 100644
--- a/lib/rpmts.c
+++ b/lib/rpmts.c
@@ -170,17 +170,17 @@ rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
return mi;
}
-rpmVerifySignatureReturn rpmtsFindPubkey(rpmts ts)
+rpmRC rpmtsFindPubkey(rpmts ts)
{
const void * sig = rpmtsSig(ts);
pgpDig dig = rpmtsDig(ts);
pgpDigParams sigp = rpmtsSignature(ts);
pgpDigParams pubp = rpmtsSignature(ts);
- rpmVerifySignatureReturn res;
+ rpmRC res;
int xx;
if (sig == NULL || dig == NULL || sigp == NULL || pubp == NULL) {
- res = RPMSIG_NOKEY; /* XXX RPMSIG_ARGS */
+ res = RPMRC_NOKEY;
goto exit;
}
@@ -216,7 +216,7 @@ rpmVerifySignatureReturn rpmtsFindPubkey(rpmts ts)
/* Was a matching pubkey found? */
if (ix < 0 || ts->pkpkt == NULL) {
- res = RPMSIG_NOKEY;
+ res = RPMRC_NOKEY;
goto exit;
}
@@ -233,7 +233,7 @@ rpmVerifySignatureReturn rpmtsFindPubkey(rpmts ts)
{
ts->pkpkt = _free(ts->pkpkt);
ts->pkpktlen = 0;
- res = RPMSIG_NOKEY;
+ res = RPMRC_NOKEY;
goto exit;
}
@@ -257,7 +257,7 @@ rpmVerifySignatureReturn rpmtsFindPubkey(rpmts ts)
const char * pkfn = rpmExpand("%{_gpg_pubkey}", NULL);
if (pgpReadPkts(pkfn, &ts->pkpkt, &ts->pkpktlen) != PGPARMOR_PUBKEY) {
pkfn = _free(pkfn);
- res = RPMSIG_NOKEY;
+ res = RPMRC_NOKEY;
goto exit;
}
pkfn = _free(pkfn);
@@ -274,9 +274,9 @@ rpmVerifySignatureReturn rpmtsFindPubkey(rpmts ts)
&& sigp->hash_algo == pubp->hash_algo
#endif
&& !memcmp(sigp->signid, pubp->signid, sizeof(sigp->signid)) )
- res = RPMSIG_OK;
+ res = RPMRC_OK;
else
- res = RPMSIG_NOKEY;
+ res = RPMRC_NOKEY;
/* XXX Verify the signature signature. */
@@ -449,17 +449,22 @@ int rpmtsSolve(rpmts ts, rpmds ds, /*@unused@*/ const void * data)
}
rpmrc = rpmReadPackageFile(ts, fd, str, &h);
xx = Fclose(fd);
- if (rpmrc == RPMRC_OK || rpmrc == RPMRC_BADSIZE) {
+ switch (rpmrc) {
+ default:
+ str = _free(str);
+ break;
+ case RPMRC_OK:
if (h != NULL &&
!rpmtsAddInstallElement(ts, h, (fnpyKey)str, 1, NULL))
{
rpmMessage(RPMMESS_DEBUG, _("Adding: %s\n"), str);
rc = -1;
/* XXX str memory leak */
- } else
- str = _free(str);
- } else
+ break;
+ }
str = _free(str);
+ break;
+ }
h = headerFree(h);
goto exit;
}
diff --git a/lib/rpmts.h b/lib/rpmts.h
index b6d2f7f48..080c65fe4 100644
--- a/lib/rpmts.h
+++ b/lib/rpmts.h
@@ -344,9 +344,9 @@ rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
/**
* Retrieve pubkey from rpm database.
* @param ts rpm transaction
- * @return RPMSIG_OK on success, RPMSIG_NOKEY if not found
+ * @return RPMRC_OK on success, RPMRC_NOKEY if not found
*/
-rpmVerifySignatureReturn rpmtsFindPubkey(rpmts ts)
+rpmRC rpmtsFindPubkey(rpmts ts)
/*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
/*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState */;
diff --git a/lib/signature.c b/lib/signature.c
index 88c07ad17..8d411e456 100644
--- a/lib/signature.c
+++ b/lib/signature.c
@@ -142,7 +142,7 @@ static inline rpmRC checkSize(FD_t fd, int siglen, int pad, int datalen)
rc = RPMRC_OK;
break;
default:
- rc = RPMRC_BADSIZE;
+ rc = RPMRC_OK; /* XXX repackaging destroys size checks */
break;
}
@@ -211,7 +211,7 @@ rpmRC rpmReadSignature(FD_t fd, Header * headerp, sigType sig_type)
/*@=boundsread@*/
}
if (pad && timedRead(fd, buf, pad) != pad)
- rc = RPMRC_SHORTREAD;
+ rc = RPMRC_FAIL;
break;
default:
break;
@@ -846,37 +846,36 @@ char * rpmGetPassPhrase(const char * prompt, const int sigTag)
return pass;
}
-static /*@observer@*/ const char * rpmSigString(rpmVerifySignatureReturn res)
+static /*@observer@*/ const char * rpmSigString(rpmRC res)
/*@*/
{
const char * str;
switch (res) {
- case RPMSIG_OK: str = "OK"; break;
- case RPMSIG_BAD: str = "BAD"; break;
- case RPMSIG_NOKEY: str = "NOKEY"; break;
- case RPMSIG_NOTTRUSTED: str = "NOTRUSTED"; break;
+ case RPMRC_OK: str = "OK"; break;
+ case RPMRC_FAIL: str = "BAD"; break;
+ case RPMRC_NOKEY: str = "NOKEY"; break;
+ case RPMRC_NOTTRUSTED: str = "NOTRUSTED"; break;
default:
- case RPMSIG_UNKNOWN: str = "UNKNOWN"; break;
+ case RPMRC_NOTFOUND: str = "UNKNOWN"; break;
}
return str;
}
/*@-boundswrite@*/
-static rpmVerifySignatureReturn
+static rpmRC
verifySizeSignature(const rpmts ts, /*@out@*/ char * t)
/*@modifies *t @*/
{
const void * sig = rpmtsSig(ts);
pgpDig dig = rpmtsDig(ts);
- rpmVerifySignatureReturn res;
+ rpmRC res;
int_32 size = 0x7fffffff;
*t = '\0';
t = stpcpy(t, _("Header+Payload size: "));
if (sig == NULL || dig == NULL || dig->nbytes == 0) {
- res = RPMSIG_NOKEY; /* XXX RPMSIG_ARGS */
- res = RPMSIG_NOKEY;
+ res = RPMRC_NOKEY;
t = stpcpy(t, rpmSigString(res));
goto exit;
}
@@ -884,11 +883,11 @@ verifySizeSignature(const rpmts ts, /*@out@*/ char * t)
memcpy(&size, sig, sizeof(size));
if (size != dig->nbytes) {
- res = RPMSIG_BAD;
+ res = RPMRC_FAIL;
t = stpcpy(t, rpmSigString(res));
sprintf(t, " Expected(%d) != (%d)\n", size, dig->nbytes);
} else {
- res = RPMSIG_OK;
+ res = RPMRC_OK;
t = stpcpy(t, rpmSigString(res));
sprintf(t, " (%d)", dig->nbytes);
}
@@ -900,7 +899,7 @@ exit:
/*@=boundswrite@*/
/*@-boundswrite@*/
-static rpmVerifySignatureReturn
+static rpmRC
verifyMD5Signature(const rpmts ts, /*@out@*/ char * t,
/*@null@*/ DIGEST_CTX md5ctx)
/*@modifies *t @*/
@@ -908,7 +907,7 @@ verifyMD5Signature(const rpmts ts, /*@out@*/ char * t,
const void * sig = rpmtsSig(ts);
int_32 siglen = rpmtsSiglen(ts);
pgpDig dig = rpmtsDig(ts);
- rpmVerifySignatureReturn res;
+ rpmRC res;
byte * md5sum = NULL;
size_t md5len = 0;
@@ -916,7 +915,7 @@ verifyMD5Signature(const rpmts ts, /*@out@*/ char * t,
t = stpcpy(t, _("MD5 digest: "));
if (md5ctx == NULL || sig == NULL || dig == NULL) {
- res = RPMSIG_NOKEY; /* XXX RPMSIG_ARGS */
+ res = RPMRC_NOKEY;
t = stpcpy(t, rpmSigString(res));
goto exit;
}
@@ -925,14 +924,14 @@ verifyMD5Signature(const rpmts ts, /*@out@*/ char * t,
(void **)&md5sum, &md5len, 0);
if (md5len != siglen || memcmp(md5sum, sig, md5len)) {
- res = RPMSIG_BAD;
+ res = RPMRC_FAIL;
t = stpcpy(t, rpmSigString(res));
t = stpcpy(t, " Expected(");
(void) pgpHexCvt(t, sig, siglen);
t += strlen(t);
t = stpcpy(t, ") != (");
} else {
- res = RPMSIG_OK;
+ res = RPMRC_OK;
t = stpcpy(t, rpmSigString(res));
t = stpcpy(t, " (");
}
@@ -953,9 +952,9 @@ exit:
* @param ts transaction set
* @retval t verbose success/failure text
* @param sha1ctx
- * @return RPMSIG_OK on success
+ * @return RPMRC_OK on success
*/
-static rpmVerifySignatureReturn
+static rpmRC
verifySHA1Signature(const rpmts ts, /*@out@*/ char * t,
/*@null@*/ DIGEST_CTX sha1ctx)
/*@modifies *t @*/
@@ -965,14 +964,14 @@ verifySHA1Signature(const rpmts ts, /*@out@*/ char * t,
int_32 siglen = rpmtsSiglen(ts);
#endif
pgpDig dig = rpmtsDig(ts);
- rpmVerifySignatureReturn res;
+ rpmRC res;
const char * SHA1 = NULL;
*t = '\0';
t = stpcpy(t, _("Header SHA1 digest: "));
if (sha1ctx == NULL || sig == NULL || dig == NULL) {
- res = RPMSIG_NOKEY; /* XXX RPMSIG_ARGS */
+ res = RPMRC_NOKEY;
t = stpcpy(t, rpmSigString(res));
goto exit;
}
@@ -981,13 +980,13 @@ verifySHA1Signature(const rpmts ts, /*@out@*/ char * t,
(void **)&SHA1, NULL, 1);
if (SHA1 == NULL || strlen(SHA1) != strlen(sig) || strcmp(SHA1, sig)) {
- res = RPMSIG_BAD;
+ res = RPMRC_FAIL;
t = stpcpy(t, rpmSigString(res));
t = stpcpy(t, " Expected(");
t = stpcpy(t, sig);
t = stpcpy(t, ") != (");
} else {
- res = RPMSIG_OK;
+ res = RPMRC_OK;
t = stpcpy(t, rpmSigString(res));
t = stpcpy(t, " (");
}
@@ -1025,9 +1024,9 @@ static inline unsigned char nibble(char c)
* @param ts transaction set
* @retval t verbose success/failure text
* @param md5ctx
- * @return RPMSIG_OK on success
+ * @return RPMRC_OK on success
*/
-static rpmVerifySignatureReturn
+static rpmRC
verifyPGPSignature(rpmts ts, /*@out@*/ char * t,
/*@null@*/ DIGEST_CTX md5ctx)
/*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
@@ -1040,14 +1039,14 @@ verifyPGPSignature(rpmts ts, /*@out@*/ char * t,
int_32 sigtag = rpmtsSigtag(ts);
pgpDig dig = rpmtsDig(ts);
pgpDigParams sigp = rpmtsSignature(ts);
- rpmVerifySignatureReturn res;
+ rpmRC res;
int xx;
*t = '\0';
t = stpcpy(t, _("V3 RSA/MD5 signature: "));
if (md5ctx == NULL || sig == NULL || dig == NULL || sigp == NULL) {
- res = RPMSIG_NOKEY; /* XXX RPMSIG_ARGS */
+ res = RPMRC_NOKEY;
goto exit;
}
@@ -1056,7 +1055,7 @@ verifyPGPSignature(rpmts ts, /*@out@*/ char * t,
&& sigp->pubkey_algo == PGPPUBKEYALGO_RSA
&& sigp->hash_algo == PGPHASHALGO_MD5))
{
- res = RPMSIG_NOKEY;
+ res = RPMRC_NOKEY;
goto exit;
}
@@ -1086,7 +1085,7 @@ verifyPGPSignature(rpmts ts, /*@out@*/ char * t,
signhash16[0] = (nibble(s[0]) << 4) | nibble(s[1]);
signhash16[1] = (nibble(s[2]) << 4) | nibble(s[3]);
if (memcmp(signhash16, sigp->signhash16, sizeof(signhash16))) {
- res = RPMSIG_BAD;
+ res = RPMRC_FAIL;
goto exit;
}
@@ -1115,13 +1114,13 @@ verifyPGPSignature(rpmts ts, /*@out@*/ char * t,
/* Retrieve the matching public key. */
res = rpmtsFindPubkey(ts);
- if (res != RPMSIG_OK)
+ if (res != RPMRC_OK)
goto exit;
if (rsavrfy(&dig->rsa_pk, &dig->rsahm, &dig->c))
- res = RPMSIG_OK;
+ res = RPMRC_OK;
else
- res = RPMSIG_BAD;
+ res = RPMRC_FAIL;
exit:
t = stpcpy(t, rpmSigString(res));
@@ -1140,10 +1139,10 @@ exit:
* @param ts transaction set
* @retval t verbose success/failure text
* @param sha1ctx
- * @return RPMSIG_OK on success
+ * @return RPMRC_OK on success
*/
/*@-boundswrite@*/
-static rpmVerifySignatureReturn
+static rpmRC
verifyGPGSignature(rpmts ts, /*@out@*/ char * t,
/*@null@*/ DIGEST_CTX sha1ctx)
/*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
@@ -1156,7 +1155,7 @@ verifyGPGSignature(rpmts ts, /*@out@*/ char * t,
int_32 sigtag = rpmtsSigtag(ts);
pgpDig dig = rpmtsDig(ts);
pgpDigParams sigp = rpmtsSignature(ts);
- rpmVerifySignatureReturn res;
+ rpmRC res;
int xx;
*t = '\0';
@@ -1165,7 +1164,7 @@ verifyGPGSignature(rpmts ts, /*@out@*/ char * t,
t = stpcpy(t, _("V3 DSA signature: "));
if (sha1ctx == NULL || sig == NULL || dig == NULL || sigp == NULL) {
- res = RPMSIG_NOKEY; /* XXX RPMSIG_ARGS */
+ res = RPMRC_NOKEY;
goto exit;
}
@@ -1174,7 +1173,7 @@ verifyGPGSignature(rpmts ts, /*@out@*/ char * t,
&& sigp->pubkey_algo == PGPPUBKEYALGO_DSA
&& sigp->hash_algo == PGPHASHALGO_SHA1))
{
- res = RPMSIG_NOKEY;
+ res = RPMRC_NOKEY;
goto exit;
}
@@ -1203,21 +1202,21 @@ verifyGPGSignature(rpmts ts, /*@out@*/ char * t,
signhash16[0] = (*dig->hm.data >> 24) & 0xff;
signhash16[1] = (*dig->hm.data >> 16) & 0xff;
if (memcmp(signhash16, sigp->signhash16, sizeof(signhash16))) {
- res = RPMSIG_BAD;
+ res = RPMRC_FAIL;
goto exit;
}
}
/* Retrieve the matching public key. */
res = rpmtsFindPubkey(ts);
- if (res != RPMSIG_OK)
+ if (res != RPMRC_OK)
goto exit;
if (dsavrfy(&dig->p, &dig->q, &dig->g,
&dig->hm, &dig->y, &dig->r, &dig->s))
- res = RPMSIG_OK;
+ res = RPMRC_OK;
else
- res = RPMSIG_BAD;
+ res = RPMRC_FAIL;
exit:
t = stpcpy(t, rpmSigString(res));
@@ -1231,18 +1230,18 @@ exit:
}
/*@=boundswrite@*/
-rpmVerifySignatureReturn
+rpmRC
rpmVerifySignature(const rpmts ts, char * result)
{
const void * sig = rpmtsSig(ts);
int_32 siglen = rpmtsSiglen(ts);
int_32 sigtag = rpmtsSigtag(ts);
pgpDig dig = rpmtsDig(ts);
- rpmVerifySignatureReturn res;
+ rpmRC res;
if (sig == NULL || siglen <= 0 || dig == NULL) {
sprintf(result, _("Verify signature: BAD PARAMETERS\n"));
- return RPMSIG_UNKNOWN;
+ return RPMRC_NOTFOUND;
}
switch (sigtag) {
@@ -1269,11 +1268,11 @@ rpmVerifySignature(const rpmts ts, char * result)
case RPMSIGTAG_LEMD5_1:
case RPMSIGTAG_LEMD5_2:
sprintf(result, _("Broken MD5 digest: UNSUPPORTED\n"));
- res = RPMSIG_UNKNOWN;
+ res = RPMRC_NOTFOUND;
break;
default:
sprintf(result, _("Signature: UNKNOWN (%d)\n"), sigtag);
- res = RPMSIG_UNKNOWN;
+ res = RPMRC_NOTFOUND;
break;
}
return res;
diff --git a/lib/transaction.c b/lib/transaction.c
index 47ef3466a..56d395d44 100644
--- a/lib/transaction.c
+++ b/lib/transaction.c
@@ -1422,7 +1422,8 @@ rpmMessage(RPMMESS_DEBUG, _("computing file dispositions\n"));
rpmteNEVR(p), &p->h);
vsflags = rpmtsSetVSFlags(ts, ovsflags);
- if (!(rpmrc == RPMRC_OK || rpmrc == RPMRC_BADSIZE)) {
+ switch (rpmrc) {
+ default:
/*@-noeffectuncon@*/ /* FIX: notify annotations */
p->fd = ts->notify(p->h, RPMCALLBACK_INST_CLOSE_FILE,
0, 0,
@@ -1430,6 +1431,9 @@ rpmMessage(RPMMESS_DEBUG, _("computing file dispositions\n"));
/*@=noeffectuncon@*/
p->fd = NULL;
ourrc++;
+ /*@innerbreak@*/ break;
+ case RPMRC_OK:
+ /*@innerbreak@*/ break;
}
if (rpmteFd(p) != NULL) gotfd = 1;
}
diff --git a/python/rpmts-py.c b/python/rpmts-py.c
index 3d78f5d55..3e2a0f6db 100644
--- a/python/rpmts-py.c
+++ b/python/rpmts-py.c
@@ -721,7 +721,7 @@ rpmts_HdrFromFdno(rpmtsObject * s, PyObject * args)
/*@globals _Py_NoneStruct, fileSystem @*/
/*@modifies s, _Py_NoneStruct, fileSystem @*/
{
- hdrObject * hdr;
+ PyObject * result = NULL;
Header h;
FD_t fd;
int fdno;
@@ -737,25 +737,32 @@ fprintf(stderr, "*** rpmts_HdrFromFdno(%p) ts %p\n", s, s->ts);
Fclose(fd);
switch (rpmrc) {
- case RPMRC_BADSIZE:
case RPMRC_OK:
- hdr = hdr_Wrap(h);
- h = headerFree(h); /* XXX ref held by hdr */
+ if (h)
+ result = Py_BuildValue("N", hdr_Wrap(h));
+ h = headerFree(h); /* XXX ref held by result */
break;
case RPMRC_NOTFOUND:
Py_INCREF(Py_None);
- hdr = (hdrObject *) Py_None;
+ result = Py_None;
+ break;
+
+ case RPMRC_NOKEY:
+ PyErr_SetString(pyrpmError, "public key not availaiable");
+ break;
+
+ case RPMRC_NOTTRUSTED:
+ PyErr_SetString(pyrpmError, "public key not trusted");
break;
case RPMRC_FAIL:
- case RPMRC_SHORTREAD:
default:
PyErr_SetString(pyrpmError, "error reading package header");
- return NULL;
+ break;
}
- return Py_BuildValue("N", hdr);
+ return result;
}
/** \ingroup python
@@ -794,8 +801,17 @@ fprintf(stderr, "*** rpmts_HdrCheck(%p) ts %p\n", s, s->ts);
Py_INCREF(Py_None);
result = Py_None;
break;
- default:
+
+ case RPMRC_NOKEY:
+ PyErr_SetString(pyrpmError, "public key not availaiable");
+ break;
+
+ case RPMRC_NOTTRUSTED:
+ PyErr_SetString(pyrpmError, "public key not trusted");
+ break;
+
case RPMRC_FAIL:
+ default:
PyErr_SetString(pyrpmError, msg);
break;
}
diff --git a/rpm.spec.in b/rpm.spec.in
index 012eea67b..ad685febe 100644
--- a/rpm.spec.in
+++ b/rpm.spec.in
@@ -17,7 +17,7 @@ Name: rpm
%define version @VERSION@
Version: %{version}
%{expand: %%define rpm_version %{version}}
-Release: 0.87
+Release: 0.88
Group: System Environment/Base
Source: ftp://ftp.rpm.org/pub/rpm/dist/rpm-4.0.x/rpm-%{rpm_version}.tar.gz
Copyright: GPL
@@ -522,6 +522,10 @@ fi
%{__prefix}/include/popt.h
%changelog
+* Fri Aug 22 2002 Jeff Johnson <jbj@redhat.com> 4.1-0.88
+- merge signature returns into rpmRC.
+- python: exceptions on NOKEY/NOTTRUSTED.
+
* Thu Aug 21 2002 Jeff Johnson <jbj@redhat.com> 4.1-0.87
- fix: don't stop if db1 database is currently in /var/lib/rpm (#72224).
- add a macro to create a sub-package with debugging symbols.
diff --git a/rpm2cpio.c b/rpm2cpio.c
index a57e53cc8..7397e8373 100644
--- a/rpm2cpio.c
+++ b/rpm2cpio.c
@@ -47,15 +47,15 @@ int main(int argc, char **argv)
}
switch (rc) {
- case RPMRC_BADSIZE:
case RPMRC_OK:
+ case RPMRC_NOKEY:
+ case RPMRC_NOTTRUSTED:
break;
case RPMRC_NOTFOUND:
fprintf(stderr, _("argument is not an RPM package\n"));
exit(EXIT_FAILURE);
break;
case RPMRC_FAIL:
- case RPMRC_SHORTREAD:
default:
fprintf(stderr, _("error reading header from package\n"));
exit(EXIT_FAILURE);
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 5c8075c67..595fc3221 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -14,7 +14,7 @@ INCLUDES = -I. \
@INCPATH@ \
-I$(top_srcdir)/misc
-EXTRA_DIST = rpminject.c rpmsort.c
+EXTRA_DIST = rpminject.c rpmsort.c sections.h utils.h
EXTRA_PROGRAMS = rpminject rpmsort
diff --git a/tools/rpmgraph.c b/tools/rpmgraph.c
index 7b15e4e65..d9ca2f40b 100644
--- a/tools/rpmgraph.c
+++ b/tools/rpmgraph.c
@@ -141,23 +141,23 @@ restart:
Fclose(fd);
fd = NULL;
- if (rpmrc == RPMRC_FAIL || rpmrc == RPMRC_SHORTREAD) {
- numFailed++; *fnp = NULL;
- continue;
- }
-
- if (rpmrc == RPMRC_OK || rpmrc == RPMRC_BADSIZE) {
- rc = rpmtsAddInstallElement(ts, h, (fnpyKey)fileName, 0, NULL);
- h = headerFree(h);
- continue;
- }
-
- if (rpmrc != RPMRC_NOTFOUND) {
+ switch (rpmrc) {
+ case RPMRC_FAIL:
+ default:
rpmMessage(RPMMESS_ERROR, _("%s cannot be installed\n"), *fnp);
numFailed++; *fnp = NULL;
- break;
+ /*@switchbreak@*/ break;
+ case RPMRC_OK:
+ rc = rpmtsAddInstallElement(ts, h, (fnpyKey)fileName, 0, NULL);
+ /*@switchbreak@*/ break;
+ case RPMRC_NOTFOUND:
+ goto maybe_manifest;
+ /*@notreached@*/ /*@switchbreak@*/ break;
}
+ h = headerFree(h);
+ continue;
+maybe_manifest:
/* Try to read a package manifest. */
fd = Fopen(*fnp, "r.fpio");
if (fd == NULL || Ferror(fd)) {