aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2007-12-12 13:19:02 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2007-12-12 13:19:02 +0000
commit57adf50a0299978606069e64b994e9bfb58ad701 (patch)
treedaf5506f682c93a5b6d64c79aa179e57ddf67ef0
parent0f78d4cebb75377eeb3c61e349e8eb088d9d88be (diff)
downloadmailfromd-57adf50a0299978606069e64b994e9bfb58ad701.tar.gz
mailfromd-57adf50a0299978606069e64b994e9bfb58ad701.tar.bz2
* 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. Raise version number to 4.2.1. * doc/mailfromd.texi: Reflect above-mentioned changes. * gacopyz/server.c, gacopyz/gacopyz.c: Rename all sun to s_un and sin to s_in, to avoid name clashes. * NEWS (4.2.1): New entry. git-svn-id: file:///svnroot/mailfromd/tags/release_4_2@1535 7a8a7f39-df28-0410-adc6-e0d955640f24
-rw-r--r--ChangeLog19
-rw-r--r--NEWS16
-rw-r--r--configure.ac31
-rw-r--r--doc/mailfromd.texi38
-rw-r--r--gacopyz/gacopyz.c18
-rw-r--r--gacopyz/server.c18
-rw-r--r--src/Makefile.am13
-rw-r--r--src/main.c26
-rw-r--r--src/syslog_async.c43
9 files changed, 162 insertions, 60 deletions
diff --git a/ChangeLog b/ChangeLog
index 0f5a8c39..894a1ff1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1 +1,20 @@
+2007-12-12 Sergey Poznyakoff <gray@gnu.org.ua>
+
+ * 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.
+ Raise version number to 4.2.1.
+
+ * doc/mailfromd.texi: Reflect above-mentioned changes.
+ * gacopyz/server.c, gacopyz/gacopyz.c: Rename all sun to s_un and
+ sin to s_in, to avoid name clashes.
+ * NEWS (4.2.1): New entry.
+
2007-10-23 Sergey Poznyakoff <gray@gnu.org.ua>
diff --git a/NEWS b/NEWS
index 578b9670..eedf4aea 100644
--- a/NEWS
+++ b/NEWS
@@ -1,2 +1,2 @@
-Mailfromd NEWS -- history of user-visible changes. 2007-10-23
+Mailfromd NEWS -- history of user-visible changes. 2007-12-12
Copyright (C) 2005, 2006, 2007 Sergey Poznyakoff
@@ -7,3 +7,13 @@ Please send mailfromd bug reports to <bug-mailfromd@gnu.org.ua>
-Version 4.2 (SVN)
+Version 4.2.1
+
+* 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
@@ -14,3 +24,3 @@ Version 4.2 (SVN)
These options allow to select the implementation of syslog to use
-at run time.
+at run time.
diff --git a/configure.ac b/configure.ac
index e49a654a..492f9487 100644
--- a/configure.ac
+++ b/configure.ac
@@ -19,3 +19,3 @@ m4_define([MF_VERSION_MAJOR], 4)
m4_define([MF_VERSION_MINOR], 2)
-dnl m4_define([MF_VERSION_PATCH], 0)
+m4_define([MF_VERSION_PATCH], 1)
AC_INIT([mailfromd],
@@ -49,3 +49,3 @@ AC_CHECK_LIB(resolv, res_query)
AC_HEADER_STDC
-AC_CHECK_HEADERS([stdlib.h unistd.h sysexits.h])
+AC_CHECK_HEADERS([stdlib.h unistd.h sysexits.h paths.h])
@@ -98,3 +98,4 @@ case $MAILUTILS_VERSION in
0.*) AC_MSG_ERROR([Mailutils version too old; at least 1.0 is required]);;
-1.1*) MAILUTILS_LIBS=`$MU_CONFIG --link auth`;;
+1.1|1.1.*) MAILUTILS_LIBS=`$MU_CONFIG --link auth`;;
+1.2) MAILUTILS_LIBS=`$MU_CONFIG --link auth`;;
*) MAILUTILS_LIBS=`$MU_CONFIG --link auth mailer`;;
@@ -129,3 +130,3 @@ 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
@@ -136,8 +137,12 @@ AC_ARG_ENABLE([syslog-async],
-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
@@ -575,3 +580,3 @@ 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
@@ -596,7 +601,3 @@ usereadline=$usereadline
rendition=$RENDITION
-if test "$syslog_async" = "yes"; then
- syslog_flavor="non-blocking"
-else
- syslog_flavor="standard"
-fi
+syslog_async=$syslog_async
])
diff --git a/doc/mailfromd.texi b/doc/mailfromd.texi
index 33d6b208..ec4e45b5 100644
--- a/doc/mailfromd.texi
+++ b/doc/mailfromd.texi
@@ -133,2 +133,3 @@ Building the Package
+* 420-421:: Upgrading from 4.2 to 4.2.1
* 410-420:: Upgrading from 4.1 to 4.2
@@ -911,8 +912,4 @@ lines are lost, this fact is logged with a message of the form:
- 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.:
@@ -922,2 +919,15 @@ using the @option{--enable-syslog-async} command line option:
+@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.
@@ -976,2 +986,3 @@ the corresponding section below.
@menu
+* 420-421:: Upgrading from 4.2 to 4.2.1
* 410-420:: Upgrading from 4.1 to 4.2
@@ -984,2 +995,15 @@ the corresponding section below.
+@node 420-421
+@section Upgrading from 4.2 to 4.2.1
+@cindex Upgrading from 4.2 to 4.2.1
+@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
@@ -987,3 +1011,3 @@ the corresponding section below.
@cindex Upgrading from 4.1 to 4.2
-@UNREVISED{}
+
Upgrading to this version does not require any special efforts. You
diff --git a/gacopyz/gacopyz.c b/gacopyz/gacopyz.c
index 1fff7edb..24f694e8 100644
--- a/gacopyz/gacopyz.c
+++ b/gacopyz/gacopyz.c
@@ -154,4 +154,4 @@ do_connect(gacopyz_conn_t conn,
struct sockaddr sa;
- struct sockaddr_in sin;
- struct sockaddr_un sun;
+ struct sockaddr_in s_in;
+ struct sockaddr_un s_un;
} addr;
@@ -173,3 +173,3 @@ do_connect(gacopyz_conn_t conn,
- if (strlen(path) > sizeof addr.sun.sun_path) {
+ if (strlen(path) > sizeof addr.s_un.sun_path) {
errno = EINVAL;
@@ -182,4 +182,4 @@ do_connect(gacopyz_conn_t conn,
addr.sa.sa_family = PF_UNIX;
- socklen = sizeof(addr.sun);
- strcpy(addr.sun.sun_path, path);
+ socklen = sizeof(addr.s_un);
+ strcpy(addr.s_un.sun_path, path);
@@ -219,3 +219,3 @@ do_connect(gacopyz_conn_t conn,
addr.sa.sa_family = PF_INET;
- socklen = sizeof(addr.sin);
+ socklen = sizeof(addr.s_in);
@@ -252,3 +252,3 @@ do_connect(gacopyz_conn_t conn,
if (!path)
- addr.sin.sin_addr.s_addr = INADDR_ANY;
+ addr.s_in.sin_addr.s_addr = INADDR_ANY;
else {
@@ -264,4 +264,4 @@ do_connect(gacopyz_conn_t conn,
case AF_INET:
- memmove(&addr.sin.sin_addr, hp->h_addr, 4);
- addr.sin.sin_port = pnum;
+ memmove(&addr.s_in.sin_addr, hp->h_addr, 4);
+ addr.s_in.sin_port = pnum;
break;
diff --git a/gacopyz/server.c b/gacopyz/server.c
index 401854b2..a4a05e49 100644
--- a/gacopyz/server.c
+++ b/gacopyz/server.c
@@ -650,4 +650,4 @@ srv_connect(gacopyz_srv_t srv, char *proto, char *port, char *path)
struct sockaddr sa;
- struct sockaddr_in sin;
- struct sockaddr_un sun;
+ struct sockaddr_in s_in;
+ struct sockaddr_un s_un;
} addr;
@@ -668,3 +668,3 @@ srv_connect(gacopyz_srv_t srv, char *proto, char *port, char *path)
- if (strlen(path) > sizeof addr.sun.sun_path) {
+ if (strlen(path) > sizeof addr.s_un.sun_path) {
errno = EINVAL;
@@ -677,4 +677,4 @@ srv_connect(gacopyz_srv_t srv, char *proto, char *port, char *path)
addr.sa.sa_family = PF_UNIX;
- socklen = sizeof(addr.sun);
- strcpy(addr.sun.sun_path, path);
+ socklen = sizeof(addr.s_un);
+ strcpy(addr.s_un.sun_path, path);
@@ -701,3 +701,3 @@ srv_connect(gacopyz_srv_t srv, char *proto, char *port, char *path)
addr.sa.sa_family = PF_INET;
- socklen = sizeof(addr.sin);
+ socklen = sizeof(addr.s_in);
@@ -734,3 +734,3 @@ srv_connect(gacopyz_srv_t srv, char *proto, char *port, char *path)
if (!path)
- addr.sin.sin_addr.s_addr = INADDR_ANY;
+ addr.s_in.sin_addr.s_addr = INADDR_ANY;
else {
@@ -746,4 +746,4 @@ srv_connect(gacopyz_srv_t srv, char *proto, char *port, char *path)
case AF_INET:
- memmove(&addr.sin.sin_addr, hp->h_addr, 4);
- addr.sin.sin_port = pnum;
+ memmove(&addr.s_in.sin_addr, hp->h_addr, 4);
+ addr.s_in.sin_port = pnum;
break;
diff --git a/src/Makefile.am b/src/Makefile.am
index ea504d53..1aa7fdb5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -64,8 +64,8 @@ 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)
@@ -76,3 +76,5 @@ 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 = \
@@ -98,3 +100,4 @@ EXTRA_DIST = \
status.mfh\
- status.mfi
+ status.mfi\
+ syslog_async.c
diff --git a/src/main.c b/src/main.c
index 938a82b6..cec23145 100644
--- a/src/main.c
+++ b/src/main.c
@@ -41,4 +41,2 @@
-#include "syslog_async.h"
-
@@ -80,4 +78,7 @@ 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. */
@@ -127,5 +128,8 @@ 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
@@ -141,2 +145,3 @@ syslog_printer (int prio, const char *fmt, va_list ap)
+#ifdef USE_SYSLOG_ASYNC
void
@@ -164,2 +169,3 @@ mf_gacopyz_syslog_async_log_printer(int level, char *fmt, va_list ap)
}
+#endif
@@ -980,2 +986,3 @@ static struct argp_option options[] = {
N_("Log to syslog (default)"), GRP+1 },
+#ifdef USE_SYSLOG_ASYNC
{ "syslog-async", OPTION_SYSLOG_ASYNC, NULL, 0,
@@ -984,2 +991,3 @@ static struct argp_option options[] = {
N_("Use system syslog"), GRP+1 },
+#endif
{ "log-tag", OPTION_LOG_TAG, N_("STRING"), 0,
@@ -1303,2 +1311,3 @@ parse_opt (int key, char *arg, struct argp_state *state)
+#ifdef USE_SYSLOG_ASYNC
case OPTION_SYSLOG_ASYNC:
@@ -1310,3 +1319,3 @@ parse_opt (int key, char *arg, struct argp_state *state)
break;
-
+#endif
case OPTION_TIMEOUT:
@@ -1704,2 +1713,3 @@ mailfromd_show_defaults()
printf("pidfile: %s\n", pidfile);
+#ifdef USE_SYSLOG_ASYNC
#if DEFAULT_SYSLOG_ASYNC == 1
@@ -1709,2 +1719,3 @@ mailfromd_show_defaults()
#endif
+#endif
printf("database format: ");
@@ -1725,2 +1736,3 @@ log_setup(int want_stderr)
if (!want_stderr) {
+#ifdef USE_SYSLOG_ASYNC
if (use_syslog_async) {
@@ -1728,3 +1740,5 @@ log_setup(int want_stderr)
gacopyz_set_logger(mf_gacopyz_syslog_async_log_printer);
- } else {
+ } else
+#endif
+ {
openlog(syslog_tag, LOG_PID, log_facility);
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
@@ -16,2 +16,5 @@
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
#include <sys/types.h>
@@ -21,2 +24,4 @@
#include <sys/syslog.h>
+#include <netinet/in.h>
+#include <signal.h>
@@ -31,3 +36,8 @@
#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>
@@ -37,2 +47,14 @@
+#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 */
@@ -168,2 +190,6 @@ void log_write_async(void)
struct log_entry *tmp;
+
+#if MSG_NOSIGNAL == 0
+ RETSIGTYPE (*sigfun) (int sig) = signal (SIGPIPE, SIG_IGN);
+#endif
@@ -196,3 +222,3 @@ void log_write_async(void)
if (errno == EAGAIN)
- return;
+ break;
@@ -202,3 +228,3 @@ void log_write_async(void)
connection_good = 0;
- return;
+ break;
}
@@ -223,3 +249,3 @@ void log_write_async(void)
- logaddr.sun_family = AF_LOCAL;
+ logaddr.sun_family = AF_UNIX;
strncpy(logaddr.sun_path, _PATH_LOG, sizeof(logaddr.sun_path));
@@ -227,3 +253,4 @@ void log_write_async(void)
/* 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;
@@ -240,3 +267,3 @@ void log_write_async(void)
connection_good = 0;
- return;
+ break;
}
@@ -291,2 +318,6 @@ void log_write_async(void)
}
+
+#if MSG_NOSIGNAL == 0
+ signal (SIGPIPE, sigfun);
+#endif
}

Return to:

Send suggestions and report system problems to the System administrator.