[comp.mail.sendmail] debugging output

reeder@ut-emx.UUCP (William P. Reeder) (02/16/89)

While I was installing sendmail 5.61, I thought I might as well bite
the bullet and do the sendmail.cf rewrite I had been promising to do
for so long.

I was testing my new configuration file (sendmail -bt -Cnew.cf) and saw
some strange stuff, so I thought I'd turn on some debugging (sendmail
-bt -Cnew.cf -d21.15).

Now I know that sendmail configuration files are cryptic, but don't you
think "^P" "<@" "^Q" ">" is even worse?  Why isn't there a special
routine which prints rules reasonably?  (For the sake of consistancy I
will accept sendmail.cf style rules as reasonable.)

Do the IDA enhancements fix this problem, or am I going to have to
rewrite printav() and xputs() (changing the names, of course) for use
in rewrite()?

William Reeder, University of Texas, Computation Center, Austin, TX, 78712
reeder@emx.utexas.edu, postmaster@emx.utexas.edu
uunet!cs.utexas.edu!ut-emx!reeder
-- 
DISCLAIMER:	I speak only for myself, and usually only to myself.

parmelee@wayback.cs.cornell.edu (Larry Parmelee) (02/16/89)

Refering to the debugging output of sendmail,
In article <10539@ut-emx.UUCP> reeder@ut-emx.UUCP (William P. Reeder) writes:
> Now I know that sendmail configuration files are cryptic, but don't you
> think "^P" "<@" "^Q" ">" is even worse?  Why isn't there a special
> routine which prints rules reasonably?  (For the sake of consistancy I
> will accept sendmail.cf style rules as reasonable.)

Someone (not me, and I don't remember who) did it a while back.  I
thought it was a useful hack, so I saved it.  Here it is as applied
to sendmail 5.61.

-Larry Parmelee
parmelee@cs.cornell.edu

*** /tmp/,RCSt1001981	Thu Feb 16 09:38:07 1989
--- util.c	Tue Jan 31 14:43:28 1989
***************
*** 280,289 ****
--- 280,349 ----
  		}
  		if (c < 040 || c >= 0177)
  		{
+ #ifdef ORIGINAL
  			(void) putchar('^');
  			c ^= 0100;
  		}
  		(void) putchar(c);
+ #else	/* !ORIGINAL */
+ 			char *cp;
+ 
+ 			switch (c) {
+ 			case MATCHZANY:	/* match zero or more tokens */
+ 				cp = "$*";
+ 				break;
+ 			case MATCHANY:	/* match one or more tokens */
+ 				cp = "$+";
+ 				break;
+ 			case MATCHONE:	/* match exactly one token */
+ 				cp = "$-";
+ 				break;
+ 			case MATCHCLASS:/* match one token in a class */
+ 				cp = "$=";
+ 				break;
+ 			case MATCHNCLASS:/* match anything not in class */
+ 				cp = "$~";
+ 				break;
+ 			case MATCHREPL:	/* replacement on RHS for above */
+ 				cp = "$";
+ 				break;
+ 			case CANONNET:	/* canonical net, next token */
+ 				cp = "$#";
+ 				break;
+ 			case CANONHOST:	/* canonical host, next token */
+ 				cp = "$@";
+ 				break;
+ 			case CANONUSER:	/* canonical user, next N tokens */
+ 				cp = "$:";
+ 				break;
+ 			case CALLSUBR:	/* call another rewriting set */
+ 				cp = "$>";
+ 				break;
+ 			case CONDIF:	/* conditional if-then */
+ 				cp = "$?";
+ 				break;
+ 			case CONDELSE:	/* conditional else */
+ 				cp = "$|";
+ 				break;
+ 			case CONDFI:	/* conditional fi */
+ 				cp = "$.";
+ 				break;
+ 			case HOSTBEGIN:	/* hostname lookup begin */
+ 				cp = "$[";
+ 				break;
+ 			case HOSTEND:	/* hostname lookup end */
+ 				cp = "$]";
+ 				break;
+ 			default:
+ 				cp = "^ ";
+ 				cp[1] = c ^ 0100;
+ 				break;
+ 			}
+ 			fputs(cp, stdout);
+ 		} else
+ 			(void) putchar(c);
+ 
+ #endif	/* ORIGINAL */
  	}
  	(void) putchar('"');
  	(void) fflush(stdout);

page@swan.ulowell.edu (Bob Page) (02/17/89)

reeder@ut-emx.UUCP (William P. Reeder) wrote:
>don't you think "^P" "<@" "^Q" ">" is even worse?

Three existing solutions (that I know of), take your pick:

1. Install the IDA patches.  Among the patches are routines to do this.


