Skip to content

Commit

Permalink
Use RPMTAG_RPMFORMAT for rpm format detection in the signing code
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pmatilai authored and ffesti committed Nov 28, 2024
1 parent ea46f4f commit ef5b538
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions sign/rpmgensig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,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;
Expand Down Expand Up @@ -666,7 +667,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;
}
Expand All @@ -677,8 +680,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 */
Expand All @@ -689,6 +691,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);
Expand Down

0 comments on commit ef5b538

Please sign in to comment.