commit:     c2ee7e88d7894a238c8812a9154dce2868d37eb9
Author:     Gabi Falk <gabifalk <AT> gmx <DOT> com>
AuthorDate: Tue Jun  3 12:00:00 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Jun  3 13:49:10 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c2ee7e88

mail-filter/opendkim: enable lua5-3, lua5-4

Link: 
https://cgit.freebsd.org/ports/commit/?id=739be5c250f886c386b3dd5cd5dda5759ca895a8
Link: 
https://cgit.freebsd.org/ports/commit/?id=0426c84984ad7fbbd2b9773b9783af8b65851d69
Link: 
https://cgit.freebsd.org/ports/commit/?id=fb4ba36cba6f14d96323cee7f2e16b56a9ed205c
Signed-off-by: Gabi Falk <gabifalk <AT> gmx.com>
Part-of: https://github.com/gentoo/gentoo/pull/42421
Closes: https://github.com/gentoo/gentoo/pull/42421
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../files/opendkim-2.10.3-lua52-lua53-lua54.patch  | 511 +++++++++++++++++++++
 mail-filter/opendkim/opendkim-2.10.3-r33.ebuild    | 255 ++++++++++
 2 files changed, 766 insertions(+)

diff --git a/mail-filter/opendkim/files/opendkim-2.10.3-lua52-lua53-lua54.patch 
b/mail-filter/opendkim/files/opendkim-2.10.3-lua52-lua53-lua54.patch
new file mode 100644
index 000000000000..e06335b801d6
--- /dev/null
+++ b/mail-filter/opendkim/files/opendkim-2.10.3-lua52-lua53-lua54.patch
@@ -0,0 +1,511 @@
+From c9581349d5d98c546517d4be70ea56786dd371f8 Mon Sep 17 00:00:00 2001
+From: Steve Wills <[email protected]>
+Date: Mon, 31 Dec 2018 20:51:16 +0000
+Subject: [PATCH 1/3] mail/opendkim: fix build with lua52 and lua53
+
+Link: 
https://cgit.freebsd.org/ports/commit/?id=739be5c250f886c386b3dd5cd5dda5759ca895a8
+---
+ miltertest/miltertest.c |  4 ++--
+ opendkim/opendkim-lua.c | 40 ++++++++++++++++++++++++++++++----------
+ 2 files changed, 32 insertions(+), 12 deletions(-)
+
+diff --git a/miltertest/miltertest.c b/miltertest/miltertest.c
+index 04e50c04..84278b82 100644
+--- a/miltertest/miltertest.c
++++ b/miltertest/miltertest.c
+@@ -4009,7 +4009,7 @@ main(int argc, char **argv)
+       }
+ 
+       /* register functions */
+-#if LUA_VERSION_NUM == 502
++#if (LUA_VERSION_NUM == 502 || LUA_VERSION_NUM == 503)
+         luaL_newlib(l, mt_library);
+       lua_setglobal(l, "mt");
+ #else /* LUA_VERSION_NUM == 502 */
+@@ -4163,7 +4163,7 @@ main(int argc, char **argv)
+       lua_setglobal(l, "SMFIF_SETSYMLIST");
+ #endif /* SMFIF_SETSYMLIST */
+ 
+-#if LUA_VERSION_NUM == 502
++#if (LUA_VERSION_NUM == 502 || LUA_VERSION_NUM == 503)
+       switch (lua_load(l, mt_lua_reader, (void *) &io,
+                        script == NULL ? "(stdin)" : script, NULL))
+ #else /* LUA_VERSION_NUM == 502 */
+diff --git a/opendkim/opendkim-lua.c b/opendkim/opendkim-lua.c
+index 71dd24ab..702e8980 100644
+--- a/opendkim/opendkim-lua.c
++++ b/opendkim/opendkim-lua.c
+@@ -282,7 +282,7 @@ dkimf_lua_alloc(void *ud, void *ptr, size_t osize, size_t 
nsize)
+               free(ptr);
+               return NULL;
+       }
+-# if LUA_VERSION_NUM == 502
++# if (LUA_VERSION_NUM == 502 || LUA_VERSION_NUM == 503)
+       else if (nsize != 0 && ptr == NULL)
+ # else /* LUA_VERSION_NUM == 502 */
+       else if (nsize != 0 && osize == 0)
+@@ -482,7 +482,7 @@ dkimf_lua_setup_hook(void *ctx, const char *script, size_t 
scriptlen,
+       **  Register functions.
+       */
+ 
+-# if LUA_VERSION_NUM == 502
++# if (LUA_VERSION_NUM == 502 || LUA_VERSION_NUM == 503)
+       luaL_newlib(l, dkimf_lua_lib_setup);
+       lua_setglobal(l, "odkim");
+ # else /* LUA_VERSION_NUM == 502 */
+@@ -529,7 +529,7 @@ dkimf_lua_setup_hook(void *ctx, const char *script, size_t 
scriptlen,
+       /* import other globals */
+       dkimf_import_globals(ctx, l);
+ 
+-# if LUA_VERSION_NUM == 502
++# if (LUA_VERSION_NUM == 502 || LUA_VERSION_NUM == 503)
+       switch (lua_load(l, dkimf_lua_reader, (void *) &io, name, NULL))
+ # else /* LUA_VERSION_NUM == 502 */
+       switch (lua_load(l, dkimf_lua_reader, (void *) &io, name))
+@@ -561,7 +561,11 @@ dkimf_lua_setup_hook(void *ctx, const char *script, 
size_t scriptlen,
+               io.lua_io_len = 0;
+               io.lua_io_alloc = 0;
+ 
++#if (LUA_VERSION_NUM == 503)
++              if (lua_dump(l, dkimf_lua_writer, &io, 0) == 0)
++#else
+               if (lua_dump(l, dkimf_lua_writer, &io) == 0)
++#endif
+               {
+                       *keep = (void *) io.lua_io_script;
+                       *funclen = io.lua_io_len;
+@@ -637,7 +641,7 @@ dkimf_lua_screen_hook(void *ctx, const char *script, 
size_t scriptlen,
+       **  Register functions.
+       */
+ 
+-# if LUA_VERSION_NUM == 502
++# if (LUA_VERSION_NUM == 502 || LUA_VERSION_NUM == 503)
+       luaL_newlib(l, dkimf_lua_lib_screen);
+       lua_setglobal(l, "odkim");
+ # else /* LUA_VERSION_NUM == 502 */
+@@ -674,7 +678,7 @@ dkimf_lua_screen_hook(void *ctx, const char *script, 
size_t scriptlen,
+       /* import other globals */
+       dkimf_import_globals(ctx, l);
+ 
+-# if LUA_VERSION_NUM == 502
++# if (LUA_VERSION_NUM == 502 || LUA_VERSION_NUM == 503)
+       switch (lua_load(l, dkimf_lua_reader, (void *) &io, name, NULL))
+ # else /* LUA_VERSION_NUM == 502 */
+       switch (lua_load(l, dkimf_lua_reader, (void *) &io, name))
+@@ -706,7 +710,11 @@ dkimf_lua_screen_hook(void *ctx, const char *script, 
size_t scriptlen,
+               io.lua_io_len = 0;
+               io.lua_io_alloc = 0;
+ 
++#if (LUA_VERSION_NUM == 503)
++              if (lua_dump(l, dkimf_lua_writer, &io, 0) == 0)
++#else
+               if (lua_dump(l, dkimf_lua_writer, &io) == 0)
++#endif
+               {
+                       *keep = (void *) io.lua_io_script;
+                       *funclen = io.lua_io_len;
+@@ -782,7 +790,7 @@ dkimf_lua_stats_hook(void *ctx, const char *script, size_t 
scriptlen,
+       **  Register functions.
+       */
+ 
+-# if LUA_VERSION_NUM == 502
++# if (LUA_VERSION_NUM == 502 || LUA_VERSION_NUM == 503)
+       luaL_newlib(l, dkimf_lua_lib_stats);
+       lua_setglobal(l, "odkim");
+ # else /* LUA_VERSION_NUM == 502 */
+@@ -911,7 +919,7 @@ dkimf_lua_stats_hook(void *ctx, const char *script, size_t 
scriptlen,
+       /* import other globals */
+       dkimf_import_globals(ctx, l);
+ 
+-# if LUA_VERSION_NUM == 502
++# if (LUA_VERSION_NUM == 502 || LUA_VERSION_NUM == 503)
+       switch (lua_load(l, dkimf_lua_reader, (void *) &io, name, NULL))
+ # else /* LUA_VERSION_NUM == 502 */
+       switch (lua_load(l, dkimf_lua_reader, (void *) &io, name))
+@@ -943,7 +951,11 @@ dkimf_lua_stats_hook(void *ctx, const char *script, 
size_t scriptlen,
+               io.lua_io_len = 0;
+               io.lua_io_alloc = 0;
+ 
++#if (LUA_VERSION_NUM == 503)
++              if (lua_dump(l, dkimf_lua_writer, &io, 0) == 0)
++#else
+               if (lua_dump(l, dkimf_lua_writer, &io) == 0)
++#endif
+               {
+                       *keep = (void *) io.lua_io_script;
+                       *funclen = io.lua_io_len;
+@@ -1019,7 +1031,7 @@ dkimf_lua_final_hook(void *ctx, const char *script, 
size_t scriptlen,
+       **  Register functions.
+       */
+ 
+-# if LUA_VERSION_NUM == 502
++# if (LUA_VERSION_NUM == 502 || LUA_VERSION_NUM == 503)
+       luaL_newlib(l, dkimf_lua_lib_final);
+       lua_setglobal(l, "odkim");
+ # else /* LUA_VERSION_NUM == 502 */
+@@ -1148,7 +1160,7 @@ dkimf_lua_final_hook(void *ctx, const char *script, 
size_t scriptlen,
+       /* import other globals */
+       dkimf_import_globals(ctx, l);
+ 
+-# if LUA_VERSION_NUM == 502
++# if (LUA_VERSION_NUM == 502 || LUA_VERSION_NUM == 503)
+       switch (lua_load(l, dkimf_lua_reader, (void *) &io, name, NULL))
+ # else /* LUA_VERSION_NUM == 502 */
+       switch (lua_load(l, dkimf_lua_reader, (void *) &io, name))
+@@ -1180,7 +1192,11 @@ dkimf_lua_final_hook(void *ctx, const char *script, 
size_t scriptlen,
+               io.lua_io_len = 0;
+               io.lua_io_alloc = 0;
+ 
++#if (LUA_VERSION_NUM == 503)
++              if (lua_dump(l, dkimf_lua_writer, &io, 0) == 0)
++#else
+               if (lua_dump(l, dkimf_lua_writer, &io) == 0)
++#endif
+               {
+                       *keep = (void *) io.lua_io_script;
+                       *funclen = io.lua_io_len;
+@@ -1249,7 +1265,7 @@ dkimf_lua_db_hook(const char *script, size_t scriptlen, 
const char *query,
+               lua_pushstring(l, query);
+       lua_setglobal(l, "query");
+ 
+-# if LUA_VERSION_NUM == 502
++# if (LUA_VERSION_NUM == 502 || LUA_VERSION_NUM == 503)
+       switch (lua_load(l, dkimf_lua_reader, (void *) &io, script, NULL))
+ # else /* LUA_VERSION_NUM == 502 */
+       switch (lua_load(l, dkimf_lua_reader, (void *) &io, script))
+@@ -1281,7 +1297,11 @@ dkimf_lua_db_hook(const char *script, size_t scriptlen, 
const char *query,
+               io.lua_io_len = 0;
+               io.lua_io_alloc = 0;
+ 
++#if (LUA_VERSION_NUM == 503)
++              if (lua_dump(l, dkimf_lua_writer, &io, 0) == 0)
++#else
+               if (lua_dump(l, dkimf_lua_writer, &io) == 0)
++#endif
+               {
+                       *keep = (void *) io.lua_io_script;
+                       *funclen = io.lua_io_len;
+
+From 6c0794abc936dcda63e7433ff514185f2c541103 Mon Sep 17 00:00:00 2001
+From: Alexey Dokuchaev <[email protected]>
+Date: Tue, 19 Jan 2021 03:46:02 +0000
+Subject: [PATCH 2/3] Fix Lua version checks and thus unbreak the build against
+ Lua 5.4.
+
+Link: 
https://cgit.freebsd.org/ports/commit/?id=0426c84984ad7fbbd2b9773b9783af8b65851d69
+---
+ miltertest/miltertest.c | 12 +++----
+ opendkim/opendkim-lua.c | 70 ++++++++++++++++++++---------------------
+ 2 files changed, 41 insertions(+), 41 deletions(-)
+
+diff --git a/miltertest/miltertest.c b/miltertest/miltertest.c
+index 84278b82..d5fc6ab6 100644
+--- a/miltertest/miltertest.c
++++ b/miltertest/miltertest.c
+@@ -4009,12 +4009,12 @@ main(int argc, char **argv)
+       }
+ 
+       /* register functions */
+-#if (LUA_VERSION_NUM == 502 || LUA_VERSION_NUM == 503)
++#if LUA_VERSION_NUM >= 502
+         luaL_newlib(l, mt_library);
+       lua_setglobal(l, "mt");
+-#else /* LUA_VERSION_NUM == 502 */
++#else /* LUA_VERSION_NUM >= 502 */
+       luaL_register(l, "mt", mt_library);
+-#endif /* LUA_VERSION_NUM == 502 */
++#endif /* LUA_VERSION_NUM >= 502 */
+       lua_pop(l, 1);
+ 
+       /* register constants */
+@@ -4163,13 +4163,13 @@ main(int argc, char **argv)
+       lua_setglobal(l, "SMFIF_SETSYMLIST");
+ #endif /* SMFIF_SETSYMLIST */
+ 
+-#if (LUA_VERSION_NUM == 502 || LUA_VERSION_NUM == 503)
++#if LUA_VERSION_NUM >= 502
+       switch (lua_load(l, mt_lua_reader, (void *) &io,
+                        script == NULL ? "(stdin)" : script, NULL))
+-#else /* LUA_VERSION_NUM == 502 */
++#else /* LUA_VERSION_NUM >= 502 */
+       switch (lua_load(l, mt_lua_reader, (void *) &io,
+                        script == NULL ? "(stdin)" : script))
+-#endif /* LUA_VERSION_NUM == 502 */
++#endif /* LUA_VERSION_NUM >= 502 */
+       {
+         case 0:
+               break;
+diff --git a/opendkim/opendkim-lua.c b/opendkim/opendkim-lua.c
+index 702e8980..508fb6f5 100644
+--- a/opendkim/opendkim-lua.c
++++ b/opendkim/opendkim-lua.c
+@@ -282,11 +282,11 @@ dkimf_lua_alloc(void *ud, void *ptr, size_t osize, 
size_t nsize)
+               free(ptr);
+               return NULL;
+       }
+-# if (LUA_VERSION_NUM == 502 || LUA_VERSION_NUM == 503)
++# if LUA_VERSION_NUM >= 502
+       else if (nsize != 0 && ptr == NULL)
+-# else /* LUA_VERSION_NUM == 502 */
++# else /* LUA_VERSION_NUM >= 502 */
+       else if (nsize != 0 && osize == 0)
+-# endif /* LUA_VERSION_NUM == 502 */
++# endif /* LUA_VERSION_NUM >= 502 */
+       {
+               return malloc(nsize);
+       }
+@@ -482,12 +482,12 @@ dkimf_lua_setup_hook(void *ctx, const char *script, 
size_t scriptlen,
+       **  Register functions.
+       */
+ 
+-# if (LUA_VERSION_NUM == 502 || LUA_VERSION_NUM == 503)
++# if LUA_VERSION_NUM >= 502
+       luaL_newlib(l, dkimf_lua_lib_setup);
+       lua_setglobal(l, "odkim");
+-# else /* LUA_VERSION_NUM == 502 */
++# else /* LUA_VERSION_NUM >= 502 */
+       luaL_register(l, "odkim", dkimf_lua_lib_setup);
+-# endif /* LUA_VERSION_NUM == 502 */
++# endif /* LUA_VERSION_NUM >= 502 */
+       lua_pop(l, 1);
+ 
+       /*
+@@ -529,11 +529,11 @@ dkimf_lua_setup_hook(void *ctx, const char *script, 
size_t scriptlen,
+       /* import other globals */
+       dkimf_import_globals(ctx, l);
+ 
+-# if (LUA_VERSION_NUM == 502 || LUA_VERSION_NUM == 503)
++# if LUA_VERSION_NUM >= 502
+       switch (lua_load(l, dkimf_lua_reader, (void *) &io, name, NULL))
+-# else /* LUA_VERSION_NUM == 502 */
++# else /* LUA_VERSION_NUM >= 502 */
+       switch (lua_load(l, dkimf_lua_reader, (void *) &io, name))
+-# endif /* LUA_VERSION_NUM == 502 */
++# endif /* LUA_VERSION_NUM >= 502 */
+       {
+         case 0:
+               break;
+@@ -561,7 +561,7 @@ dkimf_lua_setup_hook(void *ctx, const char *script, size_t 
scriptlen,
+               io.lua_io_len = 0;
+               io.lua_io_alloc = 0;
+ 
+-#if (LUA_VERSION_NUM == 503)
++#if (LUA_VERSION_NUM >= 503)
+               if (lua_dump(l, dkimf_lua_writer, &io, 0) == 0)
+ #else
+               if (lua_dump(l, dkimf_lua_writer, &io) == 0)
+@@ -641,12 +641,12 @@ dkimf_lua_screen_hook(void *ctx, const char *script, 
size_t scriptlen,
+       **  Register functions.
+       */
+ 
+-# if (LUA_VERSION_NUM == 502 || LUA_VERSION_NUM == 503)
++# if LUA_VERSION_NUM >= 502
+       luaL_newlib(l, dkimf_lua_lib_screen);
+       lua_setglobal(l, "odkim");
+-# else /* LUA_VERSION_NUM == 502 */
++# else /* LUA_VERSION_NUM >= 502 */
+       luaL_register(l, "odkim", dkimf_lua_lib_screen);
+-# endif /* LUA_VERSION_NUM == 502 */
++# endif /* LUA_VERSION_NUM >= 502 */
+       lua_pop(l, 1);
+ 
+       /*
+@@ -678,11 +678,11 @@ dkimf_lua_screen_hook(void *ctx, const char *script, 
size_t scriptlen,
+       /* import other globals */
+       dkimf_import_globals(ctx, l);
+ 
+-# if (LUA_VERSION_NUM == 502 || LUA_VERSION_NUM == 503)
++# if LUA_VERSION_NUM >= 502
+       switch (lua_load(l, dkimf_lua_reader, (void *) &io, name, NULL))
+-# else /* LUA_VERSION_NUM == 502 */
++# else /* LUA_VERSION_NUM >= 502 */
+       switch (lua_load(l, dkimf_lua_reader, (void *) &io, name))
+-# endif /* LUA_VERSION_NUM == 502 */
++# endif /* LUA_VERSION_NUM >= 502 */
+       {
+         case 0:
+               break;
+@@ -710,7 +710,7 @@ dkimf_lua_screen_hook(void *ctx, const char *script, 
size_t scriptlen,
+               io.lua_io_len = 0;
+               io.lua_io_alloc = 0;
+ 
+-#if (LUA_VERSION_NUM == 503)
++#if (LUA_VERSION_NUM >= 503)
+               if (lua_dump(l, dkimf_lua_writer, &io, 0) == 0)
+ #else
+               if (lua_dump(l, dkimf_lua_writer, &io) == 0)
+@@ -790,12 +790,12 @@ dkimf_lua_stats_hook(void *ctx, const char *script, 
size_t scriptlen,
+       **  Register functions.
+       */
+ 
+-# if (LUA_VERSION_NUM == 502 || LUA_VERSION_NUM == 503)
++# if LUA_VERSION_NUM >= 502
+       luaL_newlib(l, dkimf_lua_lib_stats);
+       lua_setglobal(l, "odkim");
+-# else /* LUA_VERSION_NUM == 502 */
++# else /* LUA_VERSION_NUM >= 502 */
+       luaL_register(l, "odkim", dkimf_lua_lib_stats);
+-# endif /* LUA_VERSION_NUM == 502 */
++# endif /* LUA_VERSION_NUM >= 502 */
+       lua_pop(l, 1);
+ 
+       /*
+@@ -919,11 +919,11 @@ dkimf_lua_stats_hook(void *ctx, const char *script, 
size_t scriptlen,
+       /* import other globals */
+       dkimf_import_globals(ctx, l);
+ 
+-# if (LUA_VERSION_NUM == 502 || LUA_VERSION_NUM == 503)
++# if LUA_VERSION_NUM >= 502
+       switch (lua_load(l, dkimf_lua_reader, (void *) &io, name, NULL))
+-# else /* LUA_VERSION_NUM == 502 */
++# else /* LUA_VERSION_NUM >= 502 */
+       switch (lua_load(l, dkimf_lua_reader, (void *) &io, name))
+-# endif /* LUA_VERSION_NUM == 502 */
++# endif /* LUA_VERSION_NUM >= 502 */
+       {
+         case 0:
+               break;
+@@ -951,7 +951,7 @@ dkimf_lua_stats_hook(void *ctx, const char *script, size_t 
scriptlen,
+               io.lua_io_len = 0;
+               io.lua_io_alloc = 0;
+ 
+-#if (LUA_VERSION_NUM == 503)
++#if (LUA_VERSION_NUM >= 503)
+               if (lua_dump(l, dkimf_lua_writer, &io, 0) == 0)
+ #else
+               if (lua_dump(l, dkimf_lua_writer, &io) == 0)
+@@ -1031,12 +1031,12 @@ dkimf_lua_final_hook(void *ctx, const char *script, 
size_t scriptlen,
+       **  Register functions.
+       */
+ 
+-# if (LUA_VERSION_NUM == 502 || LUA_VERSION_NUM == 503)
++# if LUA_VERSION_NUM >= 502
+       luaL_newlib(l, dkimf_lua_lib_final);
+       lua_setglobal(l, "odkim");
+-# else /* LUA_VERSION_NUM == 502 */
++# else /* LUA_VERSION_NUM >= 502 */
+       luaL_register(l, "odkim", dkimf_lua_lib_final);
+-# endif /* LUA_VERSION_NUM == 502 */
++# endif /* LUA_VERSION_NUM >= 502 */
+       lua_pop(l, 1);
+ 
+       /*
+@@ -1160,11 +1160,11 @@ dkimf_lua_final_hook(void *ctx, const char *script, 
size_t scriptlen,
+       /* import other globals */
+       dkimf_import_globals(ctx, l);
+ 
+-# if (LUA_VERSION_NUM == 502 || LUA_VERSION_NUM == 503)
++# if LUA_VERSION_NUM >= 502
+       switch (lua_load(l, dkimf_lua_reader, (void *) &io, name, NULL))
+-# else /* LUA_VERSION_NUM == 502 */
++# else /* LUA_VERSION_NUM >= 502 */
+       switch (lua_load(l, dkimf_lua_reader, (void *) &io, name))
+-# endif /* LUA_VERSION_NUM == 502 */
++# endif /* LUA_VERSION_NUM >= 502 */
+       {
+         case 0:
+               break;
+@@ -1192,7 +1192,7 @@ dkimf_lua_final_hook(void *ctx, const char *script, 
size_t scriptlen,
+               io.lua_io_len = 0;
+               io.lua_io_alloc = 0;
+ 
+-#if (LUA_VERSION_NUM == 503)
++#if (LUA_VERSION_NUM >= 503)
+               if (lua_dump(l, dkimf_lua_writer, &io, 0) == 0)
+ #else
+               if (lua_dump(l, dkimf_lua_writer, &io) == 0)
+@@ -1265,11 +1265,11 @@ dkimf_lua_db_hook(const char *script, size_t 
scriptlen, const char *query,
+               lua_pushstring(l, query);
+       lua_setglobal(l, "query");
+ 
+-# if (LUA_VERSION_NUM == 502 || LUA_VERSION_NUM == 503)
++# if LUA_VERSION_NUM >= 502
+       switch (lua_load(l, dkimf_lua_reader, (void *) &io, script, NULL))
+-# else /* LUA_VERSION_NUM == 502 */
++# else /* LUA_VERSION_NUM >= 502 */
+       switch (lua_load(l, dkimf_lua_reader, (void *) &io, script))
+-# endif /* LUA_VERSION_NUM == 502 */
++# endif /* LUA_VERSION_NUM >= 502 */
+       {
+         case 0:
+               break;
+@@ -1297,7 +1297,7 @@ dkimf_lua_db_hook(const char *script, size_t scriptlen, 
const char *query,
+               io.lua_io_len = 0;
+               io.lua_io_alloc = 0;
+ 
+-#if (LUA_VERSION_NUM == 503)
++#if (LUA_VERSION_NUM >= 503)
+               if (lua_dump(l, dkimf_lua_writer, &io, 0) == 0)
+ #else
+               if (lua_dump(l, dkimf_lua_writer, &io) == 0)
+
+From 4282a04cc6b9c4f74a9736818139aaedcf3f24ca Mon Sep 17 00:00:00 2001
+From: Yasuhito FUTATSUKI <[email protected]>
+Date: Mon, 11 Mar 2024 15:15:30 +0000
+Subject: [PATCH 3/3] mail/opendkim: Fix fail to start with lua54 if lua files
+ is really specified
+
+Link: 
https://cgit.freebsd.org/ports/commit/?id=fb4ba36cba6f14d96323cee7f2e16b56a9ed205c
+---
+ miltertest/miltertest.c | 2 +-
+ opendkim/opendkim-lua.c | 8 ++++----
+ 2 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/miltertest/miltertest.c b/miltertest/miltertest.c
+index d5fc6ab6..ebb79d1b 100644
+--- a/miltertest/miltertest.c
++++ b/miltertest/miltertest.c
+@@ -4014,8 +4014,8 @@ main(int argc, char **argv)
+       lua_setglobal(l, "mt");
+ #else /* LUA_VERSION_NUM >= 502 */
+       luaL_register(l, "mt", mt_library);
+-#endif /* LUA_VERSION_NUM >= 502 */
+       lua_pop(l, 1);
++#endif /* LUA_VERSION_NUM >= 502 */
+ 
+       /* register constants */
+       lua_pushnumber(l, MT_HDRINSERT);
+diff --git a/opendkim/opendkim-lua.c b/opendkim/opendkim-lua.c
+index 508fb6f5..270c4464 100644
+--- a/opendkim/opendkim-lua.c
++++ b/opendkim/opendkim-lua.c
+@@ -487,8 +487,8 @@ dkimf_lua_setup_hook(void *ctx, const char *script, size_t 
scriptlen,
+       lua_setglobal(l, "odkim");
+ # else /* LUA_VERSION_NUM >= 502 */
+       luaL_register(l, "odkim", dkimf_lua_lib_setup);
+-# endif /* LUA_VERSION_NUM >= 502 */
+       lua_pop(l, 1);
++# endif /* LUA_VERSION_NUM >= 502 */
+ 
+       /*
+       **  Register constants.
+@@ -646,8 +646,8 @@ dkimf_lua_screen_hook(void *ctx, const char *script, 
size_t scriptlen,
+       lua_setglobal(l, "odkim");
+ # else /* LUA_VERSION_NUM >= 502 */
+       luaL_register(l, "odkim", dkimf_lua_lib_screen);
+-# endif /* LUA_VERSION_NUM >= 502 */
+       lua_pop(l, 1);
++# endif /* LUA_VERSION_NUM >= 502 */
+ 
+       /*
+       **  Register constants.
+@@ -795,8 +795,8 @@ dkimf_lua_stats_hook(void *ctx, const char *script, size_t 
scriptlen,
+       lua_setglobal(l, "odkim");
+ # else /* LUA_VERSION_NUM >= 502 */
+       luaL_register(l, "odkim", dkimf_lua_lib_stats);
+-# endif /* LUA_VERSION_NUM >= 502 */
+       lua_pop(l, 1);
++# endif /* LUA_VERSION_NUM >= 502 */
+ 
+       /*
+       **  Register constants.
+@@ -1036,8 +1036,8 @@ dkimf_lua_final_hook(void *ctx, const char *script, 
size_t scriptlen,
+       lua_setglobal(l, "odkim");
+ # else /* LUA_VERSION_NUM >= 502 */
+       luaL_register(l, "odkim", dkimf_lua_lib_final);
+-# endif /* LUA_VERSION_NUM >= 502 */
+       lua_pop(l, 1);
++# endif /* LUA_VERSION_NUM >= 502 */
+ 
+       /*
+       **  Register constants.

diff --git a/mail-filter/opendkim/opendkim-2.10.3-r33.ebuild 
b/mail-filter/opendkim/opendkim-2.10.3-r33.ebuild
new file mode 100644
index 000000000000..799a26d3bc1d
--- /dev/null
+++ b/mail-filter/opendkim/opendkim-2.10.3-r33.ebuild
@@ -0,0 +1,255 @@
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+LUA_COMPAT=( lua5-1 lua5-2 lua5-3 lua5-4 )
+
+inherit autotools db-use systemd tmpfiles lua-single
+
+DESCRIPTION="A milter providing DKIM signing and verification"
+HOMEPAGE="http://opendkim.org/";
+SRC_URI="https://downloads.sourceforge.net/project/opendkim/${P}.tar.gz";
+
+# The GPL-2 is for the init script, bug 425960.
+LICENSE="BSD GPL-2 Sendmail-Open-Source"
+SLOT="0"
+KEYWORDS="~amd64 ~arm ~arm64 ~x86"
+IUSE="berkdb ldap lmdb lua memcached opendbx poll sasl selinux +ssl 
static-libs stats querycache test unbound"
+
+BDEPEND="acct-user/opendkim
+       test? ( ${LUA_DEPS} )"
+
+COMMON_DEPEND="mail-filter/libmilter:=
+       dev-libs/libbsd
+       sys-apps/grep
+       ssl? (
+               dev-libs/openssl:0=
+       )
+       berkdb? ( >=sys-libs/db-3.2:* )
+       opendbx? ( >=dev-db/opendbx-1.4.0 )
+       lua? ( ${LUA_DEPS} )
+       ldap? ( net-nds/openldap:= )
+       lmdb? ( dev-db/lmdb:= )
+       memcached? ( dev-libs/libmemcached )
+       sasl? ( dev-libs/cyrus-sasl )
+       unbound? ( >=net-dns/unbound-1.4.1:= net-dns/dnssec-root )"
+
+DEPEND="${COMMON_DEPEND}"
+
+RDEPEND="${COMMON_DEPEND}
+       acct-user/opendkim
+       sys-process/psmisc
+       selinux? ( sec-policy/selinux-dkim )"
+
+REQUIRED_USE="sasl? ( ldap )
+       stats? ( opendbx )
+       querycache? ( berkdb )
+       lua? ( ${LUA_REQUIRED_USE} )
+       test? ( ${LUA_REQUIRED_USE} )"
+RESTRICT="!test? ( test )"
+
+PATCHES=(
+       "${FILESDIR}/${P}-openrc.patch"
+       "${FILESDIR}/${P}-openssl-1.1.1.patch.r2"
+       "${FILESDIR}/${P}-lua-pkgconfig.patch"
+       "${FILESDIR}/${P}-lua-pkgconfig-pt2.patch"
+       "${FILESDIR}/${P}-define-P-macro-in-libvbr.patch"
+       "${FILESDIR}/${P}-fix-libmilter-search.patch"
+       "${FILESDIR}/${P}-snprintf-include.patch"
+       "${FILESDIR}/${P}-c-std.patch"
+       "${FILESDIR}/${P}-fix-ldap-sasl-pc.patch"
+       "${FILESDIR}/${P}-incompatible-pointer-types.patch"
+       "${FILESDIR}/${P}-vsnprintf-include.patch"
+       "${FILESDIR}/${P}-lua52-lua53-lua54.patch"
+)
+
+pkg_setup() {
+       use lua && lua-single_pkg_setup
+}
+
+src_prepare() {
+       default
+       sed -e 's:/var/db/dkim:/var/lib/opendkim:g' \
+               -i opendkim/opendkim.conf.sample 
opendkim/opendkim.conf.simple.in \
+               || die
+       sed -e 's:dist_doc_DATA:dist_html_DATA:' \
+               -i libopendkim/docs/Makefile.am \
+               || die
+
+       # The existing hard-coded path under /tmp is vulnerable to exploits
+       # since (for example) a user can create a symlink there to a file
+       # that portage will clobber. Reported upstream at,
+       #
+       #   https://github.com/trusteddomainproject/OpenDKIM/issues/113
+       #
+       sed -e "s:/tmp:${T}:" -i libopendkim/tests/t-testdata.h || die
+
+       eautoreconf
+}
+
+src_configure() {
+       local myconf=()
+       if use berkdb ; then
+               myconf+=( --with-db-incdir=$(db_includedir) )
+       fi
+       if use ldap; then
+               myconf+=( $(use_with sasl) )
+       fi
+
+       # We install the our configuration filed under e.g. /etc/opendkim,
+       # so the next line is necessary to point the daemon and all of its
+       # documentation to the right location by default.
+       myconf+=( --sysconfdir="${EPREFIX}/etc/${PN}" )
+
+       econf \
+               $(use_with berkdb db) \
+               $(use_with opendbx odbx) \
+               $(use_with lua) \
+               $(use_enable lua rbl) \
+               $(use_with ldap openldap) \
+               $(use_with lmdb) \
+               $(use_enable poll) \
+               $(use_enable querycache query_cache) \
+               $(use_enable static-libs static) \
+               $(use_enable stats) \
+               $(use_with memcached libmemcached) \
+               $(use_with unbound) \
+               "${myconf[@]}" \
+               --enable-filter \
+               --with-milter \
+               --enable-atps \
+               --enable-identity_header \
+               --enable-rate_limit \
+               --enable-resign \
+               --enable-replace_rules \
+               --enable-default_sender \
+               --enable-sender_macro \
+               --enable-vbr \
+               --disable-live-testing \
+               --with-test-socket="${T}/opendkim.sock"
+}
+
+src_compile() {
+       emake runstatedir=/run
+}
+
+src_test() {
+       # Needed for now due to the expected sequencing of the setup/cleanup
+       # tests, https://github.com/trusteddomainproject/OpenDKIM/issues/110
+       emake -j1 check
+}
+
+src_install() {
+       default
+       find "${D}" -name '*.la' -type f -delete || die
+
+       dosbin stats/opendkim-reportstats
+
+       newinitd "${S}/contrib/OpenRC/opendkim.openrc" "${PN}"
+       newtmpfiles "${S}/contrib/systemd/opendkim.tmpfiles" "${PN}.conf"
+       systemd_newunit "contrib/systemd/opendkim.service" "${PN}.service"
+
+       dodir /etc/opendkim
+       keepdir /var/lib/opendkim
+
+       # The OpenDKIM data (particularly, your keys) should be read-only to
+       # the UserID that the daemon runs as.
+       fowners root:opendkim /var/lib/opendkim
+       fperms 750 /var/lib/opendkim
+
+       # Tweak the "simple" example configuration a bit before installing
+       # it unconditionally.
+       local cf="${T}/opendkim.conf"
+       # Some MTAs are known to break DKIM signatures with "simple"
+       # canonicalization [1], so we choose the "relaxed" policy
+       # over OpenDKIM's current default settings.
+       # [1] 
https://wordtothewise.com/2016/12/dkim-canonicalization-or-why-microsoft-breaks-your-mail/
+       sed -E -e 's:^(Canonicalization)[[:space:]]+.*:\1\trelaxed/relaxed:' \
+               "${S}/opendkim/opendkim.conf.simple" >"${cf}" || die
+       cat >>"${cf}" <<EOT || die
+
+# The UMask is really only used for the PID file (root:root) and the
+# local UNIX socket, if you're using one. It should be 0117 for the
+# socket.
+UMask                  0117
+UserID                 opendkim
+
+# For use with unbound
+#TrustAnchorFile       /etc/dnssec/root-anchors.txt
+EOT
+       insinto /etc/opendkim
+       doins "${cf}"
+}
+
+pkg_postinst() {
+       tmpfiles_process "${PN}.conf"
+       if [[ -z ${REPLACING_VERSION} ]]; then
+               elog "If you want to sign your mail messages and need some help"
+               elog "please run:"
+               elog "  emerge --config ${CATEGORY}/${PN}"
+               elog "It will help you create your key and give you hints on 
how"
+               elog "to configure your DNS and MTA."
+
+               elog "If you are using a local (UNIX) socket, then you will"
+               elog "need to make sure that your MTA has read/write access"
+               elog "to the socket file. This is best accomplished by creating"
+               elog "a completely-new group with only your MTA user and the"
+               elog "\"opendkim\" user in it. Step-by-step instructions can be"
+               elog "found on our Wiki, at 
https://wiki.gentoo.org/wiki/OpenDKIM ."
+       else
+               ewarn "The user account for the OpenDKIM daemon has changed"
+               ewarn "from \"milter\" to \"opendkim\" to prevent unrelated 
services"
+               ewarn "from being able to read your private keys. You should"
+               ewarn "adjust your existing configuration to use the 
\"opendkim\""
+               ewarn "user and group, and change the permissions on"
+               ewarn "${ROOT}/var/lib/opendkim to root:opendkim with mode 
0750."
+               ewarn "The owner and group of the files within that directory"
+               ewarn "will likely need to be adjusted as well."
+       fi
+}
+
+pkg_config() {
+       local selector keysize pubkey
+
+       read -p "Enter the selector name (default ${HOSTNAME}): " selector
+       [[ -n "${selector}" ]] || selector="${HOSTNAME}"
+       if [[ -z "${selector}" ]]; then
+               eerror "Oddly enough, you don't have a HOSTNAME."
+               return 1
+       fi
+       if [[ -f "${ROOT}/var/lib/opendkim/${selector}.private" ]]; then
+               ewarn "The private key for this selector already exists."
+       else
+               keysize=1024
+               # Generate the private and public keys. Note that 
opendkim-genkeys
+               # sets umask=077 on its own to keep these safe. However, we want
+               # them to be readable (only!) to the opendkim user, and we 
manage
+               # that by changing their groups and making everything 
group-readable.
+               opendkim-genkey -b ${keysize} -D "${ROOT}/var/lib/opendkim/" \
+                       -s "${selector}" -d '(your domain)' && \
+                       chgrp --no-dereference opendkim \
+                               
"${ROOT}/var/lib/opendkim/${selector}".{private,txt} || \
+                               { eerror "Failed to create private and public 
keys."; return 1; }
+               chmod g+r "${ROOT}/var/lib/opendkim/${selector}".{private,txt}
+       fi
+
+       # opendkim selector configuration
+       echo
+       einfo "Make sure you have the following settings in your 
/etc/opendkim/opendkim.conf:"
+       einfo "  Keyfile /var/lib/opendkim/${selector}.private"
+       einfo "  Selector ${selector}"
+
+       # MTA configuration
+       echo
+       einfo "If you are using Postfix, add following lines to your main.cf:"
+       einfo "  smtpd_milters     = unix:/run/opendkim/opendkim.sock"
+       einfo "  non_smtpd_milters = unix:/run/opendkim/opendkim.sock"
+       einfo "  and read http://www.postfix.org/MILTER_README.html";
+
+       # DNS configuration
+       einfo "After you configured your MTA, publish your key by adding this 
TXT record to your domain:"
+       cat "${ROOT}/var/lib/opendkim/${selector}.txt"
+       einfo "t=y signifies you only test the DKIM on your domain. See 
following page for the complete list of tags:"
+       einfo "  https://www.rfc-editor.org/rfc/rfc6376.html#section-3.6.1";
+}

Reply via email to