diff options
author | Stef Walter <stef@thewalter.net> | 2010-11-02 15:47:38 +0000 |
---|---|---|
committer | Stef Walter <stef@thewalter.net> | 2011-01-23 15:47:45 -0600 |
commit | 32f0912fd6df69808bc25f012ce7694243025a35 (patch) | |
tree | 38b8cf22d612d6f6ed85beb4ba57a28619ed96ed /common/smtppass.c | |
parent | 5e0d08fd4309e37120ec851bfc2c2cb06c776964 (diff) |
Track client authentication correctly.
Diffstat (limited to 'common/smtppass.c')
-rw-r--r-- | common/smtppass.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/common/smtppass.c b/common/smtppass.c index d9b8cb5..7fcafd0 100644 --- a/common/smtppass.c +++ b/common/smtppass.c @@ -134,12 +134,14 @@ spthread_t; #define BDAT_CMD "BDAT" #define XCLIENT_CMD "XCLIENT" #define XFORWARD_CMD "XFORWARD" +#define AUTH_CMD "AUTH" #define DATA_END_SIG "." CRLF #define DATA_RSP "354" #define OK_RSP "250" #define START_RSP "220" +#define AUTH_SUCCESS_RSP "235" #define RCVD_HEADER "Received:" @@ -893,6 +895,7 @@ static int smtp_passthru(spctx_t* ctx) int first_rsp = 1; /* The first 220 response from server to be filtered */ int filter_host = 0; /* Next response is 250 hostname, which we change */ + int auth_started = 0; /* Started performing authentication */ /* XCLIENT is for use in access control */ int xclient_sup = 0; /* Is XCLIENT supported? */ @@ -1038,6 +1041,12 @@ static int smtp_passthru(spctx_t* ctx) continue; } + else if(is_first_word(C_LINE, AUTH_CMD, KL(AUTH_CMD))) + { + sp_messagex(ctx, LOG_DEBUG, "Tracking authentication"); + auth_started = 1; + } + /* All other commands just get passed through to server */ if(spio_write_data(ctx, &(ctx->server), C_LINE) == -1) RETURN(-1); @@ -1211,6 +1220,20 @@ static int smtp_passthru(spctx_t* ctx) { cleanup_context(ctx); } + + /* Successful authentication */ + else if(is_first_word(S_LINE, AUTH_SUCCESS_RSP, KL(AUTH_SUCCESS_RSP))) + { + if(auth_started) + { + sp_messagex(ctx, LOG_DEBUG, "Client authenticated successfully"); + ctx->authenticated = 1; + } + else + { + sp_messagex(ctx, LOG_WARNING, "Authentication success code without AUTH"); + } + } } if(spio_write_data(ctx, &(ctx->client), S_LINE) == -1) |