summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/smtppass.c33
-rw-r--r--common/smtppass.h2
-rw-r--r--common/sppriv.h1
3 files changed, 15 insertions, 21 deletions
diff --git a/common/smtppass.c b/common/smtppass.c
index 638e80d..7844879 100644
--- a/common/smtppass.c
+++ b/common/smtppass.c
@@ -161,7 +161,6 @@ spthread_t;
#define CFG_TIMEOUT "TimeOut"
#define CFG_OUTADDR "OutAddress"
#define CFG_LISTENADDR "Listen"
-#define CFG_HEADER "Header"
#define CFG_TRANSPARENT "TransparentProxy"
#define CFG_DIRECTORY "TempDirectory"
#define CFG_KEEPALIVES "KeepAlives"
@@ -1488,13 +1487,14 @@ static int make_header(spctx_t* ctx, const char* format_str, char* header)
return l >= MAX_HEADER_LENGTH ? MAX_HEADER_LENGTH - 1 : l;
}
-int sp_done_data(spctx_t* ctx)
+int sp_done_data(spctx_t* ctx, const char *headertmpl)
{
FILE* file = 0;
int ret = 0;
char *line;
char header[MAX_HEADER_LENGTH] = "";
size_t header_len, line_len;
+ int header_prepend = 0;
ssize_t rc;
ASSERT(ctx->cachename[0]); /* Must still be around */
@@ -1535,16 +1535,21 @@ int sp_done_data(spctx_t* ctx)
sp_messagex(ctx, LOG_DEBUG, "sending from cache file: %s", ctx->cachename);
- if(g_state.header)
- header_len = make_header(ctx, g_state.header, header);
+ if(headertmpl)
+ {
+ header_len = make_header(ctx, headertmpl, header);
+ if(is_first_word(RCVD_HEADER, header, KL(RCVD_HEADER)))
+ header_prepend = 1;
+ }
+
/* If we have to prepend the header, do it */
- if(header[0] != '\0' && g_state.header_prepend)
+ if(header[0] != '\0' && header_prepend)
{
- if(spio_write_data_raw(ctx, &(ctx->server), (unsigned char*)header, header_len) == -1 ||
- spio_write_data_raw(ctx, &(ctx->server), (unsigned char*)CRLF, KL(CRLF)) == -1)
- RETURN(-1);
- header[0] = '\0';
+ if(spio_write_data_raw(ctx, &(ctx->server), (unsigned char*)header, header_len) == -1 ||
+ spio_write_data_raw(ctx, &(ctx->server), (unsigned char*)CRLF, KL(CRLF)) == -1)
+ RETURN(-1);
+ header[0] = '\0';
}
/* Transfer actual file data */
@@ -1918,16 +1923,6 @@ int sp_parse_option(const char* name, const char* value)
ret = 1;
}
- else if(strcasecmp(CFG_HEADER, name) == 0)
- {
- g_state.header = trim_start(value);
- if(strlen(g_state.header) == 0)
- g_state.header = NULL;
- else if(is_first_word(RCVD_HEADER, g_state.header, KL(RCVD_HEADER)))
- g_state.header_prepend = 1;
- ret = 1;
- }
-
/* Always pass through to program */
if(cb_parse_option(name, value) == 1)
ret = 1;
diff --git a/common/smtppass.h b/common/smtppass.h
index 701ecb9..7c76225 100644
--- a/common/smtppass.h
+++ b/common/smtppass.h
@@ -213,7 +213,7 @@ int sp_cache_data(spctx_t* ctx);
* Sends the data in file buffer off to server. This is
* completes a successful mail transfer.
*/
-int sp_done_data(spctx_t* ctx);
+int sp_done_data(spctx_t* ctx, const char *header);
/*
* Fails the data, deletes any temp data, and sends given
diff --git a/common/sppriv.h b/common/sppriv.h
index a690f3c..edfd217 100644
--- a/common/sppriv.h
+++ b/common/sppriv.h
@@ -54,7 +54,6 @@ typedef struct spstate
const char* user; /* User to run as */
const char* pidfile; /* The pid file for daemon */
const char* header; /* A header to include in the email */
- int header_prepend; /* Prepend the header or not */
struct sockaddr_any outaddr; /* The outgoing address */
const char* outname;