Skip to content

Commit

Permalink
Fix "substatus" (eg NOKEY) regression on package read (#330)
Browse files Browse the repository at this point in the history
Commit 3ccd9cc introduced a regression
in the cases where package is successfully read (ie a header is returned)
but "there is a but", such as a missing pubkey. We need to return the
substatus instead of just "yes yes" in that case.

Keep track of the substatus in through the callback and return it
in case everything else was okay to restore former behavior.
  • Loading branch information
pmatilai committed Oct 11, 2017
1 parent 2f99ec7 commit e6c88ea
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/package.c
Expand Up @@ -266,6 +266,7 @@ void applyRetrofits(Header h, int leadtype)

struct pkgdata_s {
const char *fn;
rpmRC rc;
};

static rpmRC handlePkgVS(struct rpmsinfo_s *sinfo, rpmRC rc, const char *msg, void *cbdata)
Expand Down Expand Up @@ -293,7 +294,11 @@ static rpmRC handlePkgVS(struct rpmsinfo_s *sinfo, rpmRC rc, const char *msg, vo

rpmlog(lvl, "%s: %s\n", pkgdata->fn, vsmsg);

/* Preserve traditional behavior for now: only failure prevents install */
/* Remember actual return code, but don't override a previous failure */
if (rc && pkgdata->rc != RPMRC_FAIL)
pkgdata->rc = rc;

/* Preserve traditional behavior for now: only failure prevents read */
if (rc != RPMRC_FAIL)
rc = RPMRC_OK;

Expand All @@ -307,6 +312,7 @@ rpmRC rpmReadPackageFile(rpmts ts, FD_t fd, const char * fn, Header * hdrp)
rpmKeyring keyring = rpmtsGetKeyring(ts, 1);
struct pkgdata_s pkgdata = {
.fn = fn ? fn : Fdescr(fd),
.rc = RPMRC_OK,
};

/* XXX: lots of 3rd party software relies on the behavior */
Expand All @@ -315,6 +321,10 @@ rpmRC rpmReadPackageFile(rpmts ts, FD_t fd, const char * fn, Header * hdrp)

rpmRC rc = rpmpkgRead(keyring, vsflags, fd, handlePkgVS, &pkgdata, hdrp);

/* If there was a "substatus" (NOKEY in practise), return that instead */
if (rc == RPMRC_OK && pkgdata.rc)
rc = pkgdata.rc;

rpmKeyringFree(keyring);

return rc;
Expand Down

0 comments on commit e6c88ea

Please sign in to comment.