1N/A * Copyright (c) 1998-2003, 2006 Sendmail, Inc. and its suppliers. 1N/A * All rights reserved. 1N/A * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. 1N/A * Copyright (c) 1988, 1993 1N/A * The Regents of the University of California. All rights reserved. 1N/A * By using this file, you agree to the terms and conditions set 1N/A * forth in the LICENSE file which can be found at the top level of 1N/A * the sendmail distribution. 1N/A** UDB.C -- interface between sendmail and Berkeley User Data Base. 1N/A** This depends on the 4.4BSD db package. 1N/A /* type UE_REMOTE -- do remote call for lookup */ 1N/A#
endif /* NETINET || NETINET6 */ 1N/A /* type UE_FORWARD -- forward message to remote */ 1N/A /* type UE_FETCH -- lookup in local database */ 1N/A** UDBEXPAND -- look up user in database and expand 1N/A** a -- address to expand. 1N/A** sendq -- pointer to head of sendq to put the expansions in. 1N/A** aliaslevel -- the current alias nesting depth. 1N/A** e -- the current envelope. 1N/A** EX_TEMPFAIL -- if something "odd" happened -- probably due 1N/A** to accessing a file on an NFS server that is down. 1N/A** EX_OK -- otherwise. 1N/A /* make certain we are supposed to send to this address */ 1N/A /* on first call, locate the database */ 1N/A /* short circuit the process if no chance of a match */ 1N/A /* extract user to do userdb matching on */ 1N/A /* short circuit name begins with '\\' since it can't possibly match */ 1N/A /* (might want to treat this as unquoted instead) */ 1N/A /* if name begins with a colon, it indicates our metadata */ 1N/A /* if name is too long, assume it won't match */ 1N/A /* build actual database key */ 1N/A#
endif /* HESIOD && HES_GETMAILHOST */ 1N/A#
endif /* defined(NEWDB) && DB_VERSION_MAJOR > 1 */ 1N/A ** Select action based on entry type. 1N/A ** On dropping out of this switch, "class" should 1N/A ** explain the type of the data, and "user" should 1N/A ** contain the user information. 1N/A#
else /* DB_VERSION_MAJOR < 2 */ 1N/A#
else /* DB_VERSION_MAJOR > 2 || DB_VERSION_MINOR >= 6 */ 1N/A#
endif /* DB_VERSION_MAJOR > 2 || DB_VERSION_MINOR >= 6 */ 1N/A#
endif /* DB_VERSION_MAJOR < 2 */ 1N/A#
endif /* DB_VERSION_MAJOR > 1 */ 1N/A#
endif /* DB_VERSION_MAJOR > 1 */ 1N/A /* get the next record */ 1N/A#
else /* DB_VERSION_MAJOR < 2 */ 1N/A#
endif /* DB_VERSION_MAJOR < 2 */ 1N/A#
endif /* DB_VERSION_MAJOR > 1 */ 1N/A /* if nothing ever matched, try next database */ 1N/A "expand %.100s => %s",
1N/A ** If this address has a -request address, reflect 1N/A ** it into the envelope. 1N/A#
else /* DB_VERSION_MAJOR < 2 */ 1N/A#
endif /* DB_VERSION_MAJOR < 2 */ 1N/A /* announce delivery; NORECEIPT bit set later */ 1N/A "Message delivered to mailing list %s\n",
1N/A /* look up the key via hesiod */ 1N/A#
endif /* HES_GETMAILHOST */ 1N/A syserr(
"udbexpand: hesiod-getmail %s stat %d",
1N/A sm_dprintf(
"hes_getmailhost(%s): expansion too long: %.30s@%.30s\n",
1N/A#
else /* HES_GETMAILHOST */ 1N/A#
endif /* HES_GETMAILHOST */ 1N/A "hesiod %.100s => %s",
1N/A ** If this address has a -request address, reflect 1N/A ** it into the envelope. 1N/A /* not yet implemented */ 1N/A /* unknown entry type */ 1N/A /* XXX if an exception occurs, there is a storage leak */ 1N/A** UDBSENDER -- return canonical external name of sender, given local name 1N/A** sender -- the name of the sender on the local machine. 1N/A** rpool -- resource pool from which to allocate result 1N/A** The external name for this sender, if derivable from the 1N/A** database. Storage allocated from rpool. 1N/A** NULL -- if nothing is changed from the database. 1N/A** UDBMATCH -- match user in field, return result of lookup. 1N/A** user -- the name of the user. 1N/A** field -- the field to lookup. 1N/A** rpool -- resource pool from which to allocate result 1N/A** The external name for this sender, if derivable from the 1N/A** database. Storage allocated from rpool. 1N/A** NULL -- if nothing is changed from the database. 1N/A /* short circuit if no spec */ 1N/A /* short circuit name begins with '\\' since it can't possibly match */ 1N/A /* long names can never match and are a pain to deal with */ 1N/A if (i <
sizeof(
"maildrop"))
1N/A i =
sizeof(
"maildrop");
1N/A /* names beginning with colons indicate metadata */ 1N/A /* build database key */ 1N/A ** Select action based on entry type. 1N/A#
else /* DB_VERSION_MAJOR < 2 */ 1N/A#
endif /* DB_VERSION_MAJOR < 2 */ 1N/A ** Nothing yet. Search again for a default case. But only 1N/A ** use it if we also have a forward (:maildrop) pointer already 1N/A /* build database key */ 1N/A /* get the default case for this database */ 1N/A#
else /* DB_VERSION_MAJOR < 2 */ 1N/A#
endif /* DB_VERSION_MAJOR < 2 */ 1N/A /* no default case */ 1N/A /* save the default case */ 1N/A /* we have a default case -- verify user:maildrop */ 1N/A#
else /* DB_VERSION_MAJOR < 2 */ 1N/A#
endif /* DB_VERSION_MAJOR < 2 */ 1N/A /* nope -- no aliasing for this user */ 1N/A /* they exist -- build the actual address */ 1N/A /* get the default case for this database */ 1N/A /* no default case */ 1N/A /* save the default case */ 1N/A /* we have a default case -- verify user:maildrop */ 1N/A /* nope -- no aliasing for this user */ 1N/A /* they exist -- build the actual address */ 1N/A /* still nothing.... too bad */ 1N/A** UDB_MAP_LOOKUP -- look up arbitrary entry in user database map 1N/A** map -- the map being queried. 1N/A** name -- the name to look up. 1N/A** av -- arguments to the map lookup. 1N/A** statp -- to get any error status. 1N/A** NULL if name not found in map. 1N/A** The rewritten name otherwise. 1N/A** _UDBX_INIT -- parse the UDB specification, opening any valid entries. 1N/A** e -- the current envelope. 1N/A** EX_TEMPFAIL -- if it appeared it couldn't get hold of a 1N/A** database due to a host being down or some similar 1N/A** (recoverable) situation. 1N/A** EX_OK -- otherwise. 1N/A** Fills in the UdbEnts structure from UdbSpec. 1N/A#
endif /* UDB_DEFAULT_SPEC */ 1N/A while (*p ==
' ' || *p ==
'\t' || *p ==
',')
1N/A syserr(
"Maximum number of UDB entries exceeded");
1N/A /* extract options */ 1N/A ** Decode database specification. 1N/A ** In the sendmail tradition, the leading character 1N/A ** defines the semantics of the rest of the entry. 1N/A ** @hostname -- forward email to the indicated host. 1N/A ** This should be the last in the list, 1N/A ** since it always matches the input. 1N/A ** /dbname -- search the named database on the local 1N/A ** host using the Berkeley db package. 1N/A ** Hesiod -- search the named database with BIND 1N/A ** using the MIT Hesiod package. 1N/A case '@':
/* forward to remote host */ 1N/A case 'h':
/* use hesiod */ 1N/A case '/':
/* look up remote name */ 1N/A#
else /* DB_VERSION_MAJOR < 2 */ 1N/A#
endif /* DB_VERSION_MAJOR > 2 */ 1N/A#
endif /* DB_OLD_VERSION */ 1N/A#
else /* DB_VERSION_MAJOR > 2 */ 1N/A#
endif /* DB_VERSION_MAJOR > 2 */ 1N/A#
endif /* DB_VERSION_MAJOR < 2 */ 1N/A#
else /* DB_VERSION_MAJOR < 2 */ 1N/A#
endif /* DB_VERSION_MAJOR < 2 */ 1N/A#
else /* DB_VERSION_MAJOR < 2 */ 1N/A#
endif /* DB_VERSION_MAJOR < 2 */ 1N/A#
else /* DB_VERSION_MAJOR < 2 */ 1N/A#
endif /* DB_VERSION_MAJOR < 2 */ 1N/A ** On temporary failure, back out anything we've already done 1N/A#
else /* DB_VERSION_MAJOR < 2 */ 1N/A#
endif /* DB_VERSION_MAJOR < 2 */ 1N/A** _UDBX_CLOSE -- close all file based UDB entries. 1N/A#
else /* DB_VERSION_MAJOR < 2 */ 1N/A#
endif /* DB_VERSION_MAJOR < 2 */ 1N/A /* make the hesiod query */ 1N/A#
else /* HESIOD_INIT */ 1N/A#
endif /* HESIOD_INIT */ 1N/A#
else /* HESIOD_INIT */ 1N/A /* network problem or timeout */ 1N/A#
endif /* HESIOD_INIT */ 1N/A ** If there are multiple matches, just return the 1N/A ** XXX These should really be returned; for example, 1N/A ** XXX it is legal for :maildrop to be multi-valued.