Index: ossp-pkg/lmtp2nntp/lmtp2nntp.c RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/Attic/lmtp2nntp.c,v rcsdiff -q -kk '-r1.90' '-r1.91' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/Attic/lmtp2nntp.c,v' 2>/dev/null --- lmtp2nntp.c 2001/10/12 13:24:44 1.90 +++ lmtp2nntp.c 2001/10/15 10:13:50 1.91 @@ -143,6 +143,8 @@ char *option_operationmodefakestatus; char *option_operationmodefakedsn; int option_maxmessagesize; + char *azHeaderValuePairs; + size_t asHeaderValuePairs; int option_timeout_lmtp_accept; int option_timeout_lmtp_read; int option_timeout_lmtp_write; @@ -218,6 +220,7 @@ "[-c addr[:port]] " "[-d addr[:port][,addr[:port], ...]] " "[-g groupmode] " + "[-h header:value] " "[-l level[:logfile]] " "[-m mailfrom] " "[-n nodename] " @@ -403,6 +406,8 @@ char *cpAddr; char *cpPrefixLen; struct passwd *sPasswd; + char *cpHeadername; + char *cpHeadervalue; /* drop effective uid/gid priviledges */ seteuid(getuid()); @@ -429,6 +434,8 @@ ctx->option_operationmodefakestatus = "553"; /* Requested action not taken: mailbox name not allowed */ ctx->option_operationmodefakedsn = "5.7.1"; /* Delivery not authorized, message refused */ ctx->option_maxmessagesize = 8 * 1024 * 1024; + ctx->azHeaderValuePairs = NULL; + ctx->asHeaderValuePairs = 0; ctx->option_timeout_lmtp_accept = 0; ctx->option_timeout_lmtp_read = 10; ctx->option_timeout_lmtp_write = 10; @@ -485,7 +492,7 @@ */ /* read in the arguments */ - while ((i = getopt(argc, argv, "C:DKP:Va:b:c:d:g:l:m:n:o:s:t:u:v")) != -1) { + while ((i = getopt(argc, argv, "C:DKP:Va:b:c:d:g:h:l:m:n:o:s:t:u:v")) != -1) { switch (i) { case 'C': /*POD [B<-C> I] */ ctx->option_childsmax = atoi(optarg); @@ -693,6 +700,28 @@ CU(ERR_EXECUTION); } break; + case 'h': /*POD [B<-h> I
:] */ + cpHeadername = strdup(optarg); + if ((cp = strrchr(cpHeadername, ':')) == NULL) { + free(cpHeadername); + fprintf(stderr, "%s:Error: header \"%s\" for -h option not terminated with colon\n", + ctx->progname, cpHeadername); + CU(ERR_EXECUTION); + } + cp++; + if (*cp == NUL) { + free(cpHeadername); + fprintf(stderr, "%s:Error: header \"%s\" for -h option has no value\n", + ctx->progname, cpHeadername); + CU(ERR_EXECUTION); + } + cpHeadervalue = strdup(cp); + *cp = NUL; + argz_add(&ctx->azHeaderValuePairs, &ctx->asHeaderValuePairs, cpHeadername); + argz_add(&ctx->azHeaderValuePairs, &ctx->asHeaderValuePairs, cpHeadervalue); + free(cpHeadervalue); + free(cpHeadername); + break; case 'l': /*POD [B<-l> I[:I]] */ if ((cp = strrchr(optarg, ':')) != NULL) { *cp++ = NUL; @@ -1238,6 +1267,8 @@ sa_destroy(ctx->saAltio); if (ctx->saaAltio) sa_addr_destroy(ctx->saaAltio); + if (ctx->azHeaderValuePairs != NULL) + free(ctx->azHeaderValuePairs); if (ctx->option_pidfile != NULL) free(ctx->option_pidfile); if (ctx->option_logfile != NULL) @@ -2002,6 +2033,15 @@ } } + /* Optionally add command line specified Header/Value Pairs + */ + if ((ctx->asHeaderValuePairs >= 1) && ((ctx->asHeaderValuePairs & 1) == 0)) { + cp = NULL; + while ((cp = argz_next(ctx->azHeaderValuePairs, ctx->asHeaderValuePairs, cp)) != NULL) { + argz_add(&ctx->msg->azHeaders, &ctx->msg->asHeaders, cp); + } + } + /* RFC0821 4.2.1. REPLY CODES BY FUNCTION GROUPS 554 Transaction failed * RFC1893 2. Status Codes 5.X.X Permanent Failure * RFC1893 3.5 Network and Routing Status X.6.5 Conversion Failed Index: ossp-pkg/lmtp2nntp/lmtp2nntp.pod RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp.pod,v rcsdiff -q -kk '-r1.31' '-r1.32' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp.pod,v' 2>/dev/null --- lmtp2nntp.pod 2001/10/12 13:23:52 1.31 +++ lmtp2nntp.pod 2001/10/15 10:13:50 1.32 @@ -43,6 +43,7 @@ [B<-c> I[I<:port>]] [B<-d> I[I<:port>][,I[I<:port>], ...]] [B<-g> I] +[B<-h> I
:] [B<-l> I[:I]] [B<-m> I] [B<-n> I] @@ -70,6 +71,12 @@ =over 4 +=item B<-h> I
: + +Header with value to to be inserted into message before delivery. This option +can be specified more than once. Useful for specifiying an moderator Email +address to all outgoing news messages by applying an "Approved:" header. + =item B<-C> I Childs the daemon spawns at maximum. Default is 10. Index: ossp-pkg/lmtp2nntp/test.sh RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/test.sh,v rcsdiff -q -kk '-r1.5' '-r1.6' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/test.sh,v' 2>/dev/null --- test.sh 2001/10/12 14:02:57 1.5 +++ test.sh 2001/10/15 10:13:50 1.6 @@ -100,15 +100,11 @@ echo "yes" echon "checking whether -? usage option works ... " -# expected typical output: USAGE: ./lmtp2nntp -# [-D] [-K] [-P pidfile] [-a addr/mask[,addr/mask[,...]] [-b -# -|path|addr[:port]] [-c addr[:port]] [-d addr[:port][,addr[:port], ...]] [-g -# groupmode] [-l level[:logfile]] [-m mailfrom] [-n nodename] [-o operationmode] -# [-s size] [-t name=sec[,name=sec[,...]] [-v] newsgroup [newsgroup ...] +# expected typical output see ./lmtp2nntp -? prolog newmsg ./lmtp2nntp -? >${STDOUT} 2>${STDERR} -RC=`cat ${STDERR} | egrep -- '-C.*-D.*-K.*-P.*-V.*-a.*-b.*-d.*-g.*-l.*-m.*-n.*-o.*-s.*-t.*-v.*newsgroup' | wc -l` +RC=`cat ${STDERR} | egrep -- '-C.*-D.*-K.*-P.*-V.*-a.*-b.*-d.*-g.*-h.*-l.*-m.*-n.*-o.*-s.*-t.*-v.*newsgroup' | wc -l` if [ ${RC} -ne 1 -o -s ${STDOUT} ]; then echo "NO (got ${RC})" exit 1;