mirror of
https://github.com/novatiq/packages.git
synced 2026-04-30 15:38:40 +01:00
libmilter-sendmail: the sendmail mail filter API library
The sendmail Mail Filter API (Milter) is designed to allow third-party programs access to mail messages as they are being processed in order to filter meta-information and content. This library is a prerequisite for the OpenDKIM package. The proposed Makefile also contains sections for building Sendmail. These sections are commented out because more work is necessary to properly complete porting of Sendmail to LEDE/OpenWrt. The notes in Makefile provide details on what is required to complete the port. It has been verified that Sendmail executables compile and run properly on the target system when the commented sections in Makefile are uncommented. Signed-off-by: Val Kulkov <val.kulkov@gmail.com>
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
Index: sendmail-8.15.2/cf/cf/Makefile
|
||||
===================================================================
|
||||
--- sendmail-8.15.2.orig/cf/cf/Makefile
|
||||
+++ sendmail-8.15.2/cf/cf/Makefile
|
||||
@@ -80,10 +80,10 @@ install:
|
||||
install-cf: install-sendmail-cf install-submit-cf
|
||||
|
||||
install-sendmail-cf: $(CF).cf
|
||||
- $(INSTALL) -c -o $(CFOWN) -g $(CFGRP) -m $(CFMODE) $(CF).cf ${DESTDIR}$(MAILDIR)/sendmail.cf
|
||||
+ $(INSTALL) -c -m $(CFMODE) $(CF).cf ${DESTDIR}$(MAILDIR)/sendmail.cf
|
||||
|
||||
install-submit-cf: $(SUBMIT).cf
|
||||
- $(INSTALL) -c -o $(CFOWN) -g $(CFGRP) -m $(CFMODE) $(SUBMIT).cf ${DESTDIR}$(MAILDIR)/submit.cf
|
||||
+ $(INSTALL) -c -m $(CFMODE) $(SUBMIT).cf ${DESTDIR}$(MAILDIR)/submit.cf
|
||||
|
||||
depend:
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
Index: sendmail-8.15.2/libmilter/Makefile.m4
|
||||
===================================================================
|
||||
--- sendmail-8.15.2.orig/libmilter/Makefile.m4
|
||||
+++ sendmail-8.15.2/libmilter/Makefile.m4
|
||||
@@ -9,7 +9,10 @@ define(`confMT', `true')
|
||||
SMSRCDIR=ifdef(`confSMSRCDIR', `confSMSRCDIR', `${SRCDIR}/sendmail')
|
||||
PREPENDDEF(`confINCDIRS', `-I${SMSRCDIR} ')
|
||||
|
||||
-bldPRODUCT_START(`library', `libmilter')
|
||||
+# obtain libmilter version
|
||||
+define(`confSOVER', `esyscmd(`gcc -I../include -o lm_getver lm_getver.c && ./lm_getver')')
|
||||
+
|
||||
+bldPRODUCT_START(`sharedlibrary', `libmilter')
|
||||
define(`bldINSTALLABLE', `true')
|
||||
define(`LIBMILTER_EXTRAS', `errstring.c strl.c')
|
||||
APPENDDEF(`confENVDEF', `-DNOT_SENDMAIL -Dsm_snprintf=snprintf')
|
||||
@@ -0,0 +1,49 @@
|
||||
--- a/include/sm/conf.h
|
||||
+++ b/include/sm/conf.h
|
||||
@@ -57,7 +57,7 @@
|
||||
# endif /* ! HASNICE */
|
||||
|
||||
# ifndef HASRRESVPORT
|
||||
-# define HASRRESVPORT 1 /* has rrsevport(3) call */
|
||||
+# define HASRRESVPORT 0 /* has rrsevport(3) call */
|
||||
# endif /* ! HASRRESVPORT */
|
||||
|
||||
/**********************************************************************
|
||||
@@ -1470,7 +1470,9 @@ extern void *malloc();
|
||||
# define SM_CONF_GETOPT 0 /* need a replacement for getopt(3) */
|
||||
# define HASUNAME 1 /* use System V uname(2) system call */
|
||||
# define HASUNSETENV 1 /* has unsetenv(3) call */
|
||||
-# define ERRLIST_PREDEFINED /* don't declare sys_errlist */
|
||||
+# ifdef __GLIBC__
|
||||
+# define ERRLIST_PREDEFINED /* don't declare sys_errlist */
|
||||
+# endif /* __GLIBC__ */
|
||||
# define GIDSET_T gid_t /* from <linux/types.h> */
|
||||
# ifndef HASGETUSERSHELL
|
||||
# define HASGETUSERSHELL 0 /* getusershell(3) broken in Slackware 2.0 */
|
||||
@@ -1508,6 +1510,7 @@ extern void *malloc();
|
||||
# if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
|
||||
# define HASSTRERROR 1 /* has strerror(3) */
|
||||
# endif /* defined(__GLIBC__) && defined(__GLIBC_MINOR__) */
|
||||
+# define HASSTRERROR 1 /* Patch for LEDE/OpenWRT: has strerror(3) */
|
||||
# ifndef TZ_TYPE
|
||||
# define TZ_TYPE TZ_NONE /* no standard for Linux */
|
||||
# endif /* ! TZ_TYPE */
|
||||
--- a/devtools/bin/Build
|
||||
+++ b/devtools/bin/Build
|
||||
@@ -320,6 +320,16 @@ then
|
||||
rel=`/usr/apollo/bin/bldt | grep Domain | awk '{ print $4 }' | sed -e 's/,//g'`
|
||||
fi
|
||||
|
||||
+#
|
||||
+# LEDE/OpenWrt build system
|
||||
+#
|
||||
+if [ -n "$STAGING_DIR" -a -n "$OPENWRT_BUILD" ]
|
||||
+then
|
||||
+ os="OpenWrt"
|
||||
+ rel="any"
|
||||
+ arch="any"
|
||||
+fi
|
||||
+
|
||||
if [ ! "$arch" -a ! "$os" -a ! "$rel" ]
|
||||
then
|
||||
arch=`uname -m | sed -e 's/ //g' -e 's/\//-/g'`
|
||||
@@ -0,0 +1,109 @@
|
||||
Index: sendmail-8.15.2/sendmail/envelope.c
|
||||
===================================================================
|
||||
--- sendmail-8.15.2.orig/sendmail/envelope.c
|
||||
+++ sendmail-8.15.2/sendmail/envelope.c
|
||||
@@ -323,7 +323,7 @@ dropenvelope(e, fulldrop, split)
|
||||
|
||||
/* don't free, allocated from e_rpool */
|
||||
e->e_message = sm_rpool_strdup_x(e->e_rpool, buf);
|
||||
- message(buf);
|
||||
+ message("%s", buf);
|
||||
e->e_flags |= EF_CLRQUEUE;
|
||||
}
|
||||
if (msg_timeout == MSG_NOT_BY)
|
||||
@@ -420,7 +420,7 @@ dropenvelope(e, fulldrop, split)
|
||||
/* don't free, allocated from e_rpool */
|
||||
e->e_message = sm_rpool_strdup_x(e->e_rpool,
|
||||
buf);
|
||||
- message(buf);
|
||||
+ message("%s", buf);
|
||||
e->e_flags |= EF_WARNING;
|
||||
}
|
||||
if (msg_timeout == MSG_WARN_BY)
|
||||
Index: sendmail-8.15.2/sendmail/parseaddr.c
|
||||
===================================================================
|
||||
--- sendmail-8.15.2.orig/sendmail/parseaddr.c
|
||||
+++ sendmail-8.15.2/sendmail/parseaddr.c
|
||||
@@ -218,7 +218,7 @@ parseaddr(addr, a, flags, delim, delimpt
|
||||
msg = "Deferring message until queue run";
|
||||
if (tTd(20, 1))
|
||||
sm_dprintf("parseaddr: queueing message\n");
|
||||
- message(msg);
|
||||
+ message("%s", msg);
|
||||
if (e->e_message == NULL && e->e_sendmode != SM_DEFER)
|
||||
e->e_message = sm_rpool_strdup_x(e->e_rpool, msg);
|
||||
a->q_state = QS_QUEUEUP;
|
||||
Index: sendmail-8.15.2/sendmail/srvrsmtp.c
|
||||
===================================================================
|
||||
--- sendmail-8.15.2.orig/sendmail/srvrsmtp.c
|
||||
+++ sendmail-8.15.2/sendmail/srvrsmtp.c
|
||||
@@ -578,13 +578,13 @@ static bool smtp_data __P((SMTP_T *, ENV
|
||||
bool tsave = QuickAbort; \
|
||||
\
|
||||
QuickAbort = false; \
|
||||
- usrerr(response); \
|
||||
+ usrerr("%s", response); \
|
||||
QuickAbort = tsave; \
|
||||
e->e_sendqueue = NULL; \
|
||||
goto doquit; \
|
||||
} \
|
||||
else \
|
||||
- usrerr(response); \
|
||||
+ usrerr("%s", response); \
|
||||
break; \
|
||||
\
|
||||
case SMFIR_REJECT: \
|
||||
@@ -615,7 +615,7 @@ static bool smtp_data __P((SMTP_T *, ENV
|
||||
str, addr, MSG_TEMPFAIL); \
|
||||
LogUsrErrs = false; \
|
||||
} \
|
||||
- usrerr(MSG_TEMPFAIL); \
|
||||
+ usrerr("%s", MSG_TEMPFAIL); \
|
||||
break; \
|
||||
default: \
|
||||
milter_cmd_fail = false; \
|
||||
@@ -931,7 +931,7 @@ smtp(nullserver, d_flags, e)
|
||||
}
|
||||
else if (strncmp(nullserver, "421 ", 4) == 0)
|
||||
{
|
||||
- message(nullserver);
|
||||
+ message("%s", nullserver);
|
||||
goto doquit;
|
||||
}
|
||||
|
||||
@@ -1849,7 +1849,7 @@ smtp(nullserver, d_flags, e)
|
||||
if (nullserver != NULL)
|
||||
{
|
||||
if (ISSMTPREPLY(nullserver))
|
||||
- usrerr(nullserver);
|
||||
+ usrerr("%s", nullserver);
|
||||
else
|
||||
usrerr("550 5.0.0 %s",
|
||||
nullserver);
|
||||
@@ -2452,7 +2452,7 @@ smtp(nullserver, d_flags, e)
|
||||
tempfail = true;
|
||||
smtp.sm_milterize = false;
|
||||
if (response != NULL)
|
||||
- usrerr(response);
|
||||
+ usrerr("%s", response);
|
||||
else
|
||||
message("421 4.7.0 %s closing connection",
|
||||
MyHostName);
|
||||
@@ -3659,7 +3659,7 @@ smtp_data(smtp, e)
|
||||
(void) extenhsc(response + 4, ' ', e->e_enhsc);
|
||||
#endif /* _FFR_MILTER_ENHSC */
|
||||
|
||||
- usrerr(response);
|
||||
+ usrerr("%s", response);
|
||||
if (strncmp(response, "421 ", 4) == 0
|
||||
|| strncmp(response, "421-", 4) == 0)
|
||||
{
|
||||
@@ -3779,7 +3779,7 @@ smtp_data(smtp, e)
|
||||
if (ISSMTPCODE(response))
|
||||
(void) extenhsc(response + 4, ' ', e->e_enhsc);
|
||||
#endif /* _FFR_MILTER_ENHSC */
|
||||
- usrerr(response);
|
||||
+ usrerr("%s", response);
|
||||
if (strncmp(response, "421 ", 4) == 0
|
||||
|| strncmp(response, "421-", 4) == 0)
|
||||
rv = false;
|
||||
@@ -0,0 +1,48 @@
|
||||
This patch increases the stack size for pthreads from 80 KB, the default
|
||||
stack size for musl libc, to 2 MB. The default stack size for glibc is 8 MB.
|
||||
|
||||
OpenDKIM, an application that depends on libmilter, segfaults if the stack
|
||||
size for pthreads is left unchanged at the musl default value of 80 KB.
|
||||
Apparently, OpenDKIM allocates blocks of 64 KB multiple times, which causes
|
||||
libmilter and therefore OpenDKIM to crash:
|
||||
https://git.alpinelinux.org/cgit/aports/commit/?id=95724d1bd53ae87f72e6388cb7323dbd8f84be9d
|
||||
|
||||
This patch follows the patch suggested by an Alpine Linux user in bug report
|
||||
above. Also, a bug report has been filed upstream:
|
||||
https://sourceforge.net/p/opendkim/bugs/258/
|
||||
|
||||
|
||||
Index: sendmail-8.15.2/libmilter/libmilter.h
|
||||
===================================================================
|
||||
--- sendmail-8.15.2.orig/libmilter/libmilter.h
|
||||
+++ sendmail-8.15.2/libmilter/libmilter.h
|
||||
@@ -127,10 +127,10 @@ struct smfi_str
|
||||
# define MI_SOCK_READ(s, b, l) read(s, b, l)
|
||||
# define MI_SOCK_READ_FAIL(x) ((x) < 0)
|
||||
# define MI_SOCK_WRITE(s, b, l) write(s, b, l)
|
||||
-
|
||||
-# define thread_create(ptid,wr,arg) pthread_create(ptid, NULL, wr, arg)
|
||||
# define sthread_get_id() pthread_self()
|
||||
|
||||
+extern int thread_create(pthread_t *ptid, void *(*wr) (void *), void *arg);
|
||||
+
|
||||
typedef pthread_mutex_t smutex_t;
|
||||
# define smutex_init(mp) (pthread_mutex_init(mp, NULL) == 0)
|
||||
# define smutex_destroy(mp) (pthread_mutex_destroy(mp) == 0)
|
||||
Index: sendmail-8.15.2/libmilter/main.c
|
||||
===================================================================
|
||||
--- sendmail-8.15.2.orig/libmilter/main.c
|
||||
+++ sendmail-8.15.2/libmilter/main.c
|
||||
@@ -16,6 +16,12 @@ SM_RCSID("@(#)$Id: main.c,v 8.85 2013-11
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
+int thread_create(pthread_t *ptid, void *(*wr) (void *), void *arg) {
|
||||
+ pthread_attr_t attr;
|
||||
+ pthread_attr_init(&attr);
|
||||
+ pthread_attr_setstacksize(&attr,2*1024*1024);
|
||||
+ return pthread_create(ptid, &attr, wr, arg);
|
||||
+}
|
||||
|
||||
static smfiDesc_ptr smfi = NULL;
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
--- a/sendmail/Makefile.m4
|
||||
+++ b/sendmail/Makefile.m4
|
||||
@@ -71,6 +71,7 @@ install-set-user-id: bldCURRENT_PRODUCT
|
||||
${INSTALL} -c -o ${S`'BINOWN} -g ${S`'BINGRP} -m ${S`'BINMODE} bldCURRENT_PRODUCT ${DESTDIR}${M`'BINDIR}
|
||||
for i in ${sendmailTARGET_LINKS}; do \
|
||||
rm -f $$i; \
|
||||
+ mkdir -p $$(dirname $$i); \
|
||||
${LN} ${LNOPTS} ${M`'BINDIR}/sendmail $$i; \
|
||||
done
|
||||
|
||||
@@ -79,6 +80,7 @@ install-sm-mta: bldCURRENT_PRODUCT
|
||||
${INSTALL} -c -o ${M`'BINOWN} -g ${M`'BINGRP} -m ${M`'BINMODE} bldCURRENT_PRODUCT ${DESTDIR}${M`'BINDIR}/sm-mta
|
||||
for i in confMTA_LINKS; do \
|
||||
rm -f $$i; \
|
||||
+ mkdir -p $$(dirname $$i); \
|
||||
${LN} ${LNOPTS} ${M`'BINDIR}/sm-mta $$i; \
|
||||
done
|
||||
|
||||
--- a/devtools/M4/UNIX/links.m4
|
||||
+++ b/devtools/M4/UNIX/links.m4
|
||||
@@ -23,6 +23,7 @@ define(`bldMAKE_SOURCE_LINKS',
|
||||
define(`bldMAKE_TARGET_LINKS',
|
||||
` for i in $2; do \
|
||||
rm -f $$i; \
|
||||
+ mkdir -p $$(dirname $$i); \
|
||||
ln -s $1 $$i; \
|
||||
done'
|
||||
)dnl
|
||||
--- a/cf/cf/Makefile
|
||||
+++ b/cf/cf/Makefile
|
||||
@@ -80,9 +80,11 @@ install:
|
||||
install-cf: install-sendmail-cf install-submit-cf
|
||||
|
||||
install-sendmail-cf: $(CF).cf
|
||||
+ mkdir -p ${DESTDIR}$(MAILDIR)
|
||||
$(INSTALL) -c -m $(CFMODE) $(CF).cf ${DESTDIR}$(MAILDIR)/sendmail.cf
|
||||
|
||||
install-submit-cf: $(SUBMIT).cf
|
||||
+ mkdir -p ${DESTDIR}$(MAILDIR)
|
||||
$(INSTALL) -c -m $(CFMODE) $(SUBMIT).cf ${DESTDIR}$(MAILDIR)/submit.cf
|
||||
|
||||
depend:
|
||||
Reference in New Issue
Block a user