Lines Matching +full:ep +full:- +full:side

2  * Copyright (c) 1998-2003 Proofpoint, Inc. and its suppliers.
4 * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved.
16 SM_RCSID("@(#)$Id: alias.c,v 8.221 2013-11-22 20:51:54 ca Exp $")
29 ** ALIAS -- Compute aliases.
33 ** Uses libdbm database if -DDBM.
36 ** a -- address to alias.
37 ** sendq -- a pointer to the head of the send queue
39 ** aliaslevel -- the current alias nesting depth.
40 ** e -- the current envelope.
45 ** Side Effects:
66 sm_dprintf("alias(%s)\n", a->q_user);
69 if (!QS_IS_OK(a->q_state))
75 e->e_to = a->q_paddr;
87 ** envelope <> can't be sent to mailing lists, only owner-
88 ** send spam of this type to owner- of the list
89 ** ---- to stop spam from going to mailing lists!
92 if (e->e_sender != NULL && *e->e_sender == '\0')
95 (void) sm_strlcpyn(obuf, sizeof(obuf), 2, "owner-", a->q_user);
96 if (aliaslookup(obuf, &status, a->q_host) != NULL)
99 sm_syslog(LOG_WARNING, e->e_id,
101 a->q_user, obuf);
102 a->q_user = sm_rpool_strdup_x(e->e_rpool, obuf);
107 p = aliaslookup(a->q_user, &status, a->q_host);
110 a->q_state = QS_QUEUEUP;
111 if (e->e_message == NULL)
112 e->e_message = sm_rpool_strdup_x(e->e_rpool,
116 if (a->q_message == NULL)
117 a->q_message = "alias database unavailable";
130 a->q_paddr, a->q_host, a->q_user, p);
131 if (bitset(EF_VRFYONLY, e->e_flags))
133 a->q_state = QS_VERIFIED;
138 sm_syslog(LOG_INFO, e->e_id,
140 a->q_paddr, shortenstring(p, MAXSHORTSTR));
141 a->q_flags &= ~QSELFREF;
147 a->q_state = QS_EXPANDED;
155 a->q_uid = DefUid;
156 a->q_gid = 0;
157 a->q_fullname = NULL;
158 a->q_flags |= QGOODUID|QALIAS;
162 if (bitset(QSELFREF, a->q_flags) && QS_IS_EXPANDED(a->q_state))
163 a->q_state = QS_OK;
169 if (strncmp(a->q_user, "owner-", 6) == 0 ||
170 strlen(a->q_user) > sizeof(obuf) - 7)
171 (void) sm_strlcpy(obuf, "owner-owner", sizeof(obuf));
173 (void) sm_strlcpyn(obuf, sizeof(obuf), 2, "owner-", a->q_user);
174 owner = aliaslookup(obuf, &status, a->q_host);
181 a->q_owner = sm_rpool_strdup_x(e->e_rpool, owner);
184 if (e->e_xfp != NULL)
185 (void) sm_io_fprintf(e->e_xfp, SM_TIME_DEFAULT,
187 a->q_paddr);
188 e->e_flags |= EF_SENDRECEIPT;
189 a->q_flags |= QDELIVERED|QEXPANDED;
193 ** ALIASLOOKUP -- look up a name in the alias file.
196 ** name -- the name to look up [i]
197 ** pstat -- a pointer to a place to put the status.
198 ** av -- argument for %1 expansion.
232 map = &s->s_map;
236 /* special case POstMastER -- always use lower case */
255 res = (*map->map_class->map_lookup)(map, name, argv, pstat);
263 ** SETALIAS -- set up an alias map
268 ** spec -- the alias specification
315 map = &s->s_map;
317 map->map_mname = s->s_name;
329 map->map_mflags = MF_INCLNULL;
359 sm_dprintf(" map %s:%s %s\n", class, s->s_name, spec);
367 else if (!bitset(MCF_ALIASOK, s->s_mapclass.map_cflags))
374 map->map_class = &s->s_mapclass;
375 map->map_mflags |= MF_ALIAS;
376 if (map->map_class->map_parse(map, spec))
378 map->map_mflags |= MF_VALID;
379 AliasFileMap->map_stack[NAliasFileMaps++] = map;
386 ** ALIASWAIT -- wait for distinguished @:@ token to appear.
391 ** map -- a pointer to the map descriptor for this alias file.
392 ** ext -- the filename extension (e.g., ".db") for the
394 ** isopen -- if set, the database is already open, and we
399 ** true -- if the database is open when we return.
400 ** false -- if the database is closed when we return.
416 map->map_class->map_cname, map->map_file,
417 isopen, bitset(MF_ALIASWAIT, map->map_mflags));
418 if (bitset(MF_ALIASWAIT, map->map_mflags))
420 map->map_mflags |= MF_ALIASWAIT;
430 map->map_class->map_lookup(map, "@", NULL, &st) == NULL)
440 ** Close and re-open the alias database in case
451 map->map_mflags |= MF_CLOSING;
452 map->map_class->map_close(map);
453 map->map_mflags &= ~(MF_OPEN|MF_WRITABLE|MF_CLOSING|MF_CHKED_CHGD);
458 isopen = map->map_class->map_open(map, O_RDONLY);
461 map->map_mflags &= ~MF_CHKED_CHGD;
463 /* see if we need to go into auto-rebuild mode */
464 if (!bitset(MCF_REBUILDABLE, map->map_class->map_cflags))
468 map->map_mflags &= ~MF_ALIASWAIT;
471 if (stat(map->map_file, &stb) < 0)
475 map->map_mflags &= ~MF_ALIASWAIT;
480 map->map_file, ext == NULL ? "" : ext) >= sizeof(buf))
485 map->map_file, ext == NULL ? "" : ext);
487 map->map_file, ext == NULL ? "" : ext);
497 map->map_mflags &= ~MF_ALIASWAIT;
501 ** REBUILDALIASES -- rebuild the alias database.
504 ** map -- the database to rebuild.
509 ** Side Effects:
526 if (!bitset(MCF_REBUILDABLE, map->map_class->map_cflags))
537 if ((af = safefopen(map->map_file, O_RDWR, 0, sff)) == NULL)
542 (af = safefopen(map->map_file, O_RDONLY, 0, sff)) == NULL)
548 map->map_file, sm_errstring(saveerr));
549 if (!bitset(MF_OPTIONAL, map->map_mflags))
551 map->map_file, sm_errstring(saveerr));
560 map->map_file, sm_errstring(errno));
565 !lockfile(sm_io_getinfo(af, SM_IO_WHAT_FD, NULL), map->map_file,
568 /* yes, they are -- wait until done */
570 map->map_file);
575 map->map_file, NULL, LOCK_EX);
588 if (map->map_class->map_open(map, O_RDWR))
594 map->map_file, username());
596 map->map_mflags |= MF_OPEN|MF_WRITABLE;
597 map->map_pid = CurrentPid;
605 map->map_file, sm_errstring(errno));
607 map->map_file);
614 if (bitset(MF_OPEN, map->map_mflags))
621 sl = tTdlevel(78) - 100;
623 sl, map->map_file);
628 map->map_mflags |= MF_CLOSING;
629 map->map_class->map_close(map);
630 map->map_mflags &= ~(MF_OPEN|MF_WRITABLE|MF_CLOSING);
643 ** CONTLINE -- handle potential continuation line
646 ** fp -- file to read
647 ** line -- current line
653 ** Side Effects:
666 if ((p = strchr(line, '\n')) != NULL && p > line && p[-1] == '\\')
669 *--p = '\0';
682 if (nlp > p && nlp[-1] == '\n')
683 *--nlp = '\0';
690 ** READALIASES -- read and process the alias file.
696 ** map -- the alias database descriptor.
697 ** af -- file to read the aliases from.
698 ** announcestats -- announce statistics regarding number of
700 ** logstats -- lot the same info.
705 ** Side Effects:
734 FileName = map->map_file;
817 syserr("554 5.3.5 Non-continuation line starts with space");
826 ** It should resolve to a local name -- this will
860 if (nlp > p && nlp[-1] == '\n')
861 *--nlp = '\0';
891 if (!bitnset(M_ALIASABLE, al.q_mailer->m_flags))
893 syserr("554 5.3.5 %s... cannot alias non-local names",
901 ** Special case pOStmaStER -- always make it lower case.
905 makelower_a(&al.q_user, CurEnv->e_rpool);
928 map->map_class->map_store(map, lhsbuf, rhsbuf);
933 map->map_class->map_store(map, al.q_user, rhs);
943 CurEnv->e_to = NULL;
947 map->map_file, naliases, longest, bytes);
951 map->map_file, naliases, longest, bytes);
954 ** FORWARD -- Try to forward mail
959 ** user -- the name of the user who's mail we would like
960 ** to forward to. It must have been verified --
962 ** sendq -- a pointer to the head of the send queue to
964 ** aliaslevel -- the current alias nesting depth.
965 ** e -- the current envelope.
970 ** Side Effects:
982 char *ep; local
986 sm_dprintf("forward(%s)\n", user->q_paddr);
988 if (!bitnset(M_HASPWENT, user->q_mailer->m_flags) ||
989 !QS_IS_OK(user->q_state))
993 if (user->q_home == NULL)
996 user->q_home = "/no/such/directory";
999 /* good address -- look for .forward file in home */
1000 macdefine(&e->e_macro, A_PERM, 'z', user->q_home);
1001 macdefine(&e->e_macro, A_PERM, 'u', user->q_user);
1002 pp = user->q_host;
1011 macdefine(&e->e_macro, A_PERM, 'h', pp);
1016 for (pp = ForwardPath; pp != NULL; pp = ep)
1022 ep = strchr(pp, SEPARATOR);
1023 if (ep != NULL)
1024 *ep = '\0';
1026 if (ep != NULL)
1027 *ep++ = SEPARATOR;
1048 sm_syslog(LOG_ERR, e->e_id,
1086 sm_syslog(LOG_WARNING, e->e_id,
1105 user->q_state = QS_QUEUEUP;