File imaevmsignplugin.diff of Package python-rpm

--- sign/Makefile.am.orig	2024-02-23 13:06:39.243661362 +0000
+++ sign/Makefile.am	2024-02-23 13:18:59.418503999 +0000
@@ -21,6 +21,10 @@ librpmsign_la_LIBADD = \
 	@LIBINTL@
 
 if WITH_IMAEVM
-librpmsign_la_SOURCES += rpmsignfiles.c rpmsignfiles.h
-librpmsign_la_LIBADD += @WITH_IMAEVM_LIB@
+imaevmsigndir = $(libdir)/rpm-plugins
+imaevmsign_LTLIBRARIES = imaevmsign.la
+imaevmsign_la_SOURCES = rpmsignfiles.c rpmsignfiles.h
+imaevmsign_la_LDFLAGS = -avoid-version -module -shared
+imaevmsign_la_LIBADD = $(top_builddir)/lib/librpm.la $(top_builddir)/rpmio/librpmio.la @WITH_IMAEVM_LIB@
 endif
+
--- sign/rpmgensig.c.orig	2024-02-23 12:38:24.854533195 +0000
+++ sign/rpmgensig.c	2024-02-23 13:26:21.461857566 +0000
@@ -520,6 +520,38 @@ exit:
 }
 #endif
 
+#ifdef WITH_IMAEVM
+static rpmRC CallRpmSignFiles(Header h, char *key, char *keypass)
+{
+    rpmRC rc = RPMRC_FAIL;
+    void *handle = NULL;
+    void *func;
+    char *error;
+    char *path = rpmExpand("%{?__sign_imaevm}", NULL);
+    if (!path || !*path) {
+	rpmlog(RPMLOG_ERR, _("imaevm sign plugin is not configured\n"));
+	goto exit;
+    }
+    handle = dlopen(path, RTLD_LAZY);
+    if (!handle) {
+	rpmlog(RPMLOG_ERR, _("Failed to dlopen %s %s\n"), path, dlerror());
+	goto exit;
+    }
+    func = dlsym(handle, "rpmSignFiles");
+    if ((error = dlerror()) != NULL) {
+        rpmlog(RPMLOG_ERR, _("Failed to resolve symbol %s: %s\n"),
+               "rpmSignFiles", error);
+        goto exit;
+    }
+    rc = ((rpmRC (*)(Header, char *, char *))func)(h, key, keypass);
+exit:
+    if (handle)
+	dlclose(handle);
+    _free(path);
+    return rc;
+}
+#endif
+
 static rpmRC includeFileSignatures(FD_t fd, const char *rpm,
 				   Header *sigp, Header *hdrp,
 				   off_t sigStart, off_t headerStart)
@@ -547,7 +579,7 @@ static rpmRC includeFileSignatures(FD_t
 	keypass = NULL;
     }
 
-    rc = rpmSignFiles(*hdrp, key, keypass);
+    rc = CallRpmSignFiles(*hdrp, key, keypass);
     if (rc != RPMRC_OK) {
 	goto exit;
     }
--- sign/rpmsignfiles.h.orig	2024-02-23 13:39:41.632618434 +0000
+++ sign/rpmsignfiles.h	2024-02-23 13:40:22.280555243 +0000
@@ -15,7 +15,6 @@ extern "C" {
  * @param keypass	signing key password
  * @return		RPMRC_OK on success
  */
-RPM_GNUC_INTERNAL
 rpmRC rpmSignFiles(Header h, const char *key, char *keypass);
 
 #ifdef _cplusplus
openSUSE Build Service is sponsored by