Deleted Added
sdiff udiff text old ( 141858 ) new ( 147078 )
full compact
1/*
2 * Copyright (c) 1998-2005 Sendmail, Inc. and its suppliers.
3 * All rights reserved.
4 * Copyright (c) 1992, 1995-1997 Eric P. Allman. All rights reserved.
5 * Copyright (c) 1992, 1993
6 * The Regents of the University of California. All rights reserved.
7 *
8 * By using this file, you agree to the terms and conditions set
9 * forth in the LICENSE file which can be found at the top level of
10 * the sendmail distribution.
11 *
12 */
13
14#include <sendmail.h>
15
16SM_RCSID("@(#)$Id: map.c,v 8.669 2005/02/09 01:46:35 ca Exp $")
17
18#if LDAPMAP
19# include <sm/ldap.h>
20#endif /* LDAPMAP */
21
22#if NDBM
23# include <ndbm.h>
24# ifdef R_FIRST

--- 5627 unchanged lines hidden (view full) ---

5652{
5653 register STAB *s;
5654
5655 if (tTd(38, 20))
5656 sm_dprintf("stab_lookup(%s, %s)\n",
5657 map->map_mname, name);
5658
5659 s = stab(name, ST_ALIAS, ST_FIND);
5660 if (s == NULL)
5661 return NULL;
5662 if (bitset(MF_MATCHONLY, map->map_mflags))
5663 return map_rewrite(map, name, strlen(name), NULL);
5664 else
5665 return map_rewrite(map, s->s_alias, strlen(s->s_alias), av);
5666}
5667
5668/*
5669** STAB_MAP_STORE -- store in symtab (actually using during init, not rebuild)
5670*/
5671
5672void
5673stab_map_store(map, lhs, rhs)
5674 register MAP *map;
5675 char *lhs;

--- 1875 unchanged lines hidden (view full) ---

7551char *
7552socket_map_lookup(map, name, av, statp)
7553 MAP *map;
7554 char *name;
7555 char **av;
7556 int *statp;
7557{
7558 unsigned int nettolen, replylen, recvlen;
7559 char *replybuf, *rval, *value, *status, *key;
7560 SM_FILE_T *f;
7561 char keybuf[MAXNAME + 1];
7562
7563 replybuf = NULL;
7564 rval = NULL;
7565 f = (SM_FILE_T *)map->map_db1;
7566 if (tTd(38, 20))
7567 sm_dprintf("socket_map_lookup(%s, %s) %s\n",
7568 map->map_mname, name, map->map_file);
7569
7570 if (!bitset(MF_NOFOLDCASE, map->map_mflags))
7571 {
7572 nettolen = strlen(name);
7573 if (nettolen > sizeof keybuf - 1)
7574 nettolen = sizeof keybuf - 1;
7575 memmove(keybuf, name, nettolen);
7576 keybuf[nettolen] = '\0';
7577 makelower(keybuf);
7578 key = keybuf;
7579 }
7580 else
7581 key = name;
7582
7583 nettolen = strlen(map->map_mname) + 1 + strlen(key);
7584 SM_ASSERT(nettolen > strlen(map->map_mname));
7585 SM_ASSERT(nettolen > strlen(key));
7586 if ((sm_io_fprintf(f, SM_TIME_DEFAULT, "%u:%s %s,",
7587 nettolen, map->map_mname, key) == SM_IO_EOF) ||
7588 (sm_io_flush(f, SM_TIME_DEFAULT) != 0) ||
7589 (sm_io_error(f)))
7590 {
7591 syserr("451 4.3.0 socket_map_lookup(%s): failed to send lookup request",
7592 map->map_mname);
7593 *statp = EX_TEMPFAIL;
7594 goto errcl;
7595 }

--- 53 unchanged lines hidden (view full) ---

7649 value++;
7650 }
7651 if (strcmp(status, "OK") == 0)
7652 {
7653 *statp = EX_OK;
7654
7655 /* collect the return value */
7656 if (bitset(MF_MATCHONLY, map->map_mflags))
7657 rval = map_rewrite(map, key, strlen(key), NULL);
7658 else
7659 rval = map_rewrite(map, value, strlen(value), av);
7660 }
7661 else if (strcmp(status, "NOTFOUND") == 0)
7662 {
7663 *statp = EX_NOTFOUND;
7664 if (tTd(38, 20))
7665 sm_dprintf("socket_map_lookup(%s): %s not found\n",
7666 map->map_mname, key);
7667 }
7668 else
7669 {
7670 if (tTd(38, 5))
7671 sm_dprintf("socket_map_lookup(%s, %s): server returned error: type=%s, reason=%s\n",
7672 map->map_mname, key, status,
7673 value ? value : "");
7674 if ((strcmp(status, "TEMP") == 0) ||
7675 (strcmp(status, "TIMEOUT") == 0))
7676 *statp = EX_TEMPFAIL;
7677 else if(strcmp(status, "PERM") == 0)
7678 *statp = EX_UNAVAILABLE;
7679 else
7680 *statp = EX_PROTOCOL;

--- 14 unchanged lines hidden ---