diff --git a/sign/rpmgensig.cc b/sign/rpmgensig.cc index 85a515e3bd..827bf9d98d 100644 --- a/sign/rpmgensig.cc +++ b/sign/rpmgensig.cc @@ -702,14 +702,19 @@ static int rpmSign(const char *rpm, int deleting, int flags) unloadImmutableRegion(&sigh, RPMTAG_HEADERSIGNATURES); origSigSize = headerSizeof(sigh, HEADER_MAGIC_YES); - if (flags & RPMSIGN_FLAG_IMA) { - if (includeFileSignatures(&sigh, &h)) - goto exit; - } - - if (flags & RPMSIGN_FLAG_FSVERITY) { - if (includeVeritySignatures(fd, &sigh, &h)) - goto exit; + if (!headerIsSource(h)) { + if (flags & RPMSIGN_FLAG_IMA) { + if (includeFileSignatures(&sigh, &h)) + goto exit; + } + if (flags & RPMSIGN_FLAG_FSVERITY) { + if (includeVeritySignatures(fd, &sigh, &h)) + goto exit; + } + } else if (flags & (RPMSIGN_FLAG_IMA | RPMSIGN_FLAG_FSVERITY)) { + rpmlog(RPMLOG_WARNING, + _("File signatures not applicable to source packages: %s\n"), + rpm); } if (deleting == 2) { /* Nuke IMA + fsverity file signature tags. */ diff --git a/tests/rpmsigdig.at b/tests/rpmsigdig.at index 4ef1e8165a..cb8c7a1a6a 100644 --- a/tests/rpmsigdig.at +++ b/tests/rpmsigdig.at @@ -1844,4 +1844,13 @@ rpm -qp --qf "[%{filenames}:%{filesignatures}\n]" /data/RPMS/imatest-1.0-1.fc34. ], [ignore]) +RPMTEST_CHECK([ +cp /data/SRPMS/hello-1.0-1.src.rpm /tmp/ +rpmsign --key-id 4344591E1964C5FC --addsign --signfiles --fskpath=/data/keys/privkey.pem /tmp/hello-1.0-1.src.rpm +], +[0], +[], +[warning: File signatures not applicable to source packages: /tmp/hello-1.0-1.src.rpm +]) + RPMTEST_CLEANUP