# include "sendmail.h"
#ifndef lint
-static char sccsid[] = "@(#)alias.c 8.48 (Berkeley) %G%";
+static char sccsid[] = "@(#)alias.c 8.49 (Berkeley) %G%";
#endif /* not lint */
-MAP *AliasDB[MAXALIASDB + 1]; /* actual database list */
-int NAliasDBs = 1; /* number of alias databases */
+MAP *AliasFileMap = NULL; /* the actual aliases.files map */
+int NAliasFileMaps; /* the number of entries in AliasFileMap */
\f/*
** ALIAS -- Compute aliases.
**
int *pstat;
ENVELOPE *e;
{
- register int dbno;
- register MAP *map;
- register char *p;
+ static MAP *map = NULL;
- for (dbno = 0; dbno < NAliasDBs; dbno++)
+ if (map == NULL)
{
- map = AliasDB[dbno];
- if (map == NULL || !bitset(MF_OPEN, map->map_mflags))
- continue;
- p = (*map->map_class->map_lookup)(map, name, NULL, pstat);
- if (p != NULL)
- return p;
+ STAB *s = stab("aliases", ST_MAP, ST_FIND);
+
+ if (s == NULL)
+ return NULL;
+ map = &s->s_map;
}
- return NULL;
+ if (!bitset(MF_OPEN, map->map_mflags))
+ return NULL;
+ return (*map->map_class->map_lookup)(map, name, NULL, pstat);
}
\f/*
** SETALIAS -- set up an alias map
register MAP *map;
char *class;
STAB *s;
- static bool first_unqual = TRUE;
if (tTd(27, 8))
printf("setalias(%s)\n", spec);
for (p = spec; p != NULL; )
{
+ char buf[50];
+
while (isspace(*p))
p++;
if (*p == '\0')
break;
spec = p;
- /*
- ** Treat simple filename specially -- this is the file name
- ** for the files implementation, not necessarily in order.
- */
-
- if (spec[0] == '/' && first_unqual)
+ if (NAliasFileMaps >= MAXMAPSTACK)
{
- s = stab("aliases.files", ST_MAP, ST_ENTER);
- map = &s->s_map;
- first_unqual = FALSE;
+ syserr("Too many alias databases defined, %d max",
+ MAXMAPSTACK);
+ return;
}
- else
+ if (AliasFileMap == NULL)
{
- char aname[50];
-
- if (NAliasDBs >= MAXALIASDB)
+ strcpy(buf, "aliases.files sequence");
+ AliasFileMap = makemapentry(buf);
+ if (AliasFileMap == NULL)
{
- syserr("Too many alias databases defined, %d max",
- MAXALIASDB);
+ syserr("setalias: cannot create aliases.files map");
return;
}
- (void) sprintf(aname, "Alias%d", NAliasDBs);
- s = stab(aname, ST_MAP, ST_ENTER);
- map = &s->s_map;
- AliasDB[NAliasDBs] = map;
}
+ (void) sprintf(buf, "Alias%d", NAliasFileMaps);
+ s = stab(buf, ST_MAP, ST_ENTER);
+ map = &s->s_map;
bzero(map, sizeof *map);
map->map_mname = s->s_name;
if (map->map_class->map_parse(map, spec))
{
map->map_mflags |= MF_VALID|MF_ALIAS;
- if (AliasDB[NAliasDBs] == map)
- NAliasDBs++;
+ AliasFileMap->map_stack[NAliasFileMaps++] = map;
}
}
}
*/
#ifndef lint
-static char sccsid[] = "@(#)conf.c 8.183 (Berkeley) %G%";
+static char sccsid[] = "@(#)conf.c 8.184 (Berkeley) %G%";
#endif /* not lint */
# include "sendmail.h"
{
register int i;
int nmaps;
- STAB *s;
char *maptype[MAXMAPSTACK];
short mapreturn[MAXMAPACTIONS];
char buf[MAXLINE];
stab("hosts.files", ST_MAP, ST_FIND) == NULL)
{
strcpy(buf, "hosts.files text -k 0 -v 1 /etc/hosts");
- makemapentry(buf);
+ (void) makemapentry(buf);
}
#if NAMED_BIND
else if (strcmp(maptype[i], "dns") == 0 &&
stab("hosts.dns", ST_MAP, ST_FIND) == NULL)
{
strcpy(buf, "hosts.dns dns A");
- makemapentry(buf);
+ (void) makemapentry(buf);
}
#endif
#ifdef NISPLUS
stab("hosts.nisplus", ST_MAP, ST_FIND) == NULL)
{
strcpy(buf, "hosts.nisplus nisplus -k name -v address -d hosts.org_dir");
- makemapentry(buf);
+ (void) makemapentry(buf);
}
#endif
#ifdef NIS
stab("hosts.nis", ST_MAP, ST_FIND) == NULL)
{
strcpy(buf, "hosts.nis nis -d -k 0 -v 1 hosts.byname");
- makemapentry(buf);
+ (void) makemapentry(buf);
}
#endif
}
if (ConfigLevel >= 2)
strcat(buf, " -a.");
#endif
- makemapentry(buf);
+ (void) makemapentry(buf);
}
/*
stab("aliases.files", ST_MAP, ST_FIND) == NULL)
{
strcpy(buf, "aliases.files implicit /etc/aliases");
- makemapentry(buf);
+ (void) makemapentry(buf);
}
#ifdef NISPLUS
else if (strcmp(maptype[i], "nisplus") == 0 &&
stab("aliases.nisplus", ST_MAP, ST_FIND) == NULL)
{
strcpy(buf, "aliases.nisplus nisplus -kalias -vexpansion -d mail_aliases.org_dir");
- makemapentry(buf);
+ (void) makemapentry(buf);
}
#endif
#ifdef NIS
stab("aliases.nis", ST_MAP, ST_FIND) == NULL)
{
strcpy(buf, "aliases.nis nis -d mail.aliases");
- makemapentry(buf);
+ (void) makemapentry(buf);
+ }
+#endif
+#ifdef HESIOD
+ else if (strcmp(maptype[i], "hesiod") == 0 &&
+ stab("aliases.hesiod", ST_MAP, ST_FIND) == NULL)
+ {
+ strcpy(buf, "aliases.hesiod hesiod aliases");
+ (void) makemapentry(buf);
}
#endif
}
- s = stab("aliases", ST_MAP, ST_FIND);
- if (s == NULL)
+ if (stab("aliases", ST_MAP, ST_FIND) == NULL)
{
strcpy(buf, "aliases switch aliases");
- makemapentry(buf);
- s = stab("aliases", ST_MAP, ST_FIND);
- }
- if (s == NULL)
- syserr("inithostmaps: cannot initialize default aliases map");
- else
- {
- extern MAP *AliasDB[MAXALIASDB + 1];
-
- AliasDB[0] = &s->s_map;
+ (void) makemapentry(buf);
}
#if 0 /* "user" map class is a better choice */
stab("users.files", ST_MAP, ST_FIND) == NULL)
{
strcpy(buf, "users.files text -m -z: -k0 -v6 /etc/passwd");
- makemapentry(buf);
+ (void) makemapentry(buf);
}
#ifdef NISPLUS
else if (strcmp(maptype[i], "nisplus") == 0 &&
stab("users.nisplus", ST_MAP, ST_FIND) == NULL)
{
strcpy(buf, "users.nisplus nisplus -m -kname -vhome -d passwd.org_dir");
- makemapentry(buf);
+ (void) makemapentry(buf);
}
#endif
#ifdef NIS
stab("users.nis", ST_MAP, ST_FIND) == NULL)
{
strcpy(buf, "users.nis nis -m -d passwd.byname");
- makemapentry(buf);
+ (void) makemapentry(buf);
}
#endif
#ifdef HESIOD
stab("users.hesiod", ST_MAP, ST_FIND) == NULL)
{
strcpy(buf, "users.hesiod hesiod");
- makemapentry(buf);
+ (void) makemapentry(buf);
}
#endif
}
if (stab("users", ST_MAP, ST_FIND) == NULL)
{
strcpy(buf, "users switch -m passwd");
- makemapentry(buf);
+ (void) makemapentry(buf);
}
#endif
}
*/
#ifndef lint
-static char sccsid[] = "@(#)readcf.c 8.96 (Berkeley) %G%";
+static char sccsid[] = "@(#)readcf.c 8.97 (Berkeley) %G%";
#endif /* not lint */
# include "sendmail.h"
break;
case 'K':
- makemapentry(&bp[1]);
+ (void) makemapentry(&bp[1]);
break;
case 'E':
** line -- the config file line
**
** Returns:
-** none.
+** A pointer to the map that has been created.
+** NULL if there was a syntax error.
**
** Side Effects:
** Enters the map into the dictionary.
*/
-void
+MAP *
makemapentry(line)
char *line;
{
if (!(isascii(*p) && isalnum(*p)))
{
syserr("readcf: config K line: no map name");
- return;
+ return NULL;
}
mapname = p;
if (!(isascii(*p) && isalnum(*p)))
{
syserr("readcf: config K line, map %s: no map class", mapname);
- return;
+ return NULL;
}
classname = p;
while (isascii(*++p) && isalnum(*p))
if (class == NULL)
{
syserr("readcf: map %s: class %s not available", mapname, classname);
- return;
+ return NULL;
}
/* enter the map */
s->s_map.map_domain == NULL ? "(null)" : s->s_map.map_domain,
s->s_map.map_rebuild == NULL ? "(null)" : s->s_map.map_rebuild);
}
+
+ return &s->s_map;
}
\f/*
** INITTIMEOUTS -- parse and set timeout values