Skip to content

Commit ef5b538

Browse files
pmatilaiffesti
authored andcommitted
Use RPMTAG_RPMFORMAT for rpm format detection in the signing code
We now have a nice way to centrally get the format number, use it in the signing code instead of the various ad-hoc methods added during multi-signature development, and use 'rpmformat' as the variable name for easy grepping. No functional changes.
1 parent ea46f4f commit ef5b538

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

sign/rpmgensig.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,8 @@ static int rpmSign(const char *rpm, int deleting, int flags)
636636
struct sigTarget_s sigt_v4;
637637
unsigned int origSigSize;
638638
int insSig = 0;
639-
rpmTagVal reserveTag = RPMSIGTAG_RESERVEDSPACE;
639+
int rpmformat = 0;
640+
rpmTagVal reserveTag = 0;
640641

641642
if (manageFile(&fd, rpm, O_RDWR))
642643
goto exit;
@@ -666,7 +667,9 @@ static int rpmSign(const char *rpm, int deleting, int flags)
666667
goto exit;
667668
}
668669

669-
if (!headerIsEntry(h, RPMTAG_HEADERIMMUTABLE)) {
670+
rpmformat = headerGetNumber(h, RPMTAG_RPMFORMAT);
671+
672+
if (rpmformat < 4) {
670673
rpmlog(RPMLOG_ERR, _("Cannot sign RPM v3 packages: %s\n"), rpm);
671674
goto exit;
672675
}
@@ -677,8 +680,7 @@ static int rpmSign(const char *rpm, int deleting, int flags)
677680
flags |= RPMSIGN_FLAG_RPMV3;
678681
}
679682

680-
/* Only v6 packages have this */
681-
if (headerIsEntry(sigh, RPMSIGTAG_RESERVED)) {
683+
if (rpmformat >= 6) {
682684
flags |= RPMSIGN_FLAG_RPMV6;
683685
reserveTag = RPMSIGTAG_RESERVED;
684686
/* v3 signatures are not welcome in v6 packages */
@@ -689,6 +691,7 @@ static int rpmSign(const char *rpm, int deleting, int flags)
689691
}
690692
} else {
691693
flags |= RPMSIGN_FLAG_RPMV4;
694+
reserveTag = RPMSIGTAG_RESERVEDSPACE;
692695
/* Ensure only one legacy signature is added if adding v6 signatures */
693696
if ((flags & RPMSIGN_FLAG_RPMV6) && haveLegacySig(sigh))
694697
flags &= ~(RPMSIGN_FLAG_RPMV4|RPMSIGN_FLAG_RPMV3);

0 commit comments

Comments
 (0)