Index: ossp-pkg/lmtp2nntp/lmtp2nntp_config.c RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_config.c,v rcsdiff -q -kk '-r1.40' '-r1.41' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_config.c,v' 2>/dev/null --- lmtp2nntp_config.c 2002/02/05 10:40:51 1.40 +++ lmtp2nntp_config.c 2002/02/05 14:14:54 1.41 @@ -135,6 +135,7 @@ CU(ERR_EXECUTION); } if (ov->data.s != NULL) { + //FIXME this is cut off on command line!? fprintf(stderr, "DEBUG: ov->data.s = \"%s\"\n", ov->data.s); if ((rc = l2_spec(&ctx->l2, ctx->l2_env, ov->data.s)) != L2_OK) { fprintf(stderr, "%s:Error: logging failed to create stream\n", ctx->progname); CU(ERR_EXECUTION); @@ -153,6 +154,24 @@ */ log1(ctx, NOTICE, "startup, version %s", lmtp2nntp_version.v_gnu); + /* --version FLAG */ + try { + if ( (val_get(ctx->val, "option.version", &ov) != VAL_OK) + || (ov->ndata < 0) + || (ov->ndata == 1 && ov->data.f < 0) + || (ov->ndata == 1 && ov->data.f > 1) + || (ov->ndata > 1) + ) throw(0,0,0); + log1(ctx, TRACE, "--version = %d", ov->data.f); + + if (ov->data.f == 1) { + fprintf(stdout, "%s\n", lmtp2nntp_version.v_gnu); + exit(0); //FIXME + } + } + catch (ex) + rethrow; + /* --childsmax SINGLE */ try { if ( (val_get(ctx->val, "option.childsmax", &ov) != VAL_OK) @@ -426,7 +445,9 @@ log1(ctx, ERROR, "option --client, create address (internal) failed with \"%s\"", sa_error(rc)); throw(0,0,0); } - if ((rc = sa_addr_u2a(ctx->saaClientbind, "inet://%s", ov->data.s)) != SA_OK) { + if ((rc = sa_addr_u2a(ctx->saaClientbind, + (strchr(ov->data.s, ':') == NULL) ? "inet://%s:0" : "inet://%s", + ov->data.s)) != SA_OK) { log2(ctx, ERROR, "option --client, parsing alternate IO guessing INET socket (%s) failed with \"%s\"", ov->data.s, sa_error(rc)); throw(0,0,0); } @@ -885,24 +906,6 @@ } } catch (ex) - rethrow; - - /* --version FLAG */ - try { - if ( (val_get(ctx->val, "option.version", &ov) != VAL_OK) - || (ov->ndata < 0) - || (ov->ndata == 1 && ov->data.f < 0) - || (ov->ndata == 1 && ov->data.f > 1) - || (ov->ndata > 1) - ) throw(0,0,0); - log1(ctx, TRACE, "--version = %d", ov->data.f); - - if (ov->data.f == 1) { - log1(ctx, INFO, "program version %s", lmtp2nntp_version.v_gnu); - fprintf(stdout, "%s\n", lmtp2nntp_version.v_gnu); //FIXME is fprintf really the way to go? - } - } - catch (ex) rethrow; /* --newsgroup MULTI */ Index: ossp-pkg/lmtp2nntp/lmtp2nntp_option.c RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_option.c,v rcsdiff -q -kk '-r1.10' '-r1.11' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_option.c,v' 2>/dev/null --- lmtp2nntp_option.c 2002/02/05 10:42:39 1.10 +++ lmtp2nntp_option.c 2002/02/05 14:14:54 1.11 @@ -614,7 +614,6 @@ (void)option_register(o, "groupmode", 'g', OPT_SINGLE, "arg", "arg|envelope|header", "groupmode", &stdsyntax, "m/.*/" ); //"m/(arg|envelope|header)/" ); (void)option_register(o, "headervalue", 'h', OPT_MULTI, NULL, "header/ value added to message", "header: value", &stdsyntax, "m/.*/" ); (void)option_register(o, "include", 'i', OPT_MULTI, NULL, "configfile to include", "configfile", &includeit, "m/.*/" ); - (void)option_register(o, "size", 's', OPT_SINGLE, "8388608", "maximum message size", "bytes", &stdsyntax, "m/.*/" ); //"m/[0-9]+/" ); (void)option_register(o, "timeoutlmtp", NUL, OPT_SINGLE, NULL, "LMTP server default timeout", "sec", &stdsyntax, "m/.*/" ); (void)option_register(o, "timeoutlmtpaccept", NUL, OPT_SINGLE, "0", "LMTP server accept timeout", "sec", &stdsyntax, "m/.*/" ); (void)option_register(o, "timeoutlmtpread", NUL, OPT_SINGLE, "10", "LMTP server read timeout", "sec", &stdsyntax, "m/.*/" ); @@ -623,13 +622,14 @@ (void)option_register(o, "timeoutnntpconnect", NUL, OPT_SINGLE, "360", "NNTP client connect timeout", "sec", &stdsyntax, "m/.*/" ); (void)option_register(o, "timeoutnntpread", NUL, OPT_SINGLE, "60", "NNTP client read timeout", "sec", &stdsyntax, "m/.*/" ); (void)option_register(o, "timeoutnntpwrite", NUL, OPT_SINGLE, "60", "NNTP client write timeout", "sec", &stdsyntax, "m/.*/" ); + (void)option_register(o, "l2spec", 'l', OPT_SINGLE, NULL, "L2 channel tree specification", "l2spec", &stdsyntax, "m/.*/" ); (void)option_register(o, "mailfrom", 'm', OPT_SINGLE, NULL, "mail from envelope restriction", "regex", &stdsyntax, "m/.*/" ); (void)option_register(o, "nodename", 'n', OPT_SINGLE, NULL, "nodename", "name", &stdsyntax, "m/.*/" ); (void)option_register(o, "operationmode", 'o', OPT_SINGLE, "553/5.7.1", "fakestatus or operationmode", "abc/a.d.e|post|feed", &stdsyntax, "m/.*/" ); //"m/([0-9]{3}\\/[0-9]\\.[0-9]\\.[0-9]|post|feed)/" ); /* 553 = Requested action not taken: mailbox name not allowed, 5.7.1 = Delivery not authorized, message refused */ - (void)option_register(o, "l2spec", 'l', OPT_SINGLE, NULL, "L2 channel tree specification", "l2spec", &stdsyntax, "m/.*/" ); + (void)option_register(o, "restrictheader", 'r', OPT_SINGLE, NULL, "header restriction", "regex", &stdsyntax, "m/.*/" ); + (void)option_register(o, "size", 's', OPT_SINGLE, "8388608", "maximum message size", "bytes", &stdsyntax, "m/.*/" ); //"m/[0-9]+/" ); (void)option_register(o, "user", 'u', OPT_SINGLE, NULL, "user", "uid|name", &stdsyntax, "m/.*/" ); (void)option_register(o, "version", 'v', OPT_FLAG, NULL, "print version", NULL, &stdsyntax, NULL ); - (void)option_register(o, "restrictheader", 'r', OPT_SINGLE, NULL, "header restriction", "regex", &stdsyntax, "m/.*/" ); (void)option_register(o, "newsgroup", NUL, OPT_MULTI, NULL, "article destination", "newsgroup", &stdsyntax, "m/.*/" ); #if 0 Index: ossp-pkg/lmtp2nntp/test.sh RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/test.sh,v rcsdiff -q -kk '-r1.8' '-r1.9' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/test.sh,v' 2>/dev/null --- test.sh 2001/11/14 14:22:25 1.8 +++ test.sh 2002/02/05 14:14:54 1.9 @@ -77,8 +77,12 @@ TMPFILE="${PREFIX}tmp" DMALLOC="${PREFIX}dmalloc.log" - LOG="debug" - FILE="${PREFIX}stdlog" + L2CONF="${PREFIX}logspec" + L2FILE="${PREFIX}log" + L2SPEC="'debug: prefix(prefix=\"%%b %%d %%H:%%M:%%S <%%L> lmtp2nntp[%%P]: \",timezone=local) -> file(path=\"${L2FILE}\",append=0,perm=432)'" + echo >${L2CONF} "l2spec ${L2SPEC}" + LOG="-i ${L2CONF}" + STDIN="${PREFIX}stdin" STDOUT="${PREFIX}stdout" STDERR="${PREFIX}stderr" @@ -108,8 +112,38 @@ prolog newmsg ./lmtp2nntp -? >${STDOUT} 2>${STDERR} -RC=`cat ${STDERR} | egrep -- '-C.*-D.*-K.*-P.*-V.*-a.*-b.*-d.*-g.*-h.*-l.*-m.*-n.*-o.*-r.*-s.*-t.*-v.*newsgroup' | wc -l` -if [ ${RC} -ne 1 -o -s ${STDOUT} ]; then +RC=""; +if [ 1 -eq `egrep <${STDOUT} -- '-C.*--childsmax' | wc -l` ]; then RC="${RC}-C "; fi +if [ 1 -eq `egrep <${STDOUT} -- '-D.*--daemonize' | wc -l` ]; then RC="${RC}-D "; fi +if [ 1 -eq `egrep <${STDOUT} -- '-K.*--kill' | wc -l` ]; then RC="${RC}-K "; fi +if [ 1 -eq `egrep <${STDOUT} -- '-P.*--pidfile' | wc -l` ]; then RC="${RC}-P "; fi +if [ 1 -eq `egrep <${STDOUT} -- '-a.*--acl' | wc -l` ]; then RC="${RC}-a "; fi +if [ 1 -eq `egrep <${STDOUT} -- '-b.*--bind' | wc -l` ]; then RC="${RC}-b "; fi +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} -- '-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 +if [ 1 -eq `egrep <${STDOUT} -- '--timeoutlmtpread' | wc -l` ]; then RC="${RC}--timeoutlmtpread "; fi +if [ 1 -eq `egrep <${STDOUT} -- '--timeoutlmtpwrite' | wc -l` ]; then RC="${RC}--timeoutlmtpwrite "; fi +if [ 1 -eq `egrep <${STDOUT} -- '--timeoutnntp' | wc -l` ]; then RC="${RC}--timeoutnntp "; fi +if [ 1 -eq `egrep <${STDOUT} -- '--timeoutnntpconnect' | wc -l` ]; then RC="${RC}--timeoutnntpconnect "; fi +if [ 1 -eq `egrep <${STDOUT} -- '--timeoutnntpread' | wc -l` ]; then RC="${RC}--timeoutnntpread "; fi +if [ 1 -eq `egrep <${STDOUT} -- '--timeoutnntpwrite' | wc -l` ]; then RC="${RC}--timeoutnntpwrite "; fi +if [ 1 -eq `egrep <${STDOUT} -- '-l.*--l2spec' | wc -l` ]; then RC="${RC}-l "; fi +if [ 1 -eq `egrep <${STDOUT} -- '-m.*--mailfrom' | wc -l` ]; then RC="${RC}-m "; fi +if [ 1 -eq `egrep <${STDOUT} -- '-n.*--nodename' | wc -l` ]; then RC="${RC}-n "; fi +if [ 1 -eq `egrep <${STDOUT} -- '-o.*--operationmode' | wc -l` ]; then RC="${RC}-o "; fi +if [ 1 -eq `egrep <${STDOUT} -- '-r.*--restrictheader' | wc -l` ]; then RC="${RC}-r "; fi +if [ 1 -eq `egrep <${STDOUT} -- '-s.*--size' | wc -l` ]; then RC="${RC}-s "; fi +if [ 1 -eq `egrep <${STDOUT} -- '-u.*--user' | wc -l` ]; then RC="${RC}-u "; fi +if [ 1 -eq `egrep <${STDOUT} -- '-v.*--version' | wc -l` ]; then RC="${RC}-v "; fi +if [ 1 -eq `egrep <${STDOUT} -- '--newsgroup' | wc -l` ]; then RC="${RC}--newsgroup "; fi +if [ 1 -eq `egrep <${STDOUT} -- '-?.*--help' | wc -l` ]; then RC="${RC}-? "; fi +if [ 1 -eq `egrep <${STDOUT} -- '--usage' | wc -l` ]; then RC="${RC}--usage "; fi +if [ "${RC}" != "-C -D -K -P -a -b -c -d -g -h -i --timeoutlmtpaccept --timeoutlmtpread --timeoutlmtpwrite --timeoutnntpconnect --timeoutnntpread --timeoutnntpwrite -l -m -n -o -r -s -u -v --newsgroup -? --usage " ]; then echo "NO (got ${RC})" exit 1; fi @@ -118,7 +152,8 @@ echon "checking whether a valid fake posting succeeds ... " prolog newmsg -./lmtp2nntp <${STDIN} -c ${LOCAL} -o 250/2.0.0 -g arg -d ${HOST} -l ${LOG}:${FILE} -m "${MFILT}" -n ${NODE} -s 1500 -t nntp:connect=1 ${GROUP} >${STDOUT} 2>${STDERR} ; RC=$ +echo ./lmtp2nntp ${STDIN} -c ${LOCAL} -o 250/2.0.0 -g arg -d ${HOST} ${LOG} -m "${MFILT}" -n ${NODE} -s 1500 -t nntp:connect=1 ${GROUP} ${STDOUT} 2${STDERR} ; RC=$ +./lmtp2nntp <${STDIN} -c ${LOCAL} -o 250/2.0.0 -g arg -d ${HOST} ${LOG} -m "${MFILT}" -n ${NODE} -s 1500 -t nntp:connect=1 ${GROUP} >${STDOUT} 2>${STDERR} ; RC=$ RC=""; if [ 1 -eq `egrep <${STDOUT} '^220[- ]LMTP Service ready' | wc -l` ]; then RC="${RC}init "; fi if [ 1 -eq `egrep <${STDOUT} '^250[- ].*pleased to meet you' | wc -l` ]; then RC="${RC}LHLO "; fi @@ -129,6 +164,10 @@ if [ 1 -eq `egrep <${STDOUT} '^221[- ]2.0.0.+closing.+channel' | wc -l` ]; then RC="${RC}QUIT "; fi if [ "${RC}" != "init LHLO MAIL RCPT DATA post QUIT " ]; then echo "NO (got ${RC})" + echo STDIN cat ${STDIN} + echo STDOUT cat ${STDOUT} + echo STDERR cat ${STDERR} + echo LOG cat ${L2FILE} exit 1; fi echo "yes" @@ -136,7 +175,7 @@ echon "checking whether -m option blocks invalid sender ... " prolog newmsg -( MFILT=".*@is.invalid" ; ./lmtp2nntp <${STDIN} -c ${LOCAL} -o 250/2.0.0 -g arg -d ${HOST} -l ${LOG}:${FILE} -m "${MFILT}" -n ${NODE} -s 1500 -t nntp:connect=1 ${GROUP} >${STDOUT} 2>${STDERR} ) ; RC=$? +( MFILT=".*@is.invalid" ; ./lmtp2nntp <${STDIN} -c ${LOCAL} -o 250/2.0.0 -g arg -d ${HOST} ${LOG} -m "${MFILT}" -n ${NODE} -s 1500 -t nntp:connect=1 ${GROUP} >${STDOUT} 2>${STDERR} ) ; RC=$? RC=""; if [ 1 -eq `egrep <${STDOUT} '^220[- ]LMTP Service ready' | wc -l` ]; then RC="${RC}init "; fi if [ 1 -eq `egrep <${STDOUT} '^250[- ].+pleased to meet you' | wc -l` ]; then RC="${RC}LHLO "; fi @@ -154,7 +193,7 @@ echon "checking whether -s option rejects article with invalid size ... " prolog newmsg -./lmtp2nntp <${STDIN} -c ${LOCAL} -o 250/2.0.0 -g arg -d ${HOST} -l ${LOG}:${FILE} -m "${MFILT}" -n ${NODE} -s 100 -t nntp:connect=1 ${GROUP} >${STDOUT} 2>${STDERR} ; RC=$? +./lmtp2nntp <${STDIN} -c ${LOCAL} -o 250/2.0.0 -g arg -d ${HOST} ${LOG} -m "${MFILT}" -n ${NODE} -s 100 -t nntp:connect=1 ${GROUP} >${STDOUT} 2>${STDERR} ; RC=$? RC=""; if [ 1 -eq `egrep <${STDOUT} '^220[- ]LMTP Service ready' | wc -l` ]; then RC="${RC}init "; fi if [ 1 -eq `egrep <${STDOUT} '^250[- ].*pleased to meet you' | wc -l` ]; then RC="${RC}LHLO "; fi @@ -172,7 +211,7 @@ echon "checking whether -c option fails on invalid local host address ... " prolog newmsg -( LOCAL="10.255.255.255" ; ./lmtp2nntp <${STDIN} -c ${LOCAL} -o 250/2.0.0 -g arg -d ${HOST} -l ${LOG}:${FILE} -m "${MFILT}" -n ${NODE} -s 1500 -t nntp:connect=1 ${GROUP} >${STDOUT} 2>${STDERR} ) ; RC=$? +( LOCAL="10.255.255.255" ; ./lmtp2nntp <${STDIN} -c ${LOCAL} -o 250/2.0.0 -g arg -d ${HOST} ${LOG} -m "${MFILT}" -n ${NODE} -s 1500 -t nntp:connect=1 ${GROUP} >${STDOUT} 2>${STDERR} ) ; RC=$? RC=""; if [ 1 -eq `egrep <${STDOUT} '^220[- ]LMTP Service ready' | wc -l` ]; then RC="${RC}init "; fi if [ 1 -eq `egrep <${FILE} 'error.+binding' | wc -l` ]; then RC="${RC}bind "; fi @@ -185,7 +224,7 @@ echon "checking whether -g envelope option blocks invalid group ... " prolog newmsg -( GROUP="foo.*" ; ./lmtp2nntp <${STDIN} -c ${LOCAL} -o 250/2.0.0 -g envelope -d ${HOST} -l ${LOG}:${FILE} -m "${MFILT}" -n ${NODE} -s 1500 -t nntp:connect=1 ${GROUP} >${STDOUT} 2>${STDERR} ) ; RC=$? +( GROUP="foo.*" ; ./lmtp2nntp <${STDIN} -c ${LOCAL} -o 250/2.0.0 -g envelope -d ${HOST} ${LOG} -m "${MFILT}" -n ${NODE} -s 1500 -t nntp:connect=1 ${GROUP} >${STDOUT} 2>${STDERR} ) ; RC=$? RC=""; if [ 1 -eq `egrep <${STDOUT} '^220[- ]LMTP Service ready' | wc -l` ]; then RC="${RC}init "; fi if [ 1 -eq `egrep <${STDOUT} '^250[- ].*pleased to meet you' | wc -l` ]; then RC="${RC}LHLO "; fi @@ -204,7 +243,7 @@ echon "checking whether -d option times out for invalid host ... " prolog newmsg -( HOST="10.255.255.255" ; ./lmtp2nntp <${STDIN} -c ${LOCAL} -o 250/2.0.0 -g arg -d ${HOST} -l ${LOG}:${FILE} -m "${MFILT}" -n ${NODE} -s 1500 -t nntp:connect=1 ${GROUP} >${STDOUT} 2>${STDERR} ) ; RC=$? +( HOST="10.255.255.255" ; ./lmtp2nntp <${STDIN} -c ${LOCAL} -o 250/2.0.0 -g arg -d ${HOST} ${LOG} -m "${MFILT}" -n ${NODE} -s 1500 -t nntp:connect=1 ${GROUP} >${STDOUT} 2>${STDERR} ) ; RC=$? RC=""; if [ 1 -eq `egrep <${STDOUT} '^220[- ]LMTP Service ready' | wc -l` ]; then RC="${RC}init "; fi if [ 1 -eq `egrep <${FILE} 'warning.+connect.+failed' | wc -l` ]; then RC="${RC}conn "; fi