aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog18
-rw-r--r--NEWS11
-rw-r--r--configure.ac26
-rw-r--r--doc/mailfromd.texi36
-rw-r--r--src/Makefile.am13
-rw-r--r--src/bi_sieve.m421
-rw-r--r--src/main.c26
-rw-r--r--src/syslog_async.c43
8 files changed, 152 insertions, 42 deletions
diff --git a/ChangeLog b/ChangeLog
index ea8e7586..f820e701 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,23 @@
2007-12-12 Sergey Poznyakoff <gray@gnu.org.ua>
- * src/main.c: Reflect recent changes to Mailutils.
+ Ported r1536 from branches/release_4_2_patches (= r1535 from
+ tags/release_4_2):
+
+ * src/syslog_async.c: Include config.h, netinet/in.h and signal.h
+ Conditionally include paths.h, provide replacements for _PATH_LOG
+ and _PATH_CONSOLE if it is absent.
+ Provide dummy replacement for MSG_NOSIGNAL and LOG_PERROR.
+ (log_write_async): Ignore SIGPIPE if MSG_NOSIGNAL is not defined.
+ * src/main.c: Conditionally compile syslog-async stuff.
+ * src/Makefile.am: Likewise.
+ * configure.ac: Check for paths.h.
+ Restore previous meaning of --enable-syslog-async.
+ (DEFAULT_SYSLOG_ASYNC): New variable.
+
+ * doc/mailfromd.texi: Reflect above-mentioned changes.
+ * src/main.c: Reflect recent changes to Mailutils.
+
2007-11-22 Sergey Poznyakoff <gray@gnu.org.ua>
* src/main.c: Implement MU configuration statements.
diff --git a/NEWS b/NEWS
index bfc57a75..9e0d81f1 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
-Mailfromd NEWS -- history of user-visible changes. 2007-11-21
+Mailfromd NEWS -- history of user-visible changes. 2007-12-12
Copyright (C) 2005, 2006, 2007 Sergey Poznyakoff
See the end of file for copying conditions.
@@ -25,6 +25,13 @@ done
New built-in function `sieve' provides an interface to Sieve
interpreter.
+* Restore previous meaning of --enable-syslog-async.
+
+Unless this option is given to ./configure, asynchronous syslog
+implementation will not be compiled.
+
+* Fix compilation on Sun.
+
Version 4.2, 2007-10-23
@@ -33,7 +40,7 @@ Version 4.2, 2007-10-23
* New command line options --syslog-async and --no-syslog-async
These options allow to select the implementation of syslog to use
-at run time.
+at run time.
* RFC 2821 compatibility
diff --git a/configure.ac b/configure.ac
index 12f50008..c2684558 100644
--- a/configure.ac
+++ b/configure.ac
@@ -47,7 +47,7 @@ AC_CHECK_LIB(resolv, res_query)
# Checks for header files.
AC_HEADER_STDC
-AC_CHECK_HEADERS([stdlib.h unistd.h sysexits.h])
+AC_CHECK_HEADERS([stdlib.h unistd.h sysexits.h paths.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_SIGNAL
@@ -107,19 +107,23 @@ AM_GNU_GETTEXT_VERSION([0.16])
# Syslog
AC_ARG_ENABLE([syslog-async],
AC_HELP_STRING([--enable-syslog-async],
- [use non-blocking version of syslog by default]),
+ [compile non-blocking version of syslog]),
[case "${enableval}" in
yes) syslog_async=yes ;;
no) syslog_async=no ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-syslog-async]) ;;
esac],[syslog_async=no])
-AH_TEMPLATE([DEFAULT_SYSLOG_ASYNC],
- [Define to 1 if syslog-async is being used by default])
if test $syslog_async = "yes"; then
- AC_DEFINE([DEFAULT_SYSLOG_ASYNC], [1])
-else
- AC_DEFINE([DEFAULT_SYSLOG_ASYNC], [0])
+ AC_ARG_VAR([DEFAULT_SYSLOG_ASYNC],
+ [Define to 1 if syslog-async is being used by default])
+ if test -z "$DEFAULT_SYSLOG_ASYNC"; then
+ DEFAULT_SYSLOG_ASYNC=0
+ fi
+ AC_DEFINE_UNQUOTED([DEFAULT_SYSLOG_ASYNC],$DEFAULT_SYSLOG_ASYNC,
+ [Define to 1 to use syslog_async by default])
+ AC_SUBST([BUILD_SYSLOG_ASYNC], '$(SYSLOG_ASYNC_O)')
+ AC_DEFINE([USE_SYSLOG_ASYNC], [1], [Define if syslog-async is being used])
fi
# Check for DBM flavor
@@ -554,7 +558,7 @@ Socket.................................... $socket
Expiration interval....................... $expire
Negative DNS answer expiration interval... $negative_dns_expire
Rates expire interval..................... $rates_expire
-Default syslog implementation............. $syslog_flavor
+Compile asynchronous syslog............... $syslog_async
Readline (for mtasim)..................... $usereadline
Documentation rendition type.............. $rendition
*******************************************************************
@@ -576,11 +580,7 @@ negative_dns_expire=$DEFAULT_DNS_NEGATIVE_EXPIRE_INTERVAL
rates_expire=$DEFAULT_EXPIRE_RATES_INTERVAL
usereadline=$usereadline
rendition=$RENDITION
-if test "$syslog_async" = "yes"; then
- syslog_flavor="non-blocking"
-else
- syslog_flavor="standard"
-fi
+syslog_async=$syslog_async
])
AC_CONFIG_FILES([Makefile
diff --git a/doc/mailfromd.texi b/doc/mailfromd.texi
index 95c6741f..6db9fd78 100644
--- a/doc/mailfromd.texi
+++ b/doc/mailfromd.texi
@@ -131,6 +131,7 @@ Sender Address Verification.
Building the Package
+* 420-430:: Upgrading from 4.2 to 4.3
* 410-420:: Upgrading from 4.1 to 4.2
* 400-410:: Upgrading from 4.0 to 4.1
* 31x-400:: Upgrading from 3.1.x to 4.0
@@ -910,17 +911,26 @@ lines are lost, this fact is logged with a message of the form:
async_syslog overflow: 5 log entries lost
@end smallexample
- You can select which implementation to run when starting
-@command{mailfromd}, by using @option{--syslog-async} or
-@option{--no-syslog-async} command line options
-(@pxref{Logging and Debugging}). When configuring, you can set
-the asynchronous syslog as the @emph{default} syslog implementation,
-using the @option{--enable-syslog-async} command line option:
+ To enable this implementation, configure the package with
+@option{--enable-syslog-async} option, e.g.:
@smallexample
./configure --enable-syslog-async
@end smallexample
+@cindex @code{DEFAULT_SYSLOG_ASYNC}, @command{configure} variable
+ Additionally, you can instruct @command{mailfromd} to use
+asynchronous syslog by default. To do so, set
+@code{DEFAULT_SYSLOG_ASYNC} to 1, as shown in example below:
+
+@smallexample
+./configure --enable-syslog-async DEFAULT_SYSLOG_ASYNC=1
+@end smallexample
+
+ You will be able to override these defaults at run-time by using
+@option{--syslog-async} or @option{--no-syslog-async} command line options
+(@pxref{Logging and Debugging}).
+
@item Run @command{configure} with all the desired options.
For example, the following command:
@@ -975,6 +985,7 @@ the corresponding section below.
@end enumerate
@menu
+* 420-430:: Upgrading from 4.2 to 4.3
* 410-420:: Upgrading from 4.1 to 4.2
* 400-410:: Upgrading from 4.0 to 4.1
* 31x-400:: Upgrading from 3.1.x to 4.0
@@ -983,6 +994,19 @@ the corresponding section below.
* 1x-2x:: Upgrading from 1.x to 2.x
@end menu
+@node 420-430
+@section Upgrading from 4.2 to 4.3
+@cindex Upgrading from 4.2 to 4.3
+@cindex @code{DEFAULT_SYSLOG_ASYNC}, @command{configure} variable
+
+ The asynchronous syslog implementation was reported to malfunction
+on some systems (notably on Solaris), so this release does not enable
+it by default. The previous meaning of the @option{--enable-syslog-async}
+configuration option is also restored. Use this option in order to
+enable asynchronous syslog feature. To set default syslog
+implemetation, use @code{DEFAULT_SYSLOG_ASYNC} configuration variable
+(@pxref{syslog-async}).
+
@node 410-420
@section Upgrading from 4.1 to 4.2
@cindex Upgrading from 4.1 to 4.2
diff --git a/src/Makefile.am b/src/Makefile.am
index eb7efed5..9609c5bc 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -63,19 +63,21 @@ mailfromd_SOURCES = \
noinst_LIBRARIES=libmf.a
+SYSLOG_ASYNC_O=syslog_async.o
+
libmf_a_SOURCES=\
- syslog_async.c\
- syslog_async.h\
version.c
-libmf_a_LIBADD=$(LIBOBJS)
+libmf_a_LIBADD=$(LIBOBJS) $(BUILD_SYSLOG_ASYNC)
mailfromd_LDADD = ./libmf.a $(LDADD)
mtasim_SOURCES = mtasim.c openat-die.c
mtasim_LDADD = ./libmf.a $(LDADD) $(READLINE_LIBS)
-noinst_HEADERS = mailfromd.h mu_dbm.h builtin.h dns.h spf.h drivers.c debug.h
+noinst_HEADERS = mailfromd.h mu_dbm.h builtin.h dns.h spf.h drivers.c debug.h \
+ syslog_async.h
+
EXTRA_DIST = \
$(M4_FILES)\
builtin.def\
@@ -97,7 +99,8 @@ EXTRA_DIST = \
optab.oph\
snarf.m4\
status.mfh\
- status.mfi
+ status.mfi\
+ syslog_async.c
BUILT_SOURCES=\
$(M4_FILES:.m4=.c)\
diff --git a/src/bi_sieve.m4 b/src/bi_sieve.m4
index d018f9ce..f8551cb8 100644
--- a/src/bi_sieve.m4
+++ b/src/bi_sieve.m4
@@ -22,13 +22,23 @@
#define MF_SIEVE_DEBUG_MAILUTILS 0x08
#define MF_SIEVE_DEBUG_PROT 0x10
+#if MAILUTILS_VERSION_NUMBER < 1290
static int
-_mu_debug_printer (mu_debug_t unused, size_t level, const char *fmt,
- va_list ap)
+_mu_debug_printer(mu_debug_t unused, size_t level, const char *fmt,
+ va_list ap)
{
vlogmsg((level == MU_DEBUG_ERROR) ? LOG_ERR : LOG_DEBUG, fmt, ap);
return 0;
}
+typedef size_t mu_log_level_t;
+#else
+static int
+_mu_debug_printer(void *unused, mu_log_level_t level, const char *msg)
+{
+ logmsg((level == MU_DEBUG_ERROR) ? LOG_ERR : LOG_DEBUG, "%s", msg);
+ return 0;
+}
+#endif
static int
_sieve_debug_printer (void *unused, const char *fmt, va_list ap)
@@ -96,7 +106,7 @@ MF_DEFUN(sieve, NUMBER, STRING script, OPTIONAL, NUMBER dbg)
{
mu_sieve_machine_t mach;
mu_debug_t mudebug = NULL;
- int debug_flags = 0; /* FIXME: Init */
+ mu_log_level_t debug_flags = 0; /* FIXME: Init */
int sieve_debug_flags = 0;
int sieve_log = 0;
int rc = mu_sieve_machine_init(&mach, NULL);
@@ -131,7 +141,12 @@ MF_DEFUN(sieve, NUMBER, STRING script, OPTIONAL, NUMBER dbg)
mu_debug_set_print(mudebug, _mu_debug_printer, NULL);
}
+#if MAILUTILS_VERSION_NUMBER < 1290
mu_sieve_set_debug_level(mach, mudebug, sieve_debug_flags);
+#else
+ mu_sieve_set_debug_level(mach, sieve_debug_flags);
+ mu_sieve_set_debug_object(mach, mudebug);
+#endif
mu_sieve_set_parse_error(mach, _sieve_parse_error);
if (sieve_log)
mu_sieve_set_logger(mach, _sieve_action_log);
diff --git a/src/main.c b/src/main.c
index f09f34ec..121c73b9 100644
--- a/src/main.c
+++ b/src/main.c
@@ -42,8 +42,6 @@
#endif
#include "mailfromd.h"
-#include "syslog_async.h"
-
/* Configurable options */
@@ -81,8 +79,11 @@ int foreground; /* Stay in foreground */
int single_process_option; /* Run in single process mode. */
unsigned long source_address = INADDR_ANY; /* Source address for TCP
connections */
+#ifdef USE_SYSLOG_ASYNC
int use_syslog_async = DEFAULT_SYSLOG_ASYNC;
- /* Use asynchronous syslog implementation */
+ /* Use asynchronous syslog implementation */
+#endif
+
char *syslog_tag; /* Tag to mark syslog entries with. */
char *mailfromd_state_dir; /* see init_names() */
char *pidfile; /* see init_names() */
@@ -128,9 +129,12 @@ time_t response_timeout = 30;
int
syslog_printer (int prio, const char *fmt, va_list ap)
{
+#ifdef USE_SYSLOG_ASYNC
if (use_syslog_async) {
vsyslog_async (prio, fmt, ap);
- } else {
+ } else
+#endif
+ {
#if HAVE_VSYSLOG
vsyslog (prio, fmt, ap);
#else
@@ -142,6 +146,7 @@ syslog_printer (int prio, const char *fmt, va_list ap)
return 0;
}
+#ifdef USE_SYSLOG_ASYNC
void
mf_gacopyz_syslog_async_log_printer(int level, char *fmt, va_list ap)
{
@@ -165,6 +170,7 @@ mf_gacopyz_syslog_async_log_printer(int level, char *fmt, va_list ap)
}
vsyslog_async(level, fmt, ap);
}
+#endif
int
syslog_error_printer (const char *fmt, va_list ap)
@@ -1069,10 +1075,12 @@ static struct argp_option options[] = {
N_("Log to stderr"), GRP+1 },
{ "syslog", OPTION_SYSLOG, NULL, 0,
N_("Log to syslog (default)"), GRP+1 },
+#ifdef USE_SYSLOG_ASYNC
{ "syslog-async", OPTION_SYSLOG_ASYNC, NULL, 0,
N_("Use asynchronous syslog"), GRP+1 },
{ "no-syslog-async", OPTION_NO_SYSLOG_ASYNC, NULL, 0,
N_("Use system syslog"), GRP+1 },
+#endif
{ "log-tag", OPTION_LOG_TAG, N_("STRING"), 0,
N_("Set the identifier used in syslog messages to STRING"), GRP+1 },
{ "source-info", OPTION_SOURCE_INFO, NULL, 0,
@@ -1392,6 +1400,7 @@ parse_opt (int key, char *arg, struct argp_state *state)
log_to_stderr = 0;
break;
+#ifdef USE_SYSLOG_ASYNC
case OPTION_SYSLOG_ASYNC:
use_syslog_async = 1;
break;
@@ -1399,7 +1408,7 @@ parse_opt (int key, char *arg, struct argp_state *state)
case OPTION_NO_SYSLOG_ASYNC:
use_syslog_async = 0;
break;
-
+#endif
case OPTION_TIMEOUT:
set_option("timeout", arg, 1);
break;
@@ -1976,11 +1985,13 @@ mailfromd_show_defaults()
printf("statedir: %s\n", mailfromd_state_dir);
printf("socket: %s\n", portspec);
printf("pidfile: %s\n", pidfile);
+#ifdef USE_SYSLOG_ASYNC
#if DEFAULT_SYSLOG_ASYNC == 1
printf("default syslog: non-blocking\n");
#else
printf("default syslog: blocking\n");
#endif
+#endif
printf("database format: ");
#if defined WITH_GDBM
printf("GDBM");
@@ -1997,10 +2008,13 @@ log_setup(int want_stderr)
{
/* Set up logging */
if (!want_stderr) {
+#ifdef USE_SYSLOG_ASYNC
if (use_syslog_async) {
openlog_async(syslog_tag, LOG_PID, log_facility);
gacopyz_set_logger(mf_gacopyz_syslog_async_log_printer);
- } else {
+ } else
+#endif
+ {
openlog(syslog_tag, LOG_PID, log_facility);
gacopyz_set_logger(gacopyz_syslog_log_printer);
}
diff --git a/src/syslog_async.c b/src/syslog_async.c
index a168eac9..006cf16e 100644
--- a/src/syslog_async.c
+++ b/src/syslog_async.c
@@ -14,11 +14,16 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/file.h>
#include <sys/syslog.h>
+#include <netinet/in.h>
+#include <signal.h>
#include <sys/uio.h>
#include <sys/wait.h>
@@ -29,12 +34,29 @@
#include <errno.h>
#include <stdarg.h>
#include <stdlib.h>
-#include <paths.h>
+#ifdef HAVE_PATHS_H
+# include <paths.h>
+#else
+# define _PATH_LOG "/dev/log"
+# define _PATH_CONSOLE "/dev/console"
+#endif
#include <stdio.h>
#include <ctype.h>
#include "syslog_async.h"
+#ifndef MSG_NOSIGNAL
+# define MSG_NOSIGNAL 0
+#endif
+
+#ifndef LOG_PERROR
+# define LOG_PERROR 0
+#endif
+
+#ifndef LOG_PRI
+# define LOG_PRI(x) ((x) & LOG_PRIMASK)
+#endif
+
/* From RFC 3164 */
#define MAX_MESSAGE 1024
@@ -166,6 +188,10 @@ void log_write_async(void)
ssize_t rc;
int fd, tried_stream = 0;
struct log_entry *tmp;
+
+#if MSG_NOSIGNAL == 0
+ RETSIGTYPE (*sigfun) (int sig) = signal (SIGPIPE, SIG_IGN);
+#endif
while (entries)
{
@@ -194,13 +220,13 @@ void log_write_async(void)
continue;
if (errno == EAGAIN)
- return;
+ break;
/* *BSD, returns this instead of blocking? */
if (errno == ENOBUFS)
{
connection_good = 0;
- return;
+ break;
}
/* A stream socket closed at the other end goes into EPIPE
@@ -221,11 +247,12 @@ void log_write_async(void)
struct sockaddr_un logaddr;
- logaddr.sun_family = AF_LOCAL;
+ logaddr.sun_family = AF_UNIX;
strncpy(logaddr.sun_path, _PATH_LOG, sizeof(logaddr.sun_path));
/* Got connection back? try again. */
- if (connect(log_fd, (struct sockaddr *)&logaddr, sizeof(logaddr)) != -1)
+ if (connect(log_fd, (struct sockaddr *)&logaddr,
+ sizeof(logaddr)) != -1)
continue;
/* errors from connect which mean we should keep trying */
@@ -238,7 +265,7 @@ void log_write_async(void)
{
/* try again on next syslog() call */
connection_good = 0;
- return;
+ break;
}
/* we start with a SOCK_DGRAM socket, but syslog may want SOCK_STREAM */
@@ -289,6 +316,10 @@ void log_write_async(void)
}
continue;
}
+
+#if MSG_NOSIGNAL == 0
+ signal (SIGPIPE, sigfun);
+#endif
}
void syslog_async(int priority, const char *format, ...)

Return to:

Send suggestions and report system problems to the System administrator.