New patch, this time with auto-detection of dlname in EDITME, as requested by
Magnus.
Please note, that I have NOT tested it yet. But I intend to test it
throughfully once you confirm that this is the approach you want.
--
Robert Millan
<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)
diff -Nur exim-src/OS/Makefile-Base exim-src.dynamic/OS/Makefile-Base
--- exim-src/OS/Makefile-Base 2008-02-14 14:49:35.000000000 +0100
+++ exim-src.dynamic/OS/Makefile-Base 2008-02-24 20:06:11.000000000 +0100
@@ -304,7 +304,7 @@
# updated each time. We don't bother with that for the auxiliaries.
OBJ_EXIM = acl.o child.o crypt16.o daemon.o dbfn.o debug.o deliver.o \
- directory.o dns.o drtables.o enq.o exim.o expand.o filter.o \
+ directory.o dns.o drtables.o dynamic.o enq.o exim.o expand.o filter.o \
filtertest.o globals.o \
header.o host.o ip.o log.o lss.o match.o moan.o \
os.o parse.o queue.o \
@@ -540,6 +540,7 @@
deliver.o: $(HDRS) deliver.c
directory.o: $(HDRS) directory.c
dns.o: $(HDRS) dns.c
+dynamic.o: $(HDRS) dynamic.c
enq.o: $(HDRS) enq.c
exim.o: $(HDRS) exim.c
expand.o: $(HDRS) expand.c
diff -Nur exim-src/scripts/MakeLinks exim-src.dynamic/scripts/MakeLinks
--- exim-src/scripts/MakeLinks 2008-01-17 14:03:35.000000000 +0100
+++ exim-src.dynamic/scripts/MakeLinks 2008-02-24 20:06:11.000000000 +0100
@@ -217,6 +217,7 @@
ln -s ../src/dns.c dns.c
ln -s ../src/drtables.c drtables.c
ln -s ../src/dummies.c dummies.c
+ln -s ../src/dynamic.c dynamic.c
ln -s ../src/enq.c enq.c
ln -s ../src/exim.c exim.c
ln -s ../src/exim_dbmbuild.c exim_dbmbuild.c
diff -Nur exim-src/src/dynamic.c exim-src.dynamic/src/dynamic.c
--- exim-src/src/dynamic.c 1970-01-01 01:00:00.000000000 +0100
+++ exim-src.dynamic/src/dynamic.c 2008-02-24 20:17:43.000000000 +0100
@@ -0,0 +1,211 @@
+/*
+ * Copyright (c) 2008 Robert Millan
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ */
+
+#ifdef DYNAMIC_LOADER
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <dlfcn.h>
+
+#include "exim.h"
+
+static struct { void *handle; char filename[]; } dltable[] =
+{
+#ifdef EXPERIMENTAL_SPF
+ { NULL, LIBSPF_DLNAME },
+#endif
+};
+
+enum dltable_members
+{
+#ifdef EXPERIMENTAL_SPF
+ LIBSPF,
+#endif
+};
+
+static void *
+load_so (char *so)
+{
+ void *ret;
+
+ ret = dlopen (so, RTLD_GLOBAL|RTLD_LAZY);
+ if (! ret)
+ {
+ fprintf (stderr, "%s\n", dlerror ());
+ exit (1);
+ }
+
+ return ret;
+}
+
+static void *
+load_sym (int id, char *sym)
+{
+ void *ret;
+ char *err;
+
+ if (! dltable[id].handle)
+ dltable[id].handle = load_so (dltable[id].filename);
+
+ dlerror (); /* Clear old error conditions. */
+ ret = dlsym (dltable[id].handle, sym);
+ err = dlerror ();
+ if (err)
+ {
+ fprintf (stderr, "%s\n", err);
+ exit (1);
+ }
+
+ return ret;
+}
+
+
+
+#ifdef EXPERIMENTAL_SPF
+
+static SPF_request_t *(*fn_SPF_request_new_ptr) (SPF_server_t *) = NULL;
+SPF_request_t *
+SPF_request_new (SPF_server_t *spf_server)
+{
+ if (! fn_SPF_request_new_ptr)
+ fn_SPF_request_new_ptr = load_sym (LIBSPF, "SPF_request_new");
+ return (*fn_SPF_request_new_ptr) (spf_server);
+}
+
+int (*fn_SPF_request_set_env_from_ptr) (SPF_request_t *, const char *) = NULL;
+int
+SPF_request_set_env_from (SPF_request_t *sr, const char *from)
+{
+ if (! fn_SPF_request_set_env_from_ptr)
+ fn_SPF_request_set_env_from_ptr = load_sym (LIBSPF, "SPF_request_set_env_from");
+ return (*fn_SPF_request_set_env_from_ptr) (sr, from);
+}
+
+SPF_errcode_t (*fn_SPF_request_query_mailfrom_ptr) (SPF_request_t *, SPF_response_t **) = NULL;
+SPF_errcode_t
+SPF_request_query_mailfrom (SPF_request_t *spf_request, SPF_response_t **spf_responsep)
+{
+ if (! fn_SPF_request_query_mailfrom_ptr)
+ fn_SPF_request_query_mailfrom_ptr = load_sym (LIBSPF, "SPF_request_query_mailfrom");
+ return (*fn_SPF_request_query_mailfrom_ptr) (spf_request, spf_responsep);
+}
+
+SPF_errcode_t (*fn_SPF_request_set_ipv4_str_ptr) (SPF_request_t *, const char *) = NULL;
+SPF_errcode_t
+SPF_request_set_ipv4_str (SPF_request_t *sr, const char *astr)
+{
+ if (! fn_SPF_request_set_ipv4_str_ptr)
+ fn_SPF_request_set_ipv4_str_ptr = load_sym (LIBSPF, "SPF_request_set_ipv4_str");
+ return (*fn_SPF_request_set_ipv4_str_ptr) (sr, astr);
+}
+
+SPF_errcode_t (*fn_SPF_request_set_helo_dom_ptr) (SPF_request_t *, const char *) = NULL;
+SPF_errcode_t
+SPF_request_set_helo_dom (SPF_request_t *sr, const char *dom)
+{
+ if (! fn_SPF_request_set_helo_dom_ptr)
+ fn_SPF_request_set_helo_dom_ptr = load_sym (LIBSPF, "SPF_request_set_helo_dom");
+ return (*fn_SPF_request_set_helo_dom_ptr) (sr, dom);
+}
+
+void (*fn_SPF_request_free_ptr) (SPF_request_t *) = NULL;
+void
+SPF_request_free (SPF_request_t *sr)
+{
+ if (! fn_SPF_request_free_ptr)
+ fn_SPF_request_free_ptr = load_sym (LIBSPF, "SPF_request_free");
+ return (*fn_SPF_request_free_ptr) (sr);
+}
+
+const char *(*fn_SPF_response_get_header_comment_ptr) (SPF_response_t *) = NULL;
+const char *
+SPF_response_get_header_comment (SPF_response_t *rp)
+{
+ if (! fn_SPF_response_get_header_comment_ptr)
+ fn_SPF_response_get_header_comment_ptr = load_sym (LIBSPF, "SPF_response_get_header_comment");
+ return (*fn_SPF_response_get_header_comment_ptr) (rp);
+}
+
+const char *(*fn_SPF_response_get_smtp_comment_ptr) (SPF_response_t *) = NULL;
+const char *
+SPF_response_get_smtp_comment (SPF_response_t *rp)
+{
+ if (! fn_SPF_response_get_smtp_comment_ptr)
+ fn_SPF_response_get_smtp_comment_ptr = load_sym (LIBSPF, "SPF_response_get_smtp_comment");
+ return (*fn_SPF_response_get_smtp_comment_ptr) (rp);
+}
+
+const char *(*fn_SPF_response_get_received_spf_ptr) (SPF_response_t *) = NULL;
+const char *
+SPF_response_get_received_spf (SPF_response_t *rp)
+{
+ if (! fn_SPF_response_get_received_spf_ptr)
+ fn_SPF_response_get_received_spf_ptr = load_sym (LIBSPF, "SPF_response_get_received_spf");
+ return (*fn_SPF_response_get_received_spf_ptr) (rp);
+}
+
+SPF_result_t (*fn_SPF_response_result_ptr) (SPF_response_t *) = NULL;
+SPF_result_t
+SPF_response_result (SPF_response_t *rp)
+{
+ if (! fn_SPF_response_result_ptr)
+ fn_SPF_response_result_ptr = load_sym (LIBSPF, "SPF_response_result");
+ return (*fn_SPF_response_result_ptr) (rp);
+}
+
+void (*fn_SPF_response_free_ptr) (SPF_response_t *) = NULL;
+void
+SPF_response_free (SPF_response_t *rp)
+{
+ if (! fn_SPF_response_free_ptr)
+ fn_SPF_response_free_ptr = load_sym (LIBSPF, "SPF_response_free");
+ return (*fn_SPF_response_free_ptr) (rp);
+}
+
+const char *(*fn_SPF_strresult_ptr) (SPF_result_t) = NULL;
+const char *
+SPF_strresult (SPF_result_t result)
+{
+ if (! fn_SPF_strresult_ptr)
+ fn_SPF_strresult_ptr = load_sym (LIBSPF, "SPF_strresult");
+ return (*fn_SPF_strresult_ptr) (result);
+}
+
+
+SPF_server_t *(*fn_SPF_server_new_ptr) (SPF_server_dnstype_t, int) = NULL;
+SPF_server_t *
+SPF_server_new (SPF_server_dnstype_t dnstype, int debug)
+{
+ if (! fn_SPF_server_new_ptr)
+ fn_SPF_server_new_ptr = load_sym (LIBSPF, "SPF_server_new");
+ return (*fn_SPF_server_new_ptr) (dnstype, debug);
+}
+
+SPF_errcode_t (*fn_SPF_server_set_rec_dom_ptr) (SPF_server_t *, const char *) = NULL;
+SPF_errcode_t
+SPF_server_set_rec_dom (SPF_server_t *sp, const char *dom)
+{
+ if (! fn_SPF_server_set_rec_dom_ptr)
+ fn_SPF_server_set_rec_dom_ptr = load_sym (LIBSPF, "SPF_server_set_rec_dom");
+ return (*fn_SPF_server_set_rec_dom_ptr) (sp, dom);
+}
+
+void (*fn_SPF_server_free_ptr) (SPF_server_t *) = NULL;
+void
+SPF_server_free (SPF_server_t *sp)
+{
+ if (! fn_SPF_server_free_ptr)
+ fn_SPF_server_free_ptr = load_sym (LIBSPF, "SPF_server_free");
+ return (*fn_SPF_server_free_ptr) (sp);
+}
+
+#endif /* EXPERIMENTAL_SPF */
+
+#endif /* DYNAMIC_LOADER */
diff -Nur exim-src/src/EDITME exim-src.dynamic/src/EDITME
--- exim-src/src/EDITME 2008-01-16 14:44:45.000000000 +0100
+++ exim-src.dynamic/src/EDITME 2008-02-24 20:17:21.000000000 +0100
@@ -363,7 +363,13 @@
# EXPERIMENTAL_SPF=yes
# CFLAGS += -I/usr/local/include
+
+# You can either link directly with libspf2, by uncommenting the LDFLAGS line
+# below, or instruct Exim to dlopen() it only in case it is needed (i.e. if
+# your ACLs require it), by uncommenting the CFLAGS line below:
+
# LDFLAGS += -lspf2
+# CFLAGS += -DDYNAMIC_LOADER -DLIBSPF_DLNAME=$(shell . /usr/lib/libspf2.la && echo $$dlname)
# Uncomment the following lines to add SRS (Sender rewriting scheme) support.
# You need to have libsrs_alt installed on your system (srs.mirtol.com).