From 5a4c03c6695b137e311109caf13ace57829f82fc Mon Sep 17 00:00:00 2001 From: Eric Allman Date: Mon, 16 Nov 1992 00:11:04 -0800 Subject: [PATCH] finish support for generalized maps SCCS-vsn: usr.sbin/sendmail/src/conf.h 5.29 SCCS-vsn: usr.sbin/sendmail/src/parseaddr.c 5.26 SCCS-vsn: usr.sbin/sendmail/src/version.c 5.124 SCCS-vsn: usr.sbin/sendmail/src/sendmail.h 5.41 SCCS-vsn: usr.sbin/sendmail/src/daemon.c 5.52 SCCS-vsn: usr.sbin/sendmail/src/Makefile 5.28 SCCS-vsn: usr.sbin/sendmail/src/readcf.c 5.49 SCCS-vsn: usr.sbin/sendmail/src/conf.c 5.44 --- usr/src/usr.sbin/sendmail/src/Makefile | 6 ++-- usr/src/usr.sbin/sendmail/src/conf.c | 14 ++++---- usr/src/usr.sbin/sendmail/src/conf.h | 23 +++++++----- usr/src/usr.sbin/sendmail/src/daemon.c | 31 ++++++++-------- usr/src/usr.sbin/sendmail/src/parseaddr.c | 43 +++++++++++++++++------ usr/src/usr.sbin/sendmail/src/readcf.c | 4 +-- usr/src/usr.sbin/sendmail/src/sendmail.h | 6 ++-- usr/src/usr.sbin/sendmail/src/version.c | 4 +-- 8 files changed, 83 insertions(+), 48 deletions(-) diff --git a/usr/src/usr.sbin/sendmail/src/Makefile b/usr/src/usr.sbin/sendmail/src/Makefile index 832baa1ab3..228430097a 100644 --- a/usr/src/usr.sbin/sendmail/src/Makefile +++ b/usr/src/usr.sbin/sendmail/src/Makefile @@ -1,4 +1,4 @@ -# @(#)Makefile 5.27 (Berkeley) %G% +# @(#)Makefile 5.28 (Berkeley) %G% PROG= sendmail @@ -14,8 +14,8 @@ DBMDEF= -DNEWDB CFLAGS+=-I${.CURDIR} ${DBMDEF} SRCS= alias.c arpadate.c clock.c collect.c conf.c convtime.c daemon.c \ - deliver.c domain.c envelope.c err.c headers.c macro.c main.c mci.c \ - parseaddr.c queue.c readcf.c recipient.c savemail.c srvrsmtp.c \ + deliver.c domain.c envelope.c err.c headers.c macro.c main.c map.c \ + mci.c parseaddr.c queue.c readcf.c recipient.c savemail.c srvrsmtp.c \ stab.c stats.c sysexits.c trace.c udb.c usersmtp.c \ util.c version.c DPADD= ${LIBDBM} ${LIBCOMPAT} ${LIBUTIL} diff --git a/usr/src/usr.sbin/sendmail/src/conf.c b/usr/src/usr.sbin/sendmail/src/conf.c index eaf7dfad89..8e5f5f924c 100644 --- a/usr/src/usr.sbin/sendmail/src/conf.c +++ b/usr/src/usr.sbin/sendmail/src/conf.c @@ -7,7 +7,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)conf.c 5.43 (Berkeley) %G%"; +static char sccsid[] = "@(#)conf.c 5.44 (Berkeley) %G%"; #endif /* not lint */ # include @@ -210,24 +210,24 @@ setupmaps() # ifdef BTREE_MAP /* new database file access -- btree files */ { - extern void bt_map_init(); - extern char *bt_map_lookup(); + extern bool bt_map_init(); + extern char *db_map_lookup(); s = stab("btree", ST_MAPCLASS, ST_ENTER); s->s_mapclass.map_init = bt_map_init; - s->s_mapclass.map_lookup = bt_map_lookup; + s->s_mapclass.map_lookup = db_map_lookup; } # endif # ifdef HASH_MAP /* new database file access -- hash files */ { - extern void hash_map_init(); - extern char *hash_map_lookup(); + extern bool hash_map_init(); + extern char *db_map_lookup(); s = stab("hash", ST_MAPCLASS, ST_ENTER); s->s_mapclass.map_init = hash_map_init; - s->s_mapclass.map_lookup = hash_map_lookup; + s->s_mapclass.map_lookup = db_map_lookup; } # endif diff --git a/usr/src/usr.sbin/sendmail/src/conf.h b/usr/src/usr.sbin/sendmail/src/conf.h index d85d64454d..b7a8bf1c1b 100644 --- a/usr/src/usr.sbin/sendmail/src/conf.h +++ b/usr/src/usr.sbin/sendmail/src/conf.h @@ -5,7 +5,7 @@ * * %sccs.include.redist.c% * - * @(#)conf.h 5.28 (Berkeley) %G% + * @(#)conf.h 5.29 (Berkeley) %G% */ /* @@ -41,10 +41,6 @@ ** #define these if they are available; comment them out otherwise. */ -# ifdef hpux -# define SYSTEM5 1 -# endif - # define LOG 1 /* enable logging */ # define SMTP 1 /* enable user and server SMTP */ # define QUEUE 1 /* enable queueing */ @@ -56,6 +52,20 @@ # ifdef NEWDB # define USERDB 1 /* look in user database (requires NEWDB) */ +# define BTREE_MAP 1 /* enable BTREE mapping type (requires NEWDB) */ +/*# define HASH_MAP 1 /* enable HASH mapping type (requires NEWDB) */ +# endif + +# ifdef NDBM +# define DBM_MAP 1 /* enable DBM mapping type (requires NDBM) */ +# endif + +/* +** Some general configuration -- you shouldn't have to touch these +*/ + +# ifdef hpux +# define SYSTEM5 1 # endif # ifdef SYSTEM5 @@ -63,9 +73,6 @@ # define LOCKF 1 /* use System V lockf instead of flock */ # define SYS5TZ 1 /* use System V style timezones */ -# define index strchr -# define rindex strrchr - # endif /* diff --git a/usr/src/usr.sbin/sendmail/src/daemon.c b/usr/src/usr.sbin/sendmail/src/daemon.c index f79f841a04..324b2aaf93 100644 --- a/usr/src/usr.sbin/sendmail/src/daemon.c +++ b/usr/src/usr.sbin/sendmail/src/daemon.c @@ -12,9 +12,9 @@ #ifndef lint #ifdef DAEMON -static char sccsid[] = "@(#)daemon.c 5.51 (Berkeley) %G% (with daemon mode)"; +static char sccsid[] = "@(#)daemon.c 5.52 (Berkeley) %G% (with daemon mode)"; #else -static char sccsid[] = "@(#)daemon.c 5.51 (Berkeley) %G% (without daemon mode)"; +static char sccsid[] = "@(#)daemon.c 5.52 (Berkeley) %G% (without daemon mode)"; #endif #endif /* not lint */ @@ -52,9 +52,8 @@ static char sccsid[] = "@(#)daemon.c 5.51 (Berkeley) %G% (without daemon mode)"; ** appropriate for communication. Returns zero on ** success, else an exit status describing the ** error. -** maphostname(hbuf, hbufsize, avp) -** Convert the entry in hbuf into a canonical form. It -** may not be larger than hbufsize. +** maphostname(map, hbuf, hbufsiz, avp) +** Convert the entry in hbuf into a canonical form. */ static FILE *MailPort; /* port that mail comes in on */ @@ -397,6 +396,7 @@ myhostname(hostbuf, size) ** MAPHOSTNAME -- turn a hostname into canonical form ** ** Parameters: +** map -- a pointer to this map (unused). ** hbuf -- a buffer containing a hostname. ** hbsize -- the size of hbuf. ** avp -- unused -- for compatibility with other mapping @@ -413,17 +413,19 @@ myhostname(hostbuf, size) */ char * -maphostname(hbuf, hbsize, avp) +maphostname(map, hbuf, hbsize, avp) + MAP *map; char *hbuf; int hbsize; char **avp; { register struct hostent *hp; u_long in_addr; - char ptr[256], *cp; + char *cp; struct hostent *gethostbyaddr(); - /* allow room for trailing dot on correct match */ + /* allow room for null & trailing dot on correct match */ + hbsize--; if (ConfigLevel >= 2) hbsize--; @@ -453,17 +455,17 @@ maphostname(hbuf, hbsize, avp) else return NULL; } - if ((cp = strchr(strcpy(ptr, hbuf), ']')) == NULL) + if ((cp = strchr(hbuf, ']')) == NULL) return (NULL); *cp = '\0'; - in_addr = inet_addr(&ptr[1]); + in_addr = inet_addr(&hbuf[1]); hp = gethostbyaddr((char *)&in_addr, sizeof(struct in_addr), AF_INET); if (hp == NULL) return (NULL); /* found a match -- copy and dot terminate */ - if (strlen(hp->h_name) >= hbsize) - hp->h_name[hbsize - 1] = '\0'; + if (strlen(hp->h_name) > hbsize) + hp->h_name[hbsize] = '\0'; (void) strcpy(hbuf, hp->h_name); if (ConfigLevel >= 2) (void) strcat(hbuf, "."); @@ -502,8 +504,8 @@ myhostname(hostbuf, size) ** MAPHOSTNAME -- turn a hostname into canonical form ** ** Parameters: +** map -- a pointer to the database map. ** hbuf -- a buffer containing a hostname. -** hbsize -- the size of hbuf. ** avp -- a pointer to a (cf file defined) argument vector. ** ** Returns: @@ -519,7 +521,8 @@ myhostname(hostbuf, size) /*ARGSUSED*/ char * -maphostname(hbuf, hbsize, avp) +maphostname(map, hbuf, hbsize, avp) + MAP *map; char *hbuf; int hbsize; char **avp; diff --git a/usr/src/usr.sbin/sendmail/src/parseaddr.c b/usr/src/usr.sbin/sendmail/src/parseaddr.c index 2fd5d59f1c..d8f6fa7f20 100644 --- a/usr/src/usr.sbin/sendmail/src/parseaddr.c +++ b/usr/src/usr.sbin/sendmail/src/parseaddr.c @@ -7,7 +7,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)parseaddr.c 5.25 (Berkeley) %G%"; +static char sccsid[] = "@(#)parseaddr.c 5.26 (Berkeley) %G%"; #endif /* not lint */ #include "sendmail.h" @@ -1178,6 +1178,7 @@ backup: char **default_rvp; char hbuf[MAXNAME + 1], ubuf[MAXNAME + 1]; char *pvpb1[MAXATOM + 1]; + char *argvect[10]; char pvpbuf[PSBUFSIZE]; bool match, defaultpart; char begintype; @@ -1195,7 +1196,6 @@ backup: begintype = **rvp; hbrvp = rvp; ubrvp = NULL; - arg_rvp = default_rvp = NULL; if (**rvp == HOSTBEGIN) { endtoken = HOSTEND; @@ -1212,27 +1212,50 @@ backup: /* extract the match part */ key_rvp = ++rvp; + default_rvp = NULL; + arg_rvp = argvect; + xpvp = NULL; + replac = pvpbuf; while (*rvp != NULL && **rvp != endtoken) { - switch (**rvp) + int nodetype = **rvp; + + if (nodetype != CANONHOST && nodetype != CANONUSER) + { + rvp++; + continue; + } + + *rvp++ = NULL; + + if (xpvp != NULL) + { + cataddr(xpvp, replac, + &pvpbuf[sizeof pvpbuf] - replac); + *++arg_rvp = replac; + replac += strlen(replac) + 1; + xpvp = NULL; + } + switch (nodetype) { case CANONHOST: - *rvp++ = NULL; - arg_rvp = rvp; + xpvp = rvp; break; case CANONUSER: - *rvp++ = NULL; default_rvp = rvp; break; - - default: - rvp++; - break; } } if (*rvp != NULL) *rvp++ = NULL; + if (xpvp != NULL) + { + cataddr(xpvp, replac, + &pvpbuf[sizeof pvpbuf] - replac); + *++arg_rvp = replac; + } + *++arg_rvp = NULL; /* save the remainder of the input string */ trsize = (int) (avp - rvp + 1) * sizeof *rvp; diff --git a/usr/src/usr.sbin/sendmail/src/readcf.c b/usr/src/usr.sbin/sendmail/src/readcf.c index 58b9ef7761..b5afa60086 100644 --- a/usr/src/usr.sbin/sendmail/src/readcf.c +++ b/usr/src/usr.sbin/sendmail/src/readcf.c @@ -7,7 +7,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)readcf.c 5.48 (Berkeley) %G%"; +static char sccsid[] = "@(#)readcf.c 5.49 (Berkeley) %G%"; #endif /* not lint */ # include "sendmail.h" @@ -1110,6 +1110,6 @@ makemapentry(line) map = stab(mapname, ST_MAP, ST_ENTER); map->s_map.map_class = &class->s_mapclass; - if ((*class->s_mapclass.map_init)(&map->s_map, p)) + if ((*class->s_mapclass.map_init)(&map->s_map, mapname, p)) map->s_map.map_flags |= MF_VALID; } diff --git a/usr/src/usr.sbin/sendmail/src/sendmail.h b/usr/src/usr.sbin/sendmail/src/sendmail.h index 7edd706003..b61d181250 100644 --- a/usr/src/usr.sbin/sendmail/src/sendmail.h +++ b/usr/src/usr.sbin/sendmail/src/sendmail.h @@ -5,7 +5,7 @@ * * %sccs.include.redist.c% * - * @(#)sendmail.h 5.40 (Berkeley) %G% + * @(#)sendmail.h 5.41 (Berkeley) %G% */ /* @@ -15,7 +15,7 @@ # ifdef _DEFINE # define EXTERN # ifndef lint -static char SmailSccsId[] = "@(#)sendmail.h 5.40 %G%"; +static char SmailSccsId[] = "@(#)sendmail.h 5.41 %G%"; # endif lint # else /* _DEFINE */ # define EXTERN extern @@ -429,10 +429,12 @@ MAP MAPCLASS *map_class; /* the class of this map */ int map_flags; /* flags, see below */ char *map_file; /* the (nominal) filename */ + void *map_db; /* the open database ptr */ }; /* bit values for map_flags */ # define MF_VALID 00001 /* this entry is valid */ +# define MF_INCLNULL 00002 /* include null byte in key */ /* ** Symbol table definitions */ diff --git a/usr/src/usr.sbin/sendmail/src/version.c b/usr/src/usr.sbin/sendmail/src/version.c index 82365a525e..4377690b87 100644 --- a/usr/src/usr.sbin/sendmail/src/version.c +++ b/usr/src/usr.sbin/sendmail/src/version.c @@ -7,7 +7,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)version.c 5.123 (Berkeley) %G%"; +static char sccsid[] = "@(#)version.c 5.124 (Berkeley) %G%"; #endif /* not lint */ -char Version[] = "5.123"; +char Version[] = "5.124"; -- 2.20.1