diff options
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | common/compat.c | 3 | ||||
-rw-r--r-- | common/smtppass.c | 34 | ||||
-rw-r--r-- | common/sock_any.c | 7 | ||||
-rw-r--r-- | common/stringx.c | 7 | ||||
-rw-r--r-- | configure.in | 4 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/clamsmtpd.c | 34 | ||||
-rw-r--r-- | src/compat.c | 3 | ||||
-rw-r--r-- | src/sock_any.c | 7 | ||||
-rw-r--r-- | src/util.c | 7 |
11 files changed, 75 insertions, 34 deletions
@@ -3,6 +3,7 @@ - Fixed crash when too many connections established - Announce ourselves as 'clamsmtp' in EHLO/HELO responses which fixes 'loopback' problems with certain versions of Postfix 1.x + - Fixed most warnings when compiled with -Wall - Fixed other minor bugs 0.6 diff --git a/common/compat.c b/common/compat.c index d3730e0..262f94d 100644 --- a/common/compat.c +++ b/common/compat.c @@ -68,6 +68,9 @@ #include "usuals.h" #include "compat.h" +#include <ctype.h> +#include <stdlib.h> + #ifndef HAVE_REALLOCF void* reallocf(void* ptr, size_t size) diff --git a/common/smtppass.c b/common/smtppass.c index a0e59cf..01a986b 100644 --- a/common/smtppass.c +++ b/common/smtppass.c @@ -42,14 +42,16 @@ #include <sys/param.h> #include <sys/stat.h> +#include <ctype.h> #include <paths.h> #include <stdio.h> -#include <pthread.h> #include <unistd.h> #include <fcntl.h> #include <syslog.h> #include <signal.h> #include <errno.h> +#include <err.h> +#include <pthread.h> #include "usuals.h" #include "compat.h" @@ -92,7 +94,9 @@ clamsmtp_thread_t; #define SMTP_DATA "DATA" CRLF #define SMTP_BANNER "220 clamsmtp" CRLF #define SMTP_HELO_RSP "250 clamsmtp" CRLF -#define SMTP_DELIMS "\r\n\t :-" +#define SMTP_EHLO_RSP "250-clamsmtp" CRLF +#define SMTP_DELIMS "\r\n\t :" +#define SMTP_MULTI_DELIMS " -" #define ESMTP_PIPELINE "PIPELINING" #define ESMTP_TLS "STARTTLS" @@ -169,7 +173,7 @@ pthread_mutexattr_t g_mutexattr; * FORWARD DECLARATIONS */ -static usage(); +static void usage(); static void on_quit(int signal); static void pid_file(const char* pid, int write); static void connection_loop(int sock); @@ -199,7 +203,6 @@ static int write_data_raw(clamsmtp_context_t* ctx, int* fd, unsigned char* buf, int main(int argc, char* argv[]) { const char* listensock = DEFAULT_SOCKET; - clamsmtp_thread_t* threads = NULL; struct sockaddr_any addr; char* pidfile = NULL; int daemonize = 1; @@ -385,7 +388,7 @@ static void on_quit(int signal) /* fprintf(stderr, "clamsmtpd: got signal to quit\n"); */ } -static int usage() +static void usage() { fprintf(stderr, "usage: clamsmtpd [-bq] [-c clamaddr] [-d debuglevel] [-D tmpdir] [-h header] " "[-l listenaddr] [-m maxconn] [-p pidfile] [-t timeout] serveraddr\n"); @@ -430,7 +433,6 @@ static void pid_file(const char* pidfile, int write) static void connection_loop(int sock) { clamsmtp_thread_t* threads = NULL; - struct sockaddr_any addr; int fd, i, x, r; /* Create the thread buffers */ @@ -863,7 +865,8 @@ static int smtp_passthru(clamsmtp_context_t* ctx) { filter_host = 0; - if(check_first_word(ctx->line, OK_RSP, KL(OK_RSP), SMTP_DELIMS) > 0) + /* Check for a simple '250 xxxx' */ + if(is_first_word(ctx->line, OK_RSP, KL(OK_RSP))) { messagex(ctx, LOG_DEBUG, "intercepting host response"); @@ -872,6 +875,17 @@ static int smtp_passthru(clamsmtp_context_t* ctx) continue; } + + /* Check for the continued response '250-xxxx' */ + if(check_first_word(ctx->line, OK_RSP, KL(OK_RSP), SMTP_MULTI_DELIMS) > 0) + { + messagex(ctx, LOG_DEBUG, "intercepting host response"); + + if(write_data(ctx, &(ctx->client), SMTP_EHLO_RSP) == -1) + RETURN(-1); + + continue; + } } /* @@ -880,7 +894,7 @@ static int smtp_passthru(clamsmtp_context_t* ctx) */ if(filter_ehlo) { - if((r = check_first_word(ctx->line, OK_RSP, KL(OK_RSP), SMTP_DELIMS)) > 0) + if((r = check_first_word(ctx->line, OK_RSP, KL(OK_RSP), SMTP_MULTI_DELIMS)) > 0) { char* p = ctx->line + r; if(is_first_word(p, ESMTP_PIPELINE, KL(ESMTP_PIPELINE)) || @@ -1079,7 +1093,6 @@ static int read_server_response(clamsmtp_context_t* ctx) static int connect_clam(clamsmtp_context_t* ctx) { - int r, len = -1; int ret = 0; ASSERT(ctx); @@ -1349,11 +1362,8 @@ cleanup: static int transfer_from_file(clamsmtp_context_t* ctx, const char* filename) { FILE* file = NULL; - const char* t; - const char* e; int header = 0; int ret = 0; - int len, r; file = fopen(filename, "r"); if(file == NULL) diff --git a/common/sock_any.c b/common/sock_any.c index 0018318..03621ff 100644 --- a/common/sock_any.c +++ b/common/sock_any.c @@ -36,12 +36,15 @@ * */ -#include <stdlib.h> -#include <errno.h> #include <sys/types.h> #include <sys/socket.h> + +#include <ctype.h> +#include <stdlib.h> +#include <errno.h> #include <netdb.h> #include <string.h> +#include <stdio.h> #include "sock_any.h" diff --git a/common/stringx.c b/common/stringx.c index a2bc90d..02e89f3 100644 --- a/common/stringx.c +++ b/common/stringx.c @@ -38,11 +38,16 @@ #include <sys/types.h> +#include <ctype.h> #include <syslog.h> #include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <errno.h> +#include <alloca.h> +#include <err.h> +#include <stdarg.h> +#include <strings.h> #include "usuals.h" #include "compat.h" @@ -62,7 +67,6 @@ static void vmessage(clamsmtp_context_t* ctx, int level, int err, size_t len; char* m; int e = errno; - int x; if(g_daemonized) { @@ -132,7 +136,6 @@ void log_fd_data(clamsmtp_context_t* ctx, const char* data, int* fd, int read) #define ptrdiff(o, t) char prefix[16]; - const char* t; ASSERT(ctx); ASSERT(ismember(ctx, fd)); diff --git a/configure.in b/configure.in index 8087d2b..4a32982 100644 --- a/configure.in +++ b/configure.in @@ -36,8 +36,8 @@ dnl Nate Nielsen <nielsen@memberwebs.com> dnl dnl Process this file with autoconf to produce a configure script. -AC_INIT(clamsmtp, 0.6.91, nielsen@memberwebs.com) -AM_INIT_AUTOMAKE(clamsmtp, 0.6.91) +AC_INIT(clamsmtp, 0.6.92, nielsen@memberwebs.com) +AM_INIT_AUTOMAKE(clamsmtp, 0.6.92) LDFLAGS="$LDFLAGS -L/usr/local/lib" CFLAGS="$CFLAGS -I/usr/local/include" diff --git a/src/Makefile.am b/src/Makefile.am index 28671aa..f312ff9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -4,6 +4,8 @@ sbin_PROGRAMS = clamsmtpd clamsmtpd_SOURCES = clamsmtpd.c clamsmtpd.h util.c util.h sock_any.h sock_any.c \ compat.c compat.h usuals.h +clamsmtpd_CFLAGS = -Wall + man_MANS = clamsmtpd.8 EXTRA_DIST = $(man_MANS) diff --git a/src/clamsmtpd.c b/src/clamsmtpd.c index a0e59cf..01a986b 100644 --- a/src/clamsmtpd.c +++ b/src/clamsmtpd.c @@ -42,14 +42,16 @@ #include <sys/param.h> #include <sys/stat.h> +#include <ctype.h> #include <paths.h> #include <stdio.h> -#include <pthread.h> #include <unistd.h> #include <fcntl.h> #include <syslog.h> #include <signal.h> #include <errno.h> +#include <err.h> +#include <pthread.h> #include "usuals.h" #include "compat.h" @@ -92,7 +94,9 @@ clamsmtp_thread_t; #define SMTP_DATA "DATA" CRLF #define SMTP_BANNER "220 clamsmtp" CRLF #define SMTP_HELO_RSP "250 clamsmtp" CRLF -#define SMTP_DELIMS "\r\n\t :-" +#define SMTP_EHLO_RSP "250-clamsmtp" CRLF +#define SMTP_DELIMS "\r\n\t :" +#define SMTP_MULTI_DELIMS " -" #define ESMTP_PIPELINE "PIPELINING" #define ESMTP_TLS "STARTTLS" @@ -169,7 +173,7 @@ pthread_mutexattr_t g_mutexattr; * FORWARD DECLARATIONS */ -static usage(); +static void usage(); static void on_quit(int signal); static void pid_file(const char* pid, int write); static void connection_loop(int sock); @@ -199,7 +203,6 @@ static int write_data_raw(clamsmtp_context_t* ctx, int* fd, unsigned char* buf, int main(int argc, char* argv[]) { const char* listensock = DEFAULT_SOCKET; - clamsmtp_thread_t* threads = NULL; struct sockaddr_any addr; char* pidfile = NULL; int daemonize = 1; @@ -385,7 +388,7 @@ static void on_quit(int signal) /* fprintf(stderr, "clamsmtpd: got signal to quit\n"); */ } -static int usage() +static void usage() { fprintf(stderr, "usage: clamsmtpd [-bq] [-c clamaddr] [-d debuglevel] [-D tmpdir] [-h header] " "[-l listenaddr] [-m maxconn] [-p pidfile] [-t timeout] serveraddr\n"); @@ -430,7 +433,6 @@ static void pid_file(const char* pidfile, int write) static void connection_loop(int sock) { clamsmtp_thread_t* threads = NULL; - struct sockaddr_any addr; int fd, i, x, r; /* Create the thread buffers */ @@ -863,7 +865,8 @@ static int smtp_passthru(clamsmtp_context_t* ctx) { filter_host = 0; - if(check_first_word(ctx->line, OK_RSP, KL(OK_RSP), SMTP_DELIMS) > 0) + /* Check for a simple '250 xxxx' */ + if(is_first_word(ctx->line, OK_RSP, KL(OK_RSP))) { messagex(ctx, LOG_DEBUG, "intercepting host response"); @@ -872,6 +875,17 @@ static int smtp_passthru(clamsmtp_context_t* ctx) continue; } + + /* Check for the continued response '250-xxxx' */ + if(check_first_word(ctx->line, OK_RSP, KL(OK_RSP), SMTP_MULTI_DELIMS) > 0) + { + messagex(ctx, LOG_DEBUG, "intercepting host response"); + + if(write_data(ctx, &(ctx->client), SMTP_EHLO_RSP) == -1) + RETURN(-1); + + continue; + } } /* @@ -880,7 +894,7 @@ static int smtp_passthru(clamsmtp_context_t* ctx) */ if(filter_ehlo) { - if((r = check_first_word(ctx->line, OK_RSP, KL(OK_RSP), SMTP_DELIMS)) > 0) + if((r = check_first_word(ctx->line, OK_RSP, KL(OK_RSP), SMTP_MULTI_DELIMS)) > 0) { char* p = ctx->line + r; if(is_first_word(p, ESMTP_PIPELINE, KL(ESMTP_PIPELINE)) || @@ -1079,7 +1093,6 @@ static int read_server_response(clamsmtp_context_t* ctx) static int connect_clam(clamsmtp_context_t* ctx) { - int r, len = -1; int ret = 0; ASSERT(ctx); @@ -1349,11 +1362,8 @@ cleanup: static int transfer_from_file(clamsmtp_context_t* ctx, const char* filename) { FILE* file = NULL; - const char* t; - const char* e; int header = 0; int ret = 0; - int len, r; file = fopen(filename, "r"); if(file == NULL) diff --git a/src/compat.c b/src/compat.c index d3730e0..262f94d 100644 --- a/src/compat.c +++ b/src/compat.c @@ -68,6 +68,9 @@ #include "usuals.h" #include "compat.h" +#include <ctype.h> +#include <stdlib.h> + #ifndef HAVE_REALLOCF void* reallocf(void* ptr, size_t size) diff --git a/src/sock_any.c b/src/sock_any.c index 0018318..03621ff 100644 --- a/src/sock_any.c +++ b/src/sock_any.c @@ -36,12 +36,15 @@ * */ -#include <stdlib.h> -#include <errno.h> #include <sys/types.h> #include <sys/socket.h> + +#include <ctype.h> +#include <stdlib.h> +#include <errno.h> #include <netdb.h> #include <string.h> +#include <stdio.h> #include "sock_any.h" @@ -38,11 +38,16 @@ #include <sys/types.h> +#include <ctype.h> #include <syslog.h> #include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <errno.h> +#include <alloca.h> +#include <err.h> +#include <stdarg.h> +#include <strings.h> #include "usuals.h" #include "compat.h" @@ -62,7 +67,6 @@ static void vmessage(clamsmtp_context_t* ctx, int level, int err, size_t len; char* m; int e = errno; - int x; if(g_daemonized) { @@ -132,7 +136,6 @@ void log_fd_data(clamsmtp_context_t* ctx, const char* data, int* fd, int read) #define ptrdiff(o, t) char prefix[16]; - const char* t; ASSERT(ctx); ASSERT(ismember(ctx, fd)); |