diff --git a/sign/rpmgensig.cc b/sign/rpmgensig.cc index 85a515e3bd..92036676b9 100644 --- a/sign/rpmgensig.cc +++ b/sign/rpmgensig.cc @@ -641,7 +641,8 @@ static int rpmSign(const char *rpm, int deleting, int flags) struct sigTarget_s sigt_v4; unsigned int origSigSize; int insSig = 0; - rpmTagVal reserveTag = RPMSIGTAG_RESERVEDSPACE; + int rpmformat = 0; + rpmTagVal reserveTag = 0; if (manageFile(&fd, rpm, O_RDWR)) goto exit; @@ -671,7 +672,9 @@ static int rpmSign(const char *rpm, int deleting, int flags) goto exit; } - if (!headerIsEntry(h, RPMTAG_HEADERIMMUTABLE)) { + rpmformat = headerGetNumber(h, RPMTAG_RPMFORMAT); + + if (rpmformat < 4) { rpmlog(RPMLOG_ERR, _("Cannot sign RPM v3 packages: %s\n"), rpm); goto exit; } @@ -682,8 +685,7 @@ static int rpmSign(const char *rpm, int deleting, int flags) flags |= RPMSIGN_FLAG_RPMV3; } - /* Only v6 packages have this */ - if (headerIsEntry(sigh, RPMSIGTAG_RESERVED)) { + if (rpmformat >= 6) { flags |= RPMSIGN_FLAG_RPMV6; reserveTag = RPMSIGTAG_RESERVED; /* v3 signatures are not welcome in v6 packages */ @@ -694,6 +696,7 @@ static int rpmSign(const char *rpm, int deleting, int flags) } } else { flags |= RPMSIGN_FLAG_RPMV4; + reserveTag = RPMSIGTAG_RESERVEDSPACE; /* Ensure only one legacy signature is added if adding v6 signatures */ if ((flags & RPMSIGN_FLAG_RPMV6) && haveLegacySig(sigh)) flags &= ~(RPMSIGN_FLAG_RPMV4|RPMSIGN_FLAG_RPMV3);