⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 conf.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 4 页
字号:
/* * Copyright (c) 1983 Eric P. Allman * Copyright (c) 1988, 1993 *	The Regents of the University of California.  All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in the *    documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software *    must display the following acknowledgement: *	This product includes software developed by the University of *	California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors *    may be used to endorse or promote products derived from this software *    without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */#ifndef lintstatic char sccsid[] = "@(#)conf.c	8.89 (Berkeley) 4/18/94";#endif /* not lint */# include "sendmail.h"# include "pathnames.h"# include <sys/ioctl.h># include <sys/param.h># include <netdb.h># include <pwd.h>/***  CONF.C -- Sendmail Configuration Tables.****	Defines the configuration of this installation.****	Configuration Variables:**		HdrInfo -- a table describing well-known header fields.**			Each entry has the field name and some flags,**			which are described in sendmail.h.****	Notes:**		I have tried to put almost all the reasonable**		configuration information into the configuration**		file read at runtime.  My intent is that anything**		here is a function of the version of UNIX you**		are running, or is really static -- for example**		the headers are a superset of widely used**		protocols.  If you find yourself playing with**		this file too much, you may be making a mistake!*//***  Header info table**	Final (null) entry contains the flags used for any other field.****	Not all of these are actually handled specially by sendmail**	at this time.  They are included as placeholders, to let**	you know that "someday" I intend to have sendmail do**	something with them.*/struct hdrinfo	HdrInfo[] ={		/* originator fields, most to least significant  */	"resent-sender",	H_FROM|H_RESENT,	"resent-from",		H_FROM|H_RESENT,	"resent-reply-to",	H_FROM|H_RESENT,	"sender",		H_FROM,	"from",			H_FROM,	"reply-to",		H_FROM,	"full-name",		H_ACHECK,	"return-receipt-to",	H_FROM|H_RECEIPTTO,	"errors-to",		H_FROM|H_ERRORSTO,		/* destination fields */	"to",			H_RCPT,	"resent-to",		H_RCPT|H_RESENT,	"cc",			H_RCPT,	"resent-cc",		H_RCPT|H_RESENT,	"bcc",			H_RCPT|H_ACHECK,	"resent-bcc",		H_RCPT|H_ACHECK|H_RESENT,	"apparently-to",	H_RCPT,		/* message identification and control */	"message-id",		0,	"resent-message-id",	H_RESENT,	"message",		H_EOH,	"text",			H_EOH,		/* date fields */	"date",			0,	"resent-date",		H_RESENT,		/* trace fields */	"received",		H_TRACE|H_FORCE,	"x400-received",	H_TRACE|H_FORCE,	"via",			H_TRACE|H_FORCE,	"mail-from",		H_TRACE|H_FORCE,		/* miscellaneous fields */	"comments",		H_FORCE,	"return-path",		H_FORCE|H_ACHECK,	NULL,			0,};/***  Location of system files/databases/etc.*/char	*PidFile =	_PATH_SENDMAILPID;	/* stores daemon proc id *//***  Privacy values*/struct prival PrivacyValues[] ={	"public",		PRIV_PUBLIC,	"needmailhelo",		PRIV_NEEDMAILHELO,	"needexpnhelo",		PRIV_NEEDEXPNHELO,	"needvrfyhelo",		PRIV_NEEDVRFYHELO,	"noexpn",		PRIV_NOEXPN,	"novrfy",		PRIV_NOVRFY,	"restrictmailq",	PRIV_RESTRICTMAILQ,	"restrictqrun",		PRIV_RESTRICTQRUN,	"authwarnings",		PRIV_AUTHWARNINGS,	"noreceipts",		PRIV_NORECEIPTS,	"goaway",		PRIV_GOAWAY,	NULL,			0,};/***  Miscellaneous stuff.*/int	DtableSize =	50;		/* max open files; reset in 4.2bsd *//***  Following should be config parameters (and probably will be in**  future releases).  In the meantime, setting these is considered**  unsupported, and is intentionally undocumented.*/#ifdef BROKENSMTPPEERSbool	BrokenSmtpPeers = TRUE;		/* set if you have broken SMTP peers */#elsebool	BrokenSmtpPeers = FALSE;	/* set if you have broken SMTP peers */#endif#ifdef NOLOOPBACKCHECKbool	CheckLoopBack = FALSE;		/* set to check HELO loopback */#elsebool	CheckLoopBack = TRUE;		/* set to check HELO loopback */#endif/***  SETDEFAULTS -- set default values****	Because of the way freezing is done, these must be initialized**	using direct code.****	Parameters:**		e -- the default envelope.****	Returns:**		none.****	Side Effects:**		Initializes a bunch of global variables to their**		default values.*/#define DAYS		* 24 * 60 * 60setdefaults(e)	register ENVELOPE *e;{	SpaceSub = ' ';				/* option B */	QueueLA = 8;				/* option x */	RefuseLA = 12;				/* option X */	WkRecipFact = 30000L;			/* option y */	WkClassFact = 1800L;			/* option z */	WkTimeFact = 90000L;			/* option Z */	QueueFactor = WkRecipFact * 20;		/* option q */	FileMode = (RealUid != geteuid()) ? 0644 : 0600;						/* option F */	DefUid = 1;				/* option u */	DefGid = 1;				/* option g */	CheckpointInterval = 10;		/* option C */	MaxHopCount = 25;			/* option h */	e->e_sendmode = SM_FORK;		/* option d */	e->e_errormode = EM_PRINT;		/* option e */	SevenBit = FALSE;			/* option 7 */	MaxMciCache = 1;			/* option k */	MciCacheTimeout = 300;			/* option K */	LogLevel = 9;				/* option L */	settimeouts(NULL);			/* option r */	TimeOuts.to_q_return = 5 DAYS;		/* option T */	TimeOuts.to_q_warning = 0;		/* option T */	PrivacyFlags = 0;			/* option p */	setdefuser();	setupmaps();	setupmailers();}/***  SETDEFUSER -- set/reset DefUser using DefUid (for initgroups())*/setdefuser(){	struct passwd *defpwent;	static char defuserbuf[40];	DefUser = defuserbuf;	if ((defpwent = getpwuid(DefUid)) != NULL)		strcpy(defuserbuf, defpwent->pw_name);	else		strcpy(defuserbuf, "nobody");}/***  HOST_MAP_INIT -- initialize host class structures*/boolhost_map_init(map, args)	MAP *map;	char *args;{	register char *p = args;	for (;;)	{		while (isascii(*p) && isspace(*p))			p++;		if (*p != '-')			break;		switch (*++p)		{		  case 'a':			map->map_app = ++p;			break;		}		while (*p != '\0' && !(isascii(*p) && isspace(*p)))			p++;		if (*p != '\0')			*p++ = '\0';	}	if (map->map_app != NULL)		map->map_app = newstr(map->map_app);	return TRUE;}/***  SETUPMAILERS -- initialize default mailers*/setupmailers(){	char buf[100];	strcpy(buf, "prog, P=/bin/sh, F=lsD, A=sh -c $u");	makemailer(buf);	strcpy(buf, "*file*, P=/dev/null, F=lsDFMPEu, A=FILE");	makemailer(buf);	strcpy(buf, "*include*, P=/dev/null, F=su, A=INCLUDE");	makemailer(buf);}/***  SETUPMAPS -- set up map classes*/#define MAPDEF(name, ext, flags, parse, open, close, lookup, store) \	{ \		extern bool parse __P((MAP *, char *)); \		extern bool open __P((MAP *, int)); \		extern void close __P((MAP *)); \		extern char *lookup __P((MAP *, char *, char **, int *)); \		extern void store __P((MAP *, char *, char *)); \		s = stab(name, ST_MAPCLASS, ST_ENTER); \		s->s_mapclass.map_cname = name; \		s->s_mapclass.map_ext = ext; \		s->s_mapclass.map_cflags = flags; \		s->s_mapclass.map_parse = parse; \		s->s_mapclass.map_open = open; \		s->s_mapclass.map_close = close; \		s->s_mapclass.map_lookup = lookup; \		s->s_mapclass.map_store = store; \	}setupmaps(){	register STAB *s;#ifdef NEWDB	MAPDEF("hash", ".db", MCF_ALIASOK|MCF_REBUILDABLE,		map_parseargs, hash_map_open, db_map_close,		db_map_lookup, db_map_store);	MAPDEF("btree", ".db", MCF_ALIASOK|MCF_REBUILDABLE,		map_parseargs, bt_map_open, db_map_close,		db_map_lookup, db_map_store);#endif#ifdef NDBM	MAPDEF("dbm", ".dir", MCF_ALIASOK|MCF_REBUILDABLE,		map_parseargs, ndbm_map_open, ndbm_map_close,		ndbm_map_lookup, ndbm_map_store);#endif#ifdef NIS	MAPDEF("nis", NULL, MCF_ALIASOK,		map_parseargs, nis_map_open, nis_map_close,		nis_map_lookup, nis_map_store);#endif	MAPDEF("stab", NULL, MCF_ALIASOK|MCF_ALIASONLY,		map_parseargs, stab_map_open, stab_map_close,		stab_map_lookup, stab_map_store);	MAPDEF("implicit", NULL, MCF_ALIASOK|MCF_ALIASONLY|MCF_REBUILDABLE,		map_parseargs, impl_map_open, impl_map_close,		impl_map_lookup, impl_map_store);	/* host DNS lookup */	MAPDEF("host", NULL, 0,		host_map_init, null_map_open, null_map_close,		host_map_lookup, null_map_store);	/* dequote map */	MAPDEF("dequote", NULL, 0,		dequote_init, null_map_open, null_map_close,		dequote_map, null_map_store);#if 0# ifdef USERDB	/* user database */	MAPDEF("udb", ".db", 0,		udb_map_parse, null_map_open, null_map_close,		udb_map_lookup, null_map_store);# endif#endif}#undef MAPDEF/***  USERNAME -- return the user id of the logged in user.****	Parameters:**		none.****	Returns:**		The login name of the logged in user.****	Side Effects:**		none.****	Notes:**		The return value is statically allocated.*/char *username(){	static char *myname = NULL;	extern char *getlogin();	register struct passwd *pw;	/* cache the result */	if (myname == NULL)	{		myname = getlogin();		if (myname == NULL || myname[0] == '\0')		{			pw = getpwuid(RealUid);			if (pw != NULL)				myname = newstr(pw->pw_name);		}		else		{			uid_t uid = RealUid;			myname = newstr(myname);			if ((pw = getpwnam(myname)) == NULL ||			      (uid != 0 && uid != pw->pw_uid))			{				pw = getpwuid(uid);				if (pw != NULL)					myname = newstr(pw->pw_name);			}		}		if (myname == NULL || myname[0] == '\0')		{			syserr("554 Who are you?");			myname = "postmaster";		}	}	return (myname);}/***  TTYPATH -- Get the path of the user's tty****	Returns the pathname of the user's tty.  Returns NULL if**	the user is not logged in or if s/he has write permission**	denied.****	Parameters:**		none****	Returns:**		pathname of the user's tty.**		NULL if not logged in or write permission denied.****	Side Effects:**		none.****	WARNING:**		Return value is in a local buffer.****	Called By:**		savemail*/char *ttypath(){	struct stat stbuf;	register char *pathn;	extern char *ttyname();	extern char *getlogin();	/* compute the pathname of the controlling tty */	if ((pathn = ttyname(2)) == NULL && (pathn = ttyname(1)) == NULL &&	    (pathn = ttyname(0)) == NULL)	{		errno = 0;		return (NULL);	}	/* see if we have write permission */	if (stat(pathn, &stbuf) < 0 || !bitset(02, stbuf.st_mode))	{		errno = 0;		return (NULL);	}	/* see if the user is logged in */	if (getlogin() == NULL)		return (NULL);	/* looks good */	return (pathn);}/***  CHECKCOMPAT -- check for From and To person compatible.****	This routine can be supplied on a per-installation basis**	to determine whether a person is allowed to send a message.**	This allows restriction of certain types of internet**	forwarding or registration of users.****	If the hosts are found to be incompatible, an error**	message should be given using "usrerr" and 0 should**	be returned.****	'NoReturn' can be set to suppress the return-to-sender**	function; this should be done on huge messages.****	Parameters:**		to -- the person being sent to.****	Returns:**		an exit status****	Side Effects:**		none (unless you include the usrerr stuff)*/checkcompat(to, e)	register ADDRESS *to;	register ENVELOPE *e;{# ifdef lint	if (to == NULL)		to++;# endif /* lint */	if (tTd(49, 1))		printf("checkcompat(to=%s, from=%s)\n",			to->q_paddr, e->e_from.q_paddr);# ifdef EXAMPLE_CODE	/* this code is intended as an example only */	register STAB *s;	s = stab("arpa", ST_MAILER, ST_FIND);	if (s != NULL && e->e_from.q_mailer != LocalMailer &&	    to->q_mailer == s->s_mailer)	{		usrerr("553 No ARPA mail through this machine: see your system administration");		/* NoReturn = TRUE; to supress return copy */		return (EX_UNAVAILABLE);	}# endif /* EXAMPLE_CODE */	return (EX_OK);}/***  SETSIGNAL -- set a signal handler****	This is essentially old BSD "signal(3)".*/sigfunc_tsetsignal(sig, handler)	int sig;	sigfunc_t handler;{#if defined(SYS5SIGNALS) || defined(BSD4_3) || defined(_AUX_SOURCE)	return signal(sig, handler);#else	struct sigaction n, o;	bzero(&n, sizeof n);	n.sa_handler = handler;	if (sigaction(sig, &n, &o) < 0)		return SIG_ERR;	return o.sa_handler;#endif}/***  HOLDSIGS -- arrange to hold all signals****	Parameters:**		none.****	Returns:**		none.****	Side Effects:**		Arranges that signals are held.*/holdsigs(){}/***  RLSESIGS -- arrange to release all signals****	This undoes the effect of holdsigs.****	Parameters:**		none.****	Returns:**		none.****	Side Effects:**		Arranges that signals are released.*/rlsesigs(){}/***  INIT_MD -- do machine dependent initializations****	Systems that have global modes that should be set should do**	them here rather than in main.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -