122704Sdist /*
234921Sbostic  * Copyright (c) 1983 Eric P. Allman
333729Sbostic  * Copyright (c) 1988 Regents of the University of California.
433729Sbostic  * All rights reserved.
533729Sbostic  *
642826Sbostic  * %sccs.include.redist.c%
733729Sbostic  */
822704Sdist 
922704Sdist #ifndef lint
10*58020Seric static char sccsid[] = "@(#)envelope.c	6.8 (Berkeley) 02/16/93";
1133729Sbostic #endif /* not lint */
1222704Sdist 
1336928Sbostic #include <sys/types.h>
1436928Sbostic #include <sys/time.h>
1536928Sbostic #include <sys/stat.h>
169536Seric #include <pwd.h>
1757737Seric #include <fcntl.h>
189536Seric #include "sendmail.h"
199536Seric 
209536Seric /*
219536Seric **  NEWENVELOPE -- allocate a new envelope
229536Seric **
239536Seric **	Supports inheritance.
249536Seric **
259536Seric **	Parameters:
269536Seric **		e -- the new envelope to fill in.
279536Seric **
289536Seric **	Returns:
299536Seric **		e.
309536Seric **
319536Seric **	Side Effects:
329536Seric **		none.
339536Seric */
349536Seric 
359536Seric ENVELOPE *
369536Seric newenvelope(e)
379536Seric 	register ENVELOPE *e;
389536Seric {
399536Seric 	register ENVELOPE *parent;
409536Seric 	extern putheader(), putbody();
4125611Seric 	extern ENVELOPE BlankEnvelope;
429536Seric 
439536Seric 	parent = CurEnv;
4456215Seric 	if (e == CurEnv && e->e_parent != NULL)
459536Seric 		parent = e->e_parent;
4625611Seric 	clearenvelope(e, TRUE);
4724944Seric 	if (e == CurEnv)
4824944Seric 		bcopy((char *) &NullAddress, (char *) &e->e_from, sizeof e->e_from);
4924944Seric 	else
5024944Seric 		bcopy((char *) &CurEnv->e_from, (char *) &e->e_from, sizeof e->e_from);
519536Seric 	e->e_parent = parent;
529536Seric 	e->e_ctime = curtime();
5356215Seric 	if (parent != NULL)
5456215Seric 		e->e_msgpriority = parent->e_msgsize;
559536Seric 	e->e_puthdr = putheader;
569536Seric 	e->e_putbody = putbody;
579536Seric 	if (CurEnv->e_xfp != NULL)
589536Seric 		(void) fflush(CurEnv->e_xfp);
599536Seric 
609536Seric 	return (e);
619536Seric }
629536Seric /*
639536Seric **  DROPENVELOPE -- deallocate an envelope.
649536Seric **
659536Seric **	Parameters:
669536Seric **		e -- the envelope to deallocate.
679536Seric **
689536Seric **	Returns:
699536Seric **		none.
709536Seric **
719536Seric **	Side Effects:
729536Seric **		housekeeping necessary to dispose of an envelope.
739536Seric **		Unlocks this queue file.
749536Seric */
759536Seric 
769536Seric dropenvelope(e)
779536Seric 	register ENVELOPE *e;
789536Seric {
799536Seric 	bool queueit = FALSE;
809536Seric 	register ADDRESS *q;
8157943Seric 	char *id = e->e_id;
829536Seric 
839536Seric 	if (tTd(50, 1))
849536Seric 	{
859536Seric 		printf("dropenvelope %x id=", e);
869536Seric 		xputs(e->e_id);
879536Seric 		printf(" flags=%o\n", e->e_flags);
889536Seric 	}
8957943Seric 
9057943Seric 	if (id == NULL)
9157943Seric 		id = "(none)";
9257943Seric 
939536Seric #ifdef LOG
94*58020Seric 	if (LogLevel > 84)
959536Seric 		syslog(LOG_DEBUG, "dropenvelope, id=%s, flags=%o, pid=%d",
9657943Seric 				  id, e->e_flags, getpid());
9756795Seric #endif /* LOG */
989536Seric 
999536Seric 	/* we must have an id to remove disk files */
1009536Seric 	if (e->e_id == NULL)
1019536Seric 		return;
1029536Seric 
1039536Seric 	/*
1049536Seric 	**  Extract state information from dregs of send list.
1059536Seric 	*/
1069536Seric 
1079536Seric 	for (q = e->e_sendqueue; q != NULL; q = q->q_next)
1089536Seric 	{
1099536Seric 		if (bitset(QQUEUEUP, q->q_flags))
1109536Seric 			queueit = TRUE;
1119536Seric 	}
1129536Seric 
1139536Seric 	/*
1149536Seric 	**  Send back return receipts as requested.
1159536Seric 	*/
1169536Seric 
1179536Seric 	if (e->e_receiptto != NULL && bitset(EF_SENDRECEIPT, e->e_flags))
1189536Seric 	{
11910844Seric 		auto ADDRESS *rlist = NULL;
1209536Seric 
12155012Seric 		sendtolist(e->e_receiptto, (ADDRESS *) NULL, &rlist, e);
12255012Seric 		(void) returntosender("Return receipt", rlist, FALSE, e);
1239536Seric 	}
1249536Seric 
1259536Seric 	/*
1269536Seric 	**  Arrange to send error messages if there are fatal errors.
1279536Seric 	*/
1289536Seric 
12910754Seric 	if (bitset(EF_FATALERRS|EF_TIMEOUT, e->e_flags) && ErrorMode != EM_QUIET)
1309536Seric 		savemail(e);
1319536Seric 
1329536Seric 	/*
1339536Seric 	**  Instantiate or deinstantiate the queue.
1349536Seric 	*/
1359536Seric 
1369536Seric 	if ((!queueit && !bitset(EF_KEEPQUEUE, e->e_flags)) ||
1379536Seric 	    bitset(EF_CLRQUEUE, e->e_flags))
1389536Seric 	{
13923497Seric 		if (e->e_df != NULL)
14023497Seric 			xunlink(e->e_df);
1419536Seric 		xunlink(queuename(e, 'q'));
1429536Seric 	}
1439536Seric 	else if (queueit || !bitset(EF_INQUEUE, e->e_flags))
14410754Seric 	{
14510754Seric #ifdef QUEUE
14651920Seric 		queueup(e, FALSE, FALSE);
14756795Seric #else /* QUEUE */
14810754Seric 		syserr("dropenvelope: queueup");
14956795Seric #endif /* QUEUE */
15010754Seric 	}
1519536Seric 
1529536Seric 	/* now unlock the job */
15310196Seric 	closexscript(e);
1549536Seric 	unlockqueue(e);
1559536Seric 
1569536Seric 	/* make sure that this envelope is marked unused */
1579536Seric 	e->e_id = e->e_df = NULL;
15824944Seric 	if (e->e_dfp != NULL)
15924944Seric 		(void) fclose(e->e_dfp);
16010196Seric 	e->e_dfp = NULL;
16157589Seric 
16257589Seric #ifdef LOG
163*58020Seric 	if (LogLevel > 74)
16457943Seric 		syslog(LOG_INFO, "%s: done", id);
16557589Seric #endif /* LOG */
1669536Seric }
1679536Seric /*
1689536Seric **  CLEARENVELOPE -- clear an envelope without unlocking
1699536Seric **
1709536Seric **	This is normally used by a child process to get a clean
1719536Seric **	envelope without disturbing the parent.
1729536Seric **
1739536Seric **	Parameters:
1749536Seric **		e -- the envelope to clear.
17525611Seric **		fullclear - if set, the current envelope is total
17625611Seric **			garbage and should be ignored; otherwise,
17725611Seric **			release any resources it may indicate.
1789536Seric **
1799536Seric **	Returns:
1809536Seric **		none.
1819536Seric **
1829536Seric **	Side Effects:
1839536Seric **		Closes files associated with the envelope.
1849536Seric **		Marks the envelope as unallocated.
1859536Seric */
1869536Seric 
18725611Seric clearenvelope(e, fullclear)
1889536Seric 	register ENVELOPE *e;
18925611Seric 	bool fullclear;
1909536Seric {
19125514Seric 	register HDR *bh;
19225514Seric 	register HDR **nhp;
19325514Seric 	extern ENVELOPE BlankEnvelope;
19425514Seric 
19525611Seric 	if (!fullclear)
19625611Seric 	{
19725611Seric 		/* clear out any file information */
19825611Seric 		if (e->e_xfp != NULL)
19925611Seric 			(void) fclose(e->e_xfp);
20025611Seric 		if (e->e_dfp != NULL)
20125611Seric 			(void) fclose(e->e_dfp);
20225611Seric 	}
2039536Seric 
20424961Seric 	/* now clear out the data */
20524965Seric 	STRUCTCOPY(BlankEnvelope, *e);
20625514Seric 	bh = BlankEnvelope.e_header;
20725514Seric 	nhp = &e->e_header;
20825514Seric 	while (bh != NULL)
20925514Seric 	{
21025514Seric 		*nhp = (HDR *) xalloc(sizeof *bh);
21125514Seric 		bcopy((char *) bh, (char *) *nhp, sizeof *bh);
21225514Seric 		bh = bh->h_link;
21325514Seric 		nhp = &(*nhp)->h_link;
21425514Seric 	}
2159536Seric }
2169536Seric /*
2179536Seric **  INITSYS -- initialize instantiation of system
2189536Seric **
2199536Seric **	In Daemon mode, this is done in the child.
2209536Seric **
2219536Seric **	Parameters:
2229536Seric **		none.
2239536Seric **
2249536Seric **	Returns:
2259536Seric **		none.
2269536Seric **
2279536Seric **	Side Effects:
2289536Seric **		Initializes the system macros, some global variables,
2299536Seric **		etc.  In particular, the current time in various
2309536Seric **		forms is set.
2319536Seric */
2329536Seric 
23355012Seric initsys(e)
23455012Seric 	register ENVELOPE *e;
2359536Seric {
2369536Seric 	static char cbuf[5];			/* holds hop count */
2379536Seric 	static char pbuf[10];			/* holds pid */
23822963Smiriam #ifdef TTYNAME
2399536Seric 	static char ybuf[10];			/* holds tty id */
2409536Seric 	register char *p;
24156795Seric #endif /* TTYNAME */
2429536Seric 	extern char *ttyname();
2439536Seric 	extern char *macvalue();
2449536Seric 	extern char Version[];
2459536Seric 
2469536Seric 	/*
2479536Seric 	**  Give this envelope a reality.
2489536Seric 	**	I.e., an id, a transcript, and a creation time.
2499536Seric 	*/
2509536Seric 
25155012Seric 	openxscript(e);
25255012Seric 	e->e_ctime = curtime();
2539536Seric 
2549536Seric 	/*
2559536Seric 	**  Set OutChannel to something useful if stdout isn't it.
2569536Seric 	**	This arranges that any extra stuff the mailer produces
2579536Seric 	**	gets sent back to the user on error (because it is
2589536Seric 	**	tucked away in the transcript).
2599536Seric 	*/
2609536Seric 
2619536Seric 	if (OpMode == MD_DAEMON && QueueRun)
26255012Seric 		OutChannel = e->e_xfp;
2639536Seric 
2649536Seric 	/*
2659536Seric 	**  Set up some basic system macros.
2669536Seric 	*/
2679536Seric 
2689536Seric 	/* process id */
2699536Seric 	(void) sprintf(pbuf, "%d", getpid());
27055012Seric 	define('p', pbuf, e);
2719536Seric 
2729536Seric 	/* hop count */
27355012Seric 	(void) sprintf(cbuf, "%d", e->e_hopcount);
27455012Seric 	define('c', cbuf, e);
2759536Seric 
2769536Seric 	/* time as integer, unix time, arpa time */
27755012Seric 	settime(e);
2789536Seric 
27917472Seric #ifdef TTYNAME
2809536Seric 	/* tty name */
28155012Seric 	if (macvalue('y', e) == NULL)
2829536Seric 	{
2839536Seric 		p = ttyname(2);
2849536Seric 		if (p != NULL)
2859536Seric 		{
28656795Seric 			if (strrchr(p, '/') != NULL)
28756795Seric 				p = strrchr(p, '/') + 1;
2889536Seric 			(void) strcpy(ybuf, p);
28955012Seric 			define('y', ybuf, e);
2909536Seric 		}
2919536Seric 	}
29256795Seric #endif /* TTYNAME */
2939536Seric }
2949536Seric /*
29511932Seric **  SETTIME -- set the current time.
29611932Seric **
29711932Seric **	Parameters:
29811932Seric **		none.
29911932Seric **
30011932Seric **	Returns:
30111932Seric **		none.
30211932Seric **
30311932Seric **	Side Effects:
30411932Seric **		Sets the various time macros -- $a, $b, $d, $t.
30511932Seric */
30611932Seric 
30755012Seric settime(e)
30855012Seric 	register ENVELOPE *e;
30911932Seric {
31011932Seric 	register char *p;
31111932Seric 	auto time_t now;
31211932Seric 	static char tbuf[20];			/* holds "current" time */
31311932Seric 	static char dbuf[30];			/* holds ctime(tbuf) */
31411932Seric 	register struct tm *tm;
31511932Seric 	extern char *arpadate();
31611932Seric 	extern struct tm *gmtime();
31711932Seric 	extern char *macvalue();
31811932Seric 
31911932Seric 	now = curtime();
32011932Seric 	tm = gmtime(&now);
32157014Seric 	(void) sprintf(tbuf, "%04d%02d%02d%02d%02d", tm->tm_year + 1900,
32257014Seric 			tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min);
32355012Seric 	define('t', tbuf, e);
32411932Seric 	(void) strcpy(dbuf, ctime(&now));
32556795Seric 	*strchr(dbuf, '\n') = '\0';
32655012Seric 	if (macvalue('d', e) == NULL)
32755012Seric 		define('d', dbuf, e);
32811932Seric 	p = newstr(arpadate(dbuf));
32955012Seric 	if (macvalue('a', e) == NULL)
33055012Seric 		define('a', p, e);
33155012Seric 	define('b', p, e);
33211932Seric }
33311932Seric /*
3349536Seric **  OPENXSCRIPT -- Open transcript file
3359536Seric **
3369536Seric **	Creates a transcript file for possible eventual mailing or
3379536Seric **	sending back.
3389536Seric **
3399536Seric **	Parameters:
3409536Seric **		e -- the envelope to create the transcript in/for.
3419536Seric **
3429536Seric **	Returns:
3439536Seric **		none
3449536Seric **
3459536Seric **	Side Effects:
3469536Seric **		Creates the transcript file.
3479536Seric */
3489536Seric 
3499536Seric openxscript(e)
3509536Seric 	register ENVELOPE *e;
3519536Seric {
3529536Seric 	register char *p;
35340933Srick 	int fd;
3549536Seric 
3559536Seric 	if (e->e_xfp != NULL)
3569536Seric 		return;
3579536Seric 	p = queuename(e, 'x');
35840933Srick 	fd = open(p, O_WRONLY|O_CREAT, 0644);
35940933Srick 	if (fd < 0)
3609536Seric 		syserr("Can't create %s", p);
3619536Seric 	else
36240933Srick 		e->e_xfp = fdopen(fd, "w");
3639536Seric }
3649536Seric /*
36510196Seric **  CLOSEXSCRIPT -- close the transcript file.
36610196Seric **
36710196Seric **	Parameters:
36810196Seric **		e -- the envelope containing the transcript to close.
36910196Seric **
37010196Seric **	Returns:
37110196Seric **		none.
37210196Seric **
37310196Seric **	Side Effects:
37410196Seric **		none.
37510196Seric */
37610196Seric 
37710196Seric closexscript(e)
37810196Seric 	register ENVELOPE *e;
37910196Seric {
38010196Seric 	if (e->e_xfp == NULL)
38110196Seric 		return;
38210196Seric 	(void) fclose(e->e_xfp);
38310196Seric 	e->e_xfp = NULL;
38410196Seric }
38510196Seric /*
3869536Seric **  SETSENDER -- set the person who this message is from
3879536Seric **
3889536Seric **	Under certain circumstances allow the user to say who
3899536Seric **	s/he is (using -f or -r).  These are:
3909536Seric **	1.  The user's uid is zero (root).
3919536Seric **	2.  The user's login name is in an approved list (typically
3929536Seric **	    from a network server).
3939536Seric **	3.  The address the user is trying to claim has a
3949536Seric **	    "!" character in it (since #2 doesn't do it for
3959536Seric **	    us if we are dialing out for UUCP).
3969536Seric **	A better check to replace #3 would be if the
3979536Seric **	effective uid is "UUCP" -- this would require me
3989536Seric **	to rewrite getpwent to "grab" uucp as it went by,
3999536Seric **	make getname more nasty, do another passwd file
4009536Seric **	scan, or compile the UID of "UUCP" into the code,
4019536Seric **	all of which are reprehensible.
4029536Seric **
4039536Seric **	Assuming all of these fail, we figure out something
4049536Seric **	ourselves.
4059536Seric **
4069536Seric **	Parameters:
4079536Seric **		from -- the person we would like to believe this message
4089536Seric **			is from, as specified on the command line.
40953182Seric **		e -- the envelope in which we would like the sender set.
4109536Seric **
4119536Seric **	Returns:
4129536Seric **		none.
4139536Seric **
4149536Seric **	Side Effects:
4159536Seric **		sets sendmail's notion of who the from person is.
4169536Seric */
4179536Seric 
41853182Seric setsender(from, e)
4199536Seric 	char *from;
42053182Seric 	register ENVELOPE *e;
4219536Seric {
4229536Seric 	register char **pvp;
4239536Seric 	char *realname = NULL;
42418665Seric 	register struct passwd *pw;
4259536Seric 	char buf[MAXNAME];
42616913Seric 	char pvpbuf[PSBUFSIZE];
42718665Seric 	extern struct passwd *getpwnam();
4289536Seric 	extern char *macvalue();
4299536Seric 	extern char **prescan();
4309536Seric 	extern bool safefile();
4319536Seric 	extern char *FullName;
4329536Seric 
4339536Seric 	if (tTd(45, 1))
43414786Seric 		printf("setsender(%s)\n", from == NULL ? "" : from);
4359536Seric 
4369536Seric 	/*
4379536Seric 	**  Figure out the real user executing us.
4389536Seric 	**	Username can return errno != 0 on non-errors.
4399536Seric 	*/
4409536Seric 
44152220Seric 	if (QueueRun || OpMode == MD_SMTP)
4429536Seric 		realname = from;
4439536Seric 	if (realname == NULL || realname[0] == '\0')
4449536Seric 	{
4459536Seric 		extern char *username();
4469536Seric 
4479536Seric 		realname = username();
4489536Seric 	}
4499536Seric 
4509536Seric 	/*
4519536Seric 	**  Determine if this real person is allowed to alias themselves.
4529536Seric 	*/
4539536Seric 
4549536Seric 	if (from != NULL)
4559536Seric 	{
4569536Seric 		extern bool trusteduser();
4579536Seric 
45836230Skarels 		if (!trusteduser(realname) && getuid() != geteuid() &&
45956795Seric 		    strchr(from, '!') == NULL && getuid() != 0)
4609536Seric 		{
4619536Seric 			/* network sends -r regardless (why why why?) */
4629536Seric 			/* syserr("%s, you cannot use the -f flag", realname); */
4639536Seric 			from = NULL;
4649536Seric 		}
4659536Seric 	}
4669536Seric 
46757589Seric /*
4689536Seric 	SuprErrs = TRUE;
46957589Seric */
47055012Seric 	if (from == NULL || parseaddr(from, &e->e_from, 1, '\0', e) == NULL)
4719536Seric 	{
47221750Seric 		/* log garbage addresses for traceback */
47355173Seric # ifdef LOG
474*58020Seric 		if (from != NULL && LogLevel > 2)
47521750Seric 		{
47655173Seric 			char *host = RealHostName;
47755173Seric 
47855173Seric 			if (host == NULL)
47955173Seric 				host = MyHostName;
48055173Seric 			syslog(LOG_NOTICE,
48155173Seric 				"from=%s unparseable, received from %s@%s",
48255173Seric 				from, realname, host);
48355173Seric 		}
48456795Seric # endif /* LOG */
48557589Seric 		if (from != NULL)
48657589Seric 			SuprErrs = TRUE;
48757589Seric 		if (from == realname ||
48857589Seric 		    parseaddr(from = newstr(realname), &e->e_from, 1, '\0', e) == NULL)
48924944Seric 		{
49057589Seric 			SuprErrs = TRUE;
49157589Seric 			if (parseaddr("postmaster", &e->e_from, 1, '\0', e) == NULL)
49257589Seric 				syserr("setsender: can't even parse postmaster!");
49324944Seric 		}
4949536Seric 	}
4959536Seric 	else
4969536Seric 		FromFlag = TRUE;
49753182Seric 	e->e_from.q_flags |= QDONTSEND;
49857731Seric 	if (tTd(45, 5))
49957731Seric 	{
50057731Seric 		printf("setsender: QDONTSEND ");
50157731Seric 		printaddr(&e->e_from, FALSE);
50257731Seric 	}
50353182Seric 	loweraddr(&e->e_from);
5049536Seric 	SuprErrs = FALSE;
5059536Seric 
50653736Seric 	pvp = NULL;
50753736Seric 	if (e->e_from.q_mailer == LocalMailer)
5089536Seric 	{
50953736Seric # ifdef USERDB
51053736Seric 		register char *p;
51153736Seric 		extern char *udbsender();
51253736Seric # endif
51317472Seric 
5149536Seric 		/* if the user has given fullname already, don't redefine */
5159536Seric 		if (FullName == NULL)
51653182Seric 			FullName = macvalue('x', e);
51711932Seric 		if (FullName != NULL && FullName[0] == '\0')
5189536Seric 			FullName = NULL;
5199536Seric 
52053736Seric # ifdef USERDB
52153736Seric 		p = udbsender(from);
52253736Seric 
52353736Seric 		if (p != NULL)
5249536Seric 		{
52553736Seric 			/*
52653736Seric 			**  We have an alternate address for the sender
52753736Seric 			*/
52853736Seric 
52953736Seric 			pvp = prescan(p, '\0', pvpbuf);
5309536Seric 		}
53153736Seric # endif /* USERDB */
53253736Seric 
53353736Seric 		if ((pw = getpwnam(e->e_from.q_user)) != NULL)
53453736Seric 		{
53553736Seric 			/*
53653736Seric 			**  Process passwd file entry.
53753736Seric 			*/
53853736Seric 
53953736Seric 
54053736Seric 			/* extract home directory */
54153736Seric 			e->e_from.q_home = newstr(pw->pw_dir);
54253736Seric 			define('z', e->e_from.q_home, e);
54353736Seric 
54453736Seric 			/* extract user and group id */
54553736Seric 			e->e_from.q_uid = pw->pw_uid;
54653736Seric 			e->e_from.q_gid = pw->pw_gid;
54753736Seric 
54853736Seric 			/* extract full name from passwd file */
54953736Seric 			if (FullName == NULL && pw->pw_gecos != NULL &&
55053736Seric 			    strcmp(pw->pw_name, e->e_from.q_user) == 0)
55153736Seric 			{
55253736Seric 				buildfname(pw->pw_gecos, e->e_from.q_user, buf);
55353736Seric 				if (buf[0] != '\0')
55453736Seric 					FullName = newstr(buf);
55553736Seric 			}
55653736Seric 		}
5579536Seric 		if (FullName != NULL)
55853182Seric 			define('x', FullName, e);
5599536Seric 	}
56011625Seric 	else
56111625Seric 	{
56253182Seric 		if (e->e_from.q_home == NULL)
56353182Seric 			e->e_from.q_home = getenv("HOME");
56453182Seric 		e->e_from.q_uid = getuid();
56553182Seric 		e->e_from.q_gid = getgid();
56611625Seric 	}
56711625Seric 
5689536Seric 	/*
5699536Seric 	**  Rewrite the from person to dispose of possible implicit
5709536Seric 	**	links in the net.
5719536Seric 	*/
5729536Seric 
5739536Seric 	if (pvp == NULL)
57453736Seric 		pvp = prescan(from, '\0', pvpbuf);
57553736Seric 	if (pvp == NULL)
5769536Seric 	{
57736233Skarels # ifdef LOG
578*58020Seric 		if (LogLevel > 2)
57936233Skarels 			syslog(LOG_NOTICE, "cannot prescan from (%s)", from);
58036233Skarels # endif
58136230Skarels 		usrerr("cannot prescan from (%s)", from);
5829536Seric 		finis();
5839536Seric 	}
5849536Seric 	rewrite(pvp, 3);
5859536Seric 	rewrite(pvp, 1);
58625032Seric 	rewrite(pvp, 4);
5879536Seric 	cataddr(pvp, buf, sizeof buf);
58853182Seric 	e->e_sender = e->e_returnpath = newstr(buf);
5899536Seric 
59053182Seric 	define('f', e->e_sender, e);
59151951Seric 
5929536Seric 	/* save the domain spec if this mailer wants it */
59353182Seric 	if (e->e_from.q_mailer != NULL &&
59453182Seric 	    bitnset(M_CANONICAL, e->e_from.q_mailer->m_flags))
5959536Seric 	{
5969536Seric 		extern char **copyplist();
5979536Seric 
5989536Seric 		while (*pvp != NULL && strcmp(*pvp, "@") != 0)
5999536Seric 			pvp++;
6009536Seric 		if (*pvp != NULL)
60153182Seric 			e->e_fromdomain = copyplist(pvp, TRUE);
6029536Seric 	}
6039536Seric }
6049536Seric /*
6059536Seric **  TRUSTEDUSER -- tell us if this user is to be trusted.
6069536Seric **
6079536Seric **	Parameters:
6089536Seric **		user -- the user to be checked.
6099536Seric **
6109536Seric **	Returns:
6119536Seric **		TRUE if the user is in an approved list.
6129536Seric **		FALSE otherwise.
6139536Seric **
6149536Seric **	Side Effects:
6159536Seric **		none.
6169536Seric */
6179536Seric 
6189536Seric bool
6199536Seric trusteduser(user)
6209536Seric 	char *user;
6219536Seric {
6229536Seric 	register char **ulist;
6239536Seric 	extern char *TrustedUsers[];
6249536Seric 
6259536Seric 	for (ulist = TrustedUsers; *ulist != NULL; ulist++)
6269536Seric 		if (strcmp(*ulist, user) == 0)
6279536Seric 			return (TRUE);
6289536Seric 	return (FALSE);
6299536Seric }
630