"files" or "local" alias service type
SCCS-vsn: usr.sbin/sendmail/src/readcf.c 8.97
SCCS-vsn: usr.sbin/sendmail/src/conf.c 8.184
SCCS-vsn: usr.sbin/sendmail/src/alias.c 8.49
# include "sendmail.h"
#ifndef lint
# include "sendmail.h"
#ifndef lint
-static char sccsid[] = "@(#)alias.c 8.48 (Berkeley) %G%";
+static char sccsid[] = "@(#)alias.c 8.49 (Berkeley) %G%";
-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.
**
\f/*
** ALIAS -- Compute aliases.
**
int *pstat;
ENVELOPE *e;
{
int *pstat;
ENVELOPE *e;
{
- register int dbno;
- register MAP *map;
- register char *p;
+ static MAP *map = NULL;
- for (dbno = 0; dbno < NAliasDBs; dbno++)
- 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;
+ 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
}
\f/*
** SETALIAS -- set up an alias map
register MAP *map;
char *class;
STAB *s;
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; )
{
if (tTd(27, 8))
printf("setalias(%s)\n", spec);
for (p = spec; p != NULL; )
{
while (isspace(*p))
p++;
if (*p == '\0')
break;
spec = p;
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;
+ 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");
- (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;
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 (map->map_class->map_parse(map, spec))
{
map->map_mflags |= MF_VALID|MF_ALIAS;
- if (AliasDB[NAliasDBs] == map)
- NAliasDBs++;
+ AliasFileMap->map_stack[NAliasFileMaps++] = map;
-static char sccsid[] = "@(#)conf.c 8.183 (Berkeley) %G%";
+static char sccsid[] = "@(#)conf.c 8.184 (Berkeley) %G%";
#endif /* not lint */
# include "sendmail.h"
#endif /* not lint */
# include "sendmail.h"
{
register int i;
int nmaps;
{
register int i;
int nmaps;
char *maptype[MAXMAPSTACK];
short mapreturn[MAXMAPACTIONS];
char buf[MAXLINE];
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");
stab("hosts.files", ST_MAP, ST_FIND) == NULL)
{
strcpy(buf, "hosts.files text -k 0 -v 1 /etc/hosts");
+ (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");
}
#if NAMED_BIND
else if (strcmp(maptype[i], "dns") == 0 &&
stab("hosts.dns", ST_MAP, ST_FIND) == NULL)
{
strcpy(buf, "hosts.dns dns A");
+ (void) makemapentry(buf);
stab("hosts.nisplus", ST_MAP, ST_FIND) == NULL)
{
strcpy(buf, "hosts.nisplus nisplus -k name -v address -d hosts.org_dir");
stab("hosts.nisplus", ST_MAP, ST_FIND) == NULL)
{
strcpy(buf, "hosts.nisplus nisplus -k name -v address -d hosts.org_dir");
+ (void) makemapentry(buf);
stab("hosts.nis", ST_MAP, ST_FIND) == NULL)
{
strcpy(buf, "hosts.nis nis -d -k 0 -v 1 hosts.byname");
stab("hosts.nis", ST_MAP, ST_FIND) == NULL)
{
strcpy(buf, "hosts.nis nis -d -k 0 -v 1 hosts.byname");
+ (void) makemapentry(buf);
if (ConfigLevel >= 2)
strcat(buf, " -a.");
#endif
if (ConfigLevel >= 2)
strcat(buf, " -a.");
#endif
+ (void) makemapentry(buf);
stab("aliases.files", ST_MAP, ST_FIND) == NULL)
{
strcpy(buf, "aliases.files implicit /etc/aliases");
stab("aliases.files", ST_MAP, ST_FIND) == NULL)
{
strcpy(buf, "aliases.files implicit /etc/aliases");
+ (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");
}
#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");
+ (void) makemapentry(buf);
stab("aliases.nis", ST_MAP, ST_FIND) == NULL)
{
strcpy(buf, "aliases.nis nis -d mail.aliases");
stab("aliases.nis", ST_MAP, ST_FIND) == NULL)
{
strcpy(buf, "aliases.nis nis -d mail.aliases");
+ (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);
- s = stab("aliases", ST_MAP, ST_FIND);
- if (s == NULL)
+ if (stab("aliases", ST_MAP, ST_FIND) == NULL)
{
strcpy(buf, "aliases switch aliases");
{
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 */
}
#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");
stab("users.files", ST_MAP, ST_FIND) == NULL)
{
strcpy(buf, "users.files text -m -z: -k0 -v6 /etc/passwd");
+ (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");
}
#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");
+ (void) makemapentry(buf);
stab("users.nis", ST_MAP, ST_FIND) == NULL)
{
strcpy(buf, "users.nis nis -m -d passwd.byname");
stab("users.nis", ST_MAP, ST_FIND) == NULL)
{
strcpy(buf, "users.nis nis -m -d passwd.byname");
+ (void) makemapentry(buf);
stab("users.hesiod", ST_MAP, ST_FIND) == NULL)
{
strcpy(buf, "users.hesiod hesiod");
stab("users.hesiod", ST_MAP, ST_FIND) == NULL)
{
strcpy(buf, "users.hesiod hesiod");
+ (void) makemapentry(buf);
}
#endif
}
if (stab("users", ST_MAP, ST_FIND) == NULL)
{
strcpy(buf, "users switch -m passwd");
}
#endif
}
if (stab("users", ST_MAP, ST_FIND) == NULL)
{
strcpy(buf, "users switch -m passwd");
+ (void) makemapentry(buf);
-static char sccsid[] = "@(#)readcf.c 8.96 (Berkeley) %G%";
+static char sccsid[] = "@(#)readcf.c 8.97 (Berkeley) %G%";
#endif /* not lint */
# include "sendmail.h"
#endif /* not lint */
# include "sendmail.h"
+ (void) makemapentry(&bp[1]);
** line -- the config file line
**
** Returns:
** line -- the config file line
**
** Returns:
+** A pointer to the map that has been created.
+** NULL if there was a syntax error.
**
** Side Effects:
** Enters the map into the dictionary.
*/
**
** Side Effects:
** Enters the map into the dictionary.
*/
makemapentry(line)
char *line;
{
makemapentry(line)
char *line;
{
if (!(isascii(*p) && isalnum(*p)))
{
syserr("readcf: config K line: no map name");
if (!(isascii(*p) && isalnum(*p)))
{
syserr("readcf: config K line: no map name");
if (!(isascii(*p) && isalnum(*p)))
{
syserr("readcf: config K line, map %s: no map class", mapname);
if (!(isascii(*p) && isalnum(*p)))
{
syserr("readcf: config K line, map %s: no map class", mapname);
}
classname = p;
while (isascii(*++p) && isalnum(*p))
}
classname = p;
while (isascii(*++p) && isalnum(*p))
if (class == NULL)
{
syserr("readcf: map %s: class %s not available", mapname, classname);
if (class == NULL)
{
syserr("readcf: map %s: class %s not available", mapname, classname);
s->s_map.map_domain == NULL ? "(null)" : s->s_map.map_domain,
s->s_map.map_rebuild == NULL ? "(null)" : s->s_map.map_rebuild);
}
s->s_map.map_domain == NULL ? "(null)" : s->s_map.map_domain,
s->s_map.map_rebuild == NULL ? "(null)" : s->s_map.map_rebuild);
}
}
\f/*
** INITTIMEOUTS -- parse and set timeout values
}
\f/*
** INITTIMEOUTS -- parse and set timeout values