2. Use this script to do your debugging (this came across the net some
   time ago; sorry I don't remember who provided it):

#! /bin/sh
#
# This shell script runs sendmail in address test mode and converts the
# debugging output to something more intelligible for helping debug sendmail.cf
# files.
# 
# Pass the config file to use as $1
#
# Enter input of the form (same as for "sendmail -bt"):
# 
#       0 address1
#       0 address2
#       ...
#       (eof)
# 
#
/usr/lib/sendmail -bt -C$1 -d21.12 |\
grep -v -e '----- rule fails' |\
sed -e 's/-----trying rule:/R/' \
    -e 's/"^P"/$*/g' \
    -e 's/"^Q"/$+/g' \
    -e 's/"^R"/$-/g' \
    -e 's/"^S\([A-Za-z]\)"/$=\1/g' \
    -e 's/"^T\([0-9]\)"/$\1/g' \
    -e 's/"^U"/$#/' \
    -e 's/"^V"/$\&/g' \
    -e 's/"^W"/$:/g' \
    -e 's/"^X"/$>/g' \
    -e 's/"//g' |\
sed -e '/^R/s/[ 	]//g' \
    -e '/matches:/s/[ 	]//g' -e 's/rulematches:/rule matches: /' \
    -e '/rewritten as:/s/[ 	]//g' -e 's/rewrittenas:/rewritten as: /' \
    -e '/returns:/s/[ 	]//g' \
    -e 's/.*ruleset\([0-9]\)returns:/ruleset \1 returns: /' \
    -e '/input:/s/[ 	]//g' \
    -e 's/.*ruleset\(.*\)input:/ruleset \1 input: /'


3. Install these changes in util.c:xputs().  You'll have to do it by
   hand; I have too many changes to too many versions to be able to
   produce a usable context diff.  Again, I don't remember the original
   author of these changes.

Change:
  		}
  		if (c < 040 || c >= 0177)
  		{
! 			(void) putchar('^');
  			c ^= 0100;
  		}
  		(void) putchar(c);

To:
  		}
  		if (c < 040 || c >= 0177)
  		{
! 			switch (c) {
! 			case MATCHZANY:	/* match zero or more tokens */
! 				fputs("$*", stdout);
! 				continue;
! 				break;
! 			case MATCHANY:	/* match one or more tokens */
! 				fputs("$+", stdout);
! 				continue;
! 				break;
! 			case MATCHONE:	/* match exactly one token */
! 				fputs("$-", stdout);
! 				continue;
! 				break;
! 			case MATCHCLASS:/* match one token in a class */
! 				fputs("$=", stdout);
! 				continue;
! 				break;
! 			case MATCHNCLASS:/* match anything not in class */
! 				fputs("$~", stdout);
! 				continue;
! 				break;
! 			case MATCHREPL:	/* replacement on RHS for above */
! 				fputs("$", stdout);
! 				continue;
! 				break;
! 			case CANONNET:	/* canonical net, next token */
! 				fputs("$#", stdout);
! 				continue;
! 				break;
! 			case CANONHOST:	/* canonical host, next token */
! 				fputs("$@", stdout);
! 				continue;
! 				break;
! 			case CANONUSER:	/* canonical user, next N tokens */
! 				fputs("$:", stdout);
! 				continue;
! 				break;
! 			case CALLSUBR:	/* call another rewriting set */
! 				fputs("$>", stdout);
! 				continue;
! 				break;
! 			case CONDIF:	/* conditional if-then */
! 				fputs("$?", stdout);
! 				continue;
! 				break;
! 			case CONDELSE:	/* conditional else */
! 				fputs("$|", stdout);
! 				continue;
! 				break;
! 			case CONDFI:	/* conditional fi */
! 				fputs("$.", stdout);
! 				continue;
! 				break;
! 			case HOSTBEGIN:	/* hostname lookup begin */
! 				fputs("$[", stdout);
! 				continue;
! 				break;
! 			case HOSTEND:	/* hostname lookup end */
! 				fputs("$]", stdout);
! 				continue;
! 				break;
! 			}
! 			putchar('^');
  			c ^= 0100;
  		}
  		(void) putchar(c);


Happy sendmail debugging, if that isn't an oxymoron.

..Bob
-- 
Bob Page, U of Lowell CS Dept.  page@swan.ulowell.edu  ulowell!page
Have five nice days.

barnett@vdsvax.steinmetz.ge.com (Bruce Barnett) (02/17/89)

In article <11751@swan.ulowell.edu>, page@swan (Bob Page) writes:
>2. Use this script to do your debugging (this came across the net some
>   time ago; sorry I don't remember who provided it):

According to my notes:
# Compliments of the author:  Dan Long
#                             CSNET Technical Staff
#         		      long@sh.cs.net

Thanks Dan!

--
	Bruce G. Barnett 	barnett@ge-crd.ARPA, barnett@steinmetz.ge.com
				uunet!steinmetz!barnett