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 committed Nov 21, 2024
1 parent e7b6651 commit 11d3a0e
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 @@ -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;
Expand Down Expand Up @@ -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;
}
Expand All @@ -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 */
Expand All @@ -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);
Expand Down

0 comments on commit 11d3a0e

Please sign in to comment.