Index: ossp-pkg/lmtp2nntp/00TODO RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/00TODO,v rcsdiff -q -kk '-r1.55' '-r1.56' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/00TODO,v' 2>/dev/null --- 00TODO 2002/02/13 16:25:38 1.55 +++ 00TODO 2002/03/04 15:54:28 1.56 @@ -101,24 +101,6 @@ -h [pri]:[regex]:header:[val] - # merge values from duplicate headers and separte them with "comma space" - -h :(Reply-To|To|Cc|Bcc):$0: [%{$0[#]}%{$0[#+1]:+, }] - - # keep only first value from duplicate headers - -h :(X-Firstonly):$0: %{$0[0]} - - # replace empty Subject with text "None" - -h :Subject: %{$Subject:-None} - - # create Message-ID if omitted or illegal (<> single @) - -h :Messageid: %{messagid:s/^([^@+@[^@]+)$/<$1/:s/^[^<].*$/%{tool.createmessageid}/} - - # append a header - -h ::X-Append: Tail - - # remove a header (empty value) - -h ::X-Delete: - foreach rule { if (rule has regex) { foreach header { Index: ossp-pkg/lmtp2nntp/README RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/README,v rcsdiff -q -kk '-r1.16' '-r1.17' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/README,v' 2>/dev/null --- README 2001/12/31 15:15:36 1.16 +++ README 2002/03/04 15:54:28 1.17 @@ -7,7 +7,7 @@ |_| |_| OSSP lmtp2nntp - Mail to News Gateway - Version 1.2a2 (31-Dec-2001) + Version 1.2a3 (04-Mar-2002) ABSTRACT Index: ossp-pkg/lmtp2nntp/example.conf RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/Attic/example.conf,v rcsdiff -q -kk '-r1.15' '-r1.16' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/Attic/example.conf,v' 2>/dev/null --- example.conf 2002/01/31 15:54:53 1.15 +++ example.conf 2002/03/04 15:54:28 1.16 @@ -53,3 +53,25 @@ version #see -v aka --version newsgroup "test" newsgroup "alt.test" #see man page for information about newsgroup + + + ### CRUCIAL GATEWAY HEADER REWRITE RULES ### + +# merge values from duplicate headers and separte them with "comma space" +headerrule 500:(Reply-To|To|Cc|Bcc):$0: [%{$0[#]}%{$0[#+1]:+, }] + +# keep only first value from duplicate headers +headerrule 510:(X-Firstonly):$0: %{$0[0]} + +# replace empty Subject with text "None" +headerrule 520:Subject: %{$Subject:-None} + +# create Message-ID if omitted or illegal (<> single @) +headerrule 530:Messageid: %{messagid:s/^([^@+@[^@]+)$/<$1/:s/^[^<].*$/%{tool.createmessageid}/} + +# append a header +headerrule 540::X-Append: Tail + +# remove a header (empty value) +headerrule 550::X-Delete: + Index: ossp-pkg/lmtp2nntp/fixme.h RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/Attic/fixme.h,v rcsdiff -q -kk '-r1.19' '-r1.20' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/Attic/fixme.h,v' 2>/dev/null --- fixme.h 2002/02/28 12:57:55 1.19 +++ fixme.h 2002/03/04 15:54:28 1.20 @@ -67,13 +67,7 @@ char *option_operationmodefakestatus; char *option_operationmodefakedsn; int option_maxmessagesize; - headerrule_t *option_firstheaderrule; - /* FIXME obsolete */ - char *azHeaderValuePairs; - size_t asHeaderValuePairs; - - int option_timeout_lmtp_accept; int option_timeout_lmtp_read; int option_timeout_lmtp_write; @@ -128,4 +122,8 @@ OPERATIONMODE_FEED }; +void msg_headermatrixbuildup(msg_t *msg); +void msg_headermatrixteardwn(msg_t *msg); +void headerrewrite(lmtp2nntp_t *ctx); + #endif /* __FIXME_H__ */ Index: ossp-pkg/lmtp2nntp/lmtp2nntp_config.c RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_config.c,v rcsdiff -q -kk '-r1.63' '-r1.64' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_config.c,v' 2>/dev/null --- lmtp2nntp_config.c 2002/02/28 15:57:09 1.63 +++ lmtp2nntp_config.c 2002/03/04 15:54:28 1.64 @@ -104,10 +104,6 @@ return L2_OK; } -static void msg_headermatrixbuildup(msg_t *msg); -static void msg_headermatrixteardwn(msg_t *msg); -static void headerrewrite(lmtp2nntp_t *ctx); - static var_syntax_t syntax_regex = { '\\', /* escape */ '$', /* varinit */ @@ -1250,7 +1246,7 @@ return rc; } -static void msg_headermatrixbuildup(msg_t *msg) +void msg_headermatrixbuildup(msg_t *msg) { ex_t ex; volatile headerdata_t *hdNew = NULL; @@ -1313,7 +1309,7 @@ } } -static void msg_headermatrixteardwn(msg_t *msg) +void msg_headermatrixteardwn(msg_t *msg) { ex_t ex; try { @@ -1351,7 +1347,7 @@ } } -static void headerrewrite(lmtp2nntp_t *ctx) +void headerrewrite(lmtp2nntp_t *ctx) { headerrule_t *hrI; headerdata_t *hdI, *hdNew; @@ -1360,6 +1356,10 @@ int ovec[OVECSIZE]; var_rc_t rc; char *cp; //FIXME what a bad name, it's not the returncode of this function + /* short circuit in case no headerrules were set up */ + if (ctx->option_firstheaderrule == NULL) + return; + { //FIXME debug code block int i; headerrule_t *hrD; Index: ossp-pkg/lmtp2nntp/lmtp2nntp_main.c RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_main.c,v rcsdiff -q -kk '-r1.45' '-r1.46' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_main.c,v' 2>/dev/null --- lmtp2nntp_main.c 2002/02/28 15:57:09 1.45 +++ lmtp2nntp_main.c 2002/03/04 15:54:28 1.46 @@ -368,8 +368,6 @@ ctx->option_operationmodefakedsn = NULL; ctx->option_maxmessagesize = 0; ctx->option_firstheaderrule = NULL; - ctx->azHeaderValuePairs = NULL; //FIXME obsolete - ctx->asHeaderValuePairs = 0; //FIXME obsolete ctx->option_timeout_lmtp_accept = 0; ctx->option_timeout_lmtp_read = 0; ctx->option_timeout_lmtp_write = 0; @@ -437,7 +435,6 @@ (void)option_create(&o, ctx->val); /* FIXME */ (void)option_parse(o, argc, argv); (void)config_context(ctx); - CU(0); //FIXME if (getuid() != ctx->option_uid) { if (setuid(ctx->option_uid) == -1) { @@ -676,8 +673,7 @@ sa_addr_destroy(ctx->saaServerbind); if (ctx->option_restrictheader != NULL) free(ctx->option_restrictheader); - if (ctx->azHeaderValuePairs != NULL) - free(ctx->azHeaderValuePairs); + //FIXME if (ctx->azHeaderValuePairs != NULL) free(ctx->azHeaderValuePairs); what about headerrules if (ctx->option_pidfile != NULL) free(ctx->option_pidfile); if (ctx->progname != NULL) @@ -1476,22 +1472,11 @@ } } - /* Optionally add command line specified Header/Value Pairs - */ - log0(ctx, TRACE, "adding header/value pairs"); - - cp = NULL; - while ((cp = argz_next(ctx->azHeaderValuePairs, ctx->asHeaderValuePairs, cp)) != NULL) { - var_rc_t var_rc; - char *res_ptr; - if ((var_rc = var_expand(ctx->config_varctx, cp, strlen(cp), &res_ptr, NULL, TRUE)) != VAR_OK) { - log3(ctx, ERROR, "expansion of '%s' failed: %s (%d)", cp, var_strerror(ctx->config_varctx, rc, &cp) == VAR_OK ? cp : "Unknown Error", rc); - continue; - } - log1(ctx, DEBUG, "adding expanded header: \"%s\"", res_ptr); - argz_add(&ctx->msg->azHeaders, &ctx->msg->asHeaders, res_ptr); - free(res_ptr); - } + /* rewrite headers */ + log0(ctx, TRACE, "appying header rewrite rules"); + msg_headermatrixbuildup(ctx->msg); + headerrewrite(ctx); + msg_headermatrixteardwn(ctx->msg); /* RFC0821 4.2.1. REPLY CODES BY FUNCTION GROUPS 554 Transaction failed * RFC1893 2. Status Codes 5.X.X Permanent Failure @@ -1616,11 +1601,10 @@ for (i = 0; i < ctx->nns; i++) { if (ctx->pns[i].rc != NNTP_OK) { str_format(errorstring, sizeof(errorstring), - "${option.destination}[${i}] returned %s\n" /*FIXME*/ - "${option.destination}[${i}] lastresp \"%s\"", /*FIXME*/ - i, - nntp_error(ctx->pns[i].rc), - nntp_lastresp(ctx->pns[i].nntp)); + "${option.destination}[%d] returned %s\n" /*FIXME*/ + "${option.destination}[%d] lastresp \"%s\"", /*FIXME*/ + i, nntp_error(ctx->pns[i].rc), + i, nntp_lastresp(ctx->pns[i].nntp)); argz_add(&azErr, &asErr, errorstring); } } Index: ossp-pkg/lmtp2nntp/lmtp2nntp_version.c RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_version.c,v rcsdiff -q -kk '-r1.2' '-r1.3' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_version.c,v' 2>/dev/null --- lmtp2nntp_version.c 2001/12/31 12:03:09 1.2 +++ lmtp2nntp_version.c 2002/03/04 15:54:28 1.3 @@ -8,7 +8,7 @@ #ifndef _LMTP2NNTP_VERSION_C_ #define _LMTP2NNTP_VERSION_C_ -#define LMTP2NNTP_VERSION 0x102002 +#define LMTP2NNTP_VERSION 0x102003 typedef struct { const int v_hex; @@ -32,13 +32,13 @@ #undef _LMTP2NNTP_VERSION_C_AS_HEADER_ lmtp2nntp_version_t lmtp2nntp_version = { - 0x102002, - "1.2a2", - "1.2a2 (31-Dec-2001)", - "This is OSSP lmtp2nntp, Version 1.2a2 (31-Dec-2001)", - "OSSP lmtp2nntp 1.2a2 (31-Dec-2001)", - "OSSP lmtp2nntp/1.2a2", - "@(#)OSSP lmtp2nntp 1.2a2 (31-Dec-2001)", + 0x102003, + "1.2a3", + "1.2a3 (04-Mar-2002)", + "This is OSSP lmtp2nntp, Version 1.2a3 (04-Mar-2002)", + "OSSP lmtp2nntp 1.2a3 (04-Mar-2002)", + "OSSP lmtp2nntp/1.2a3", + "@(#)OSSP lmtp2nntp 1.2a3 (04-Mar-2002)", "$Id$" }; Index: ossp-pkg/lmtp2nntp/test.sh RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/test.sh,v rcsdiff -q -kk '-r1.12' '-r1.13' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/test.sh,v' 2>/dev/null --- test.sh 2002/02/07 13:39:38 1.12 +++ test.sh 2002/03/04 15:54:28 1.13 @@ -126,7 +126,7 @@ if [ 1 -eq `egrep <${STDOUT} -- '-c.*--client' | wc -l` ]; then RC="${RC}-c "; fi if [ 1 -eq `egrep <${STDOUT} -- '-d.*--destination' | wc -l` ]; then RC="${RC}-d "; fi if [ 1 -eq `egrep <${STDOUT} -- '-g.*--groupmode' | wc -l` ]; then RC="${RC}-g "; fi -if [ 1 -eq `egrep <${STDOUT} -- '-h.*--headervalue' | wc -l` ]; then RC="${RC}-h "; fi +if [ 1 -eq `egrep <${STDOUT} -- '-h.*--headerrule' | wc -l` ]; then RC="${RC}-h "; fi if [ 1 -eq `egrep <${STDOUT} -- '-i.*--include' | wc -l` ]; then RC="${RC}-i "; fi if [ 1 -eq `egrep <${STDOUT} -- '--timeoutlmtp' | wc -l` ]; then RC="${RC}--timeoutlmtp "; fi if [ 1 -eq `egrep <${STDOUT} -- '--timeoutlmtpaccept' | wc -l` ]; then RC="${RC}--timeoutlmtpaccept "; fi @@ -283,11 +283,11 @@ echon "checking whether -h option adds header/value pair ... " prolog newmsg -./lmtp2nntp <${STDIN} -b - -c ${LOCAL} -o 250/2.0.0 -g arg -d ${HOST} -h "X-Gateway: added it!" ${LOG} -m "${MFILT}" -n ${NODE} -s 1500 --timeoutnntpconnect=1 ${GROUP} >${STDOUT} 2>${STDERR} +./lmtp2nntp <${STDIN} -b - -c ${LOCAL} -o 250/2.0.0 -g arg -d ${HOST} -h "::X-Gateway:added it!" ${LOG} -m "${MFILT}" -n ${NODE} -s 1500 --timeoutnntpconnect=1 ${GROUP} >${STDOUT} 2>${STDERR} RC=""; if [ 1 -eq `egrep <${STDOUT} '^220[- ]LMTP Service ready' | wc -l` ]; then RC="${RC}init "; fi -if [ 1 -eq `egrep <${L2FILE} 'adding.*header: "X-Gateway:"' | wc -l` ]; then RC="${RC}head "; fi -if [ 1 -eq `egrep <${L2FILE} 'adding.*header: "added it!"' | wc -l` ]; then RC="${RC}val. "; fi +if [ 1 -eq `egrep <${L2FILE} 'appending header X-Gateway:' | wc -l` ]; then RC="${RC}head "; fi +if [ 1 -eq `egrep <${L2FILE} 'header=X-Gateway.*data=added it!' | wc -l` ]; then RC="${RC}val. "; fi if [ 1 -eq `egrep <${L2FILE} 'verbatim.*"X-Gateway: added it!"' | wc -l` ]; then RC="${RC}pair "; fi if [ "${RC}" != "init head val. pair " ]; then echo "NO (got ${RC})"