[Mimedefang] Order of the fuctions?

James Ebright jebright at esisnet.com
Wed Jun 22 09:41:17 EDT 2005

Well, I will try your method of replying :-)

On Wed, 22 Jun 2005 00:28:55 +0200, Jan Pieter Cornet wrote
> recipients.c has no milter calls in it, so it must be confusing 
> comparing those two.

The code I was referring to about the milter interface in recipients.c refers
specifically to modifying the recipients list I believe, it is one function
inside a precompiler if statement and only available if milter is available:

**  REMOVEFROMLIST -- Remove addresses from a send list.
**	The parameter is a comma-separated list of recipients to remove.
**	Note that it only deletes matching addresses.  If those addresses
**	have been expanded already in the sendq, it won't mark the
**	expanded recipients as QS_REMOVED.
**	Parameters:
**		list -- the list to remove.
**		sendq -- a pointer to the head of a queue to remove
**			these addresses from.
**		e -- the envelope in which to remove these recipients.
**	Returns:
**		The number of addresses removed from the list.

removefromlist(list, sendq, e)
	char *list;
	ADDRESS **sendq;
	SM_NONVOLATILE char delimiter;		/* the address delimiter */
	SM_NONVOLATILE int naddrs;
	char *p;
	char *oldto = e->e_to;
	char *SM_NONVOLATILE bufp;
	char buf[MAXNAME + 1];

	if (list == NULL)
		syserr("removefromlist: null list");
		return 0;

	if (tTd(25, 1))
		sm_dprintf("removefromlist: %s\n", list);

	/* heuristic to determine old versus new style addresses */
	if (strchr(list, ',') != NULL || strchr(list, ';') != NULL ||
	    strchr(list, '<') != NULL || strchr(list, '(') != NULL)
		e->e_flags &= ~EF_OLDSTYLE;
	delimiter = ' ';
	if (!bitset(EF_OLDSTYLE, e->e_flags))
		delimiter = ',';

	naddrs = 0;

	/* make sure we have enough space to copy the string */
	i = strlen(list) + 1;
	if (i <= sizeof buf)
		bufp = buf;
		i = sizeof buf;
		bufp = sm_malloc_x(i);

		(void) sm_strlcpy(bufp, denlstring(list, false, true), i);

		macdefine(&e->e_macro, A_PERM, macid("{addr_type}"), "e r");
		for (p = bufp; *p != '\0'; )
			ADDRESS a;	/* parsed address to be removed */
			ADDRESS *q;
			ADDRESS **pq;
			char *delimptr;

			/* parse the address */
			while ((isascii(*p) && isspace(*p)) || *p == ',')
			if (parseaddr(p, &a, RF_COPYALL,
				      delimiter, &delimptr, e, true) == NULL)
				p = delimptr;
			p = delimptr;
			for (pq = sendq; (q = *pq) != NULL; pq = &q->q_next)
				if (!QS_IS_DEAD(q->q_state) &&
				    (sameaddr(q, &a) ||
				     strcmp(q->q_paddr, a.q_paddr) == 0))
					if (tTd(25, 5))
						sm_dprintf("removefromlist: QS_REMOVED ");
						printaddr(sm_debug_file(), &a, false);
					q->q_state = QS_REMOVED;
		e->e_to = oldto;
		if (bufp != buf)
		macdefine(&e->e_macro, A_PERM, macid("{addr_type}"), NULL);
	return naddrs;
#endif /* MILTER */

> Yes, this is true (except you cannot modify the recipients list at 
> each point, only at the xxfi_eom callback).

Yes, that makes sense.

> I suspect your confusion arises from the fact that your unsure which
> parts of the verification is done by sendmail rulesets, and which 
> part is done in mimedefang via milter calls, or maybe you think that 
> mimedefang is called as part of some rulesets. It isn't. MD is 
> called via the milter interface, which is pretty much completely 
> separated from the rulesets.

Yes, still going through the source now and yes, I thought MDs milter
invocation for filter_relay, filter_recipients and filter_sender was called
via the specific check rulesets for those three. Looks like I was incorrect
there. I have done some extensive logging, but configured for our localized
scenario, as I pointed out, some check rulesets can be skipped due to auth and
I check for auth in filter_begin (earliest I know of that you can check for
authenticated users in MD [I use the global array SendmailMacros]) and skip
portions of my MD filter if the user authenticated as well. Most actions in
filter_recipients and filter_relay I dont actually take at that time but save
to a state file and do not take any action until after I can check for

EsisNet.com Webmail Client

More information about the MIMEDefang mailing list