aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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,3 +1,22 @@
+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>
* doc/mailfromd.texi: Do not use subheading commands inside of
diff --git a/NEWS b/NEWS
index 578b9670..eedf4aea 100644
--- a/NEWS
+++ b/NEWS
@@ -1,18 +1,28 @@
-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
See the end of file for copying conditions.
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
* Licensed under the GPLv3
* 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 e49a654a..492f9487 100644
--- a/configure.ac
+++ b/configure.ac
@@ -17,7 +17,7 @@
AC_PREREQ(2.59)
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],
MF_VERSION_MAJOR.MF_VERSION_MINOR[]m4_ifdef([MF_VERSION_PATCH],.MF_VERSION_PATCH),
[bug-mailfromd@gnu.org.ua])
@@ -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
@@ -96,7 +96,8 @@ AC_SUBST(MAILUTILS_LIBS)
MAILUTILS_VERSION=`$MU_CONFIG --info version|sed 's/VERSION=//'`
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`;;
esac
MAILUTILS_INCLUDES=`$MU_CONFIG --compile`
@@ -127,19 +128,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
@@ -573,7 +578,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
*******************************************************************
@@ -594,11 +599,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 33d6b208..ec4e45b5 100644
--- a/doc/mailfromd.texi
+++ b/doc/mailfromd.texi
@@ -131,6 +131,7 @@ Sender Address Verification.
Building the Package
+* 420-421:: Upgrading from 4.2 to 4.2.1
* 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
@@ -909,17 +910,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:
@@ -974,6 +984,7 @@ the corresponding section below.
@end enumerate
@menu
+* 420-421:: Upgrading from 4.2 to 4.2.1
* 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
@@ -982,10 +993,23 @@ the corresponding section below.
* 1x-2x:: Upgrading from 1.x to 2.x
@end menu
+@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
@section Upgrading from 4.1 to 4.2
@cindex Upgrading from 4.1 to 4.2
-@UNREVISED{}
+
Upgrading to this version does not require any special efforts. You
can use your configuration files and filter scripts without any
changes. The only difference worth noticing is that starting from this
diff --git a/gacopyz/gacopyz.c b/gacopyz/gacopyz.c
index 1fff7edb..24f694e8 100644
--- a/gacopyz/gacopyz.c
+++ b/gacopyz/gacopyz.c
@@ -152,8 +152,8 @@ do_connect(gacopyz_conn_t conn,
{
union {
struct sockaddr sa;
- struct sockaddr_in sin;
- struct sockaddr_un sun;
+ struct sockaddr_in s_in;
+ struct sockaddr_un s_un;
} addr;
int socklen;
int fd, flags;
@@ -171,7 +171,7 @@ do_connect(gacopyz_conn_t conn,
return -1;
}
- if (strlen(path) > sizeof addr.sun.sun_path) {
+ if (strlen(path) > sizeof addr.s_un.sun_path) {
errno = EINVAL;
gacopyz_log(conn, SMI_LOG_ERR,
_("%s: %s: UNIX socket name too long"),
@@ -180,8 +180,8 @@ 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);
if (stat(path, &st)) {
if (errno == ENOENT) {
@@ -217,7 +217,7 @@ do_connect(gacopyz_conn_t conn,
char *p;
addr.sa.sa_family = PF_INET;
- socklen = sizeof(addr.sin);
+ socklen = sizeof(addr.s_in);
if (!port) {
gacopyz_log(conn, SMI_LOG_ERR,
@@ -250,7 +250,7 @@ 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 {
struct hostent *hp = gethostbyname(path);
if (!hp) {
@@ -262,8 +262,8 @@ do_connect(gacopyz_conn_t conn,
addr.sa.sa_family = hp->h_addrtype;
switch (hp->h_addrtype) {
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;
default:
diff --git a/gacopyz/server.c b/gacopyz/server.c
index 401854b2..a4a05e49 100644
--- a/gacopyz/server.c
+++ b/gacopyz/server.c
@@ -648,8 +648,8 @@ srv_connect(gacopyz_srv_t srv, char *proto, char *port, char *path)
{
union {
struct sockaddr sa;
- struct sockaddr_in sin;
- struct sockaddr_un sun;
+ struct sockaddr_in s_in;
+ struct sockaddr_un s_un;
} addr;
int socklen;
int fd = -1;
@@ -666,7 +666,7 @@ srv_connect(gacopyz_srv_t srv, char *proto, char *port, char *path)
return -1;
}
- if (strlen(path) > sizeof addr.sun.sun_path) {
+ if (strlen(path) > sizeof addr.s_un.sun_path) {
errno = EINVAL;
gacopyz_io_log(&srv->iod, SMI_LOG_ERR,
_("%s: UNIX socket name too long"),
@@ -675,8 +675,8 @@ 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);
if (stat(path, &st)) {
gacopyz_io_log(&srv->iod, SMI_LOG_ERR,
@@ -699,7 +699,7 @@ srv_connect(gacopyz_srv_t srv, char *proto, char *port, char *path)
char *p;
addr.sa.sa_family = PF_INET;
- socklen = sizeof(addr.sin);
+ socklen = sizeof(addr.s_in);
if (!port) {
gacopyz_io_log(&srv->iod, SMI_LOG_ERR,
@@ -732,7 +732,7 @@ 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 {
struct hostent *hp = gethostbyname(path);
if (!hp) {
@@ -744,8 +744,8 @@ srv_connect(gacopyz_srv_t srv, char *proto, char *port, char *path)
addr.sa.sa_family = hp->h_addrtype;
switch (hp->h_addrtype) {
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;
default:
diff --git a/src/Makefile.am b/src/Makefile.am
index ea504d53..1aa7fdb5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -62,19 +62,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\
@@ -96,7 +98,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/main.c b/src/main.c
index 938a82b6..cec23145 100644
--- a/src/main.c
+++ b/src/main.c
@@ -39,8 +39,6 @@
#include "mailfromd.h"
-#include "syslog_async.h"
-
/* Configurable options */
@@ -78,8 +76,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() */
@@ -125,9 +126,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
@@ -139,6 +143,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)
{
@@ -162,6 +167,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)
@@ -978,10 +984,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,
@@ -1301,6 +1309,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;
@@ -1308,7 +1317,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;
@@ -1702,11 +1711,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");
@@ -1723,10 +1734,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.