DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T c

⟦6d338ac32⟧ TextFile

    Length: 23441 (0x5b91)
    Types: TextFile
    Names: »conf.c,v«

Derivation

└─⟦9ae75bfbd⟧ Bits:30007242 EUUGD3: Starter Kit
    └─⟦bfebc70e2⟧ »EurOpenD3/mail/sendmail-5.65b+IDA-1.4.3.tar.Z« 
        └─⟦f9e35cd84⟧ 
            └─⟦this⟧ »sendmail/src/RCS/conf.c,v« 

TextFile

head	5.26;
branch	5.26.0;
access;
symbols
	UICSO:5.26.0
	VANILLA:5.26;
locks; strict;
comment	@ * @;


5.26
date	90.06.20.08.35.28;	author paul;	state Exp;
branches
	5.26.0.1;
next	;

5.26.0.1
date	90.06.20.09.42.38;	author paul;	state Exp;
branches;
next	5.26.0.2;

5.26.0.2
date	90.06.25.09.20.32;	author paul;	state Exp;
branches;
next	5.26.0.3;

5.26.0.3
date	90.06.25.09.42.54;	author paul;	state Exp;
branches;
next	5.26.0.4;

5.26.0.4
date	90.06.25.14.26.17;	author paul;	state Exp;
branches;
next	5.26.0.5;

5.26.0.5
date	90.07.06.20.31.22;	author paul;	state Exp;
branches;
next	5.26.0.6;

5.26.0.6
date	90.10.16.08.14.45;	author paul;	state Exp;
branches;
next	5.26.0.7;

5.26.0.7
date	90.10.17.14.20.54;	author paul;	state Exp;
branches;
next	5.26.0.8;

5.26.0.8
date	90.11.01.23.46.37;	author paul;	state Exp;
branches;
next	5.26.0.9;

5.26.0.9
date	90.11.19.16.21.49;	author paul;	state Exp;
branches;
next	5.26.0.10;

5.26.0.10
date	90.11.24.02.37.57;	author paul;	state Exp;
branches;
next	5.26.0.11;

5.26.0.11
date	90.11.27.13.52.24;	author paul;	state Exp;
branches;
next	5.26.0.12;

5.26.0.12
date	90.11.28.14.17.32;	author paul;	state Exp;
branches;
next	5.26.0.13;

5.26.0.13
date	90.11.28.15.31.52;	author paul;	state Exp;
branches;
next	5.26.0.14;

5.26.0.14
date	90.11.29.21.15.23;	author paul;	state Exp;
branches;
next	5.26.0.15;

5.26.0.15
date	91.01.19.19.26.02;	author paul;	state Exp;
branches;
next	5.26.0.16;

5.26.0.16
date	91.03.04.21.48.23;	author paul;	state Exp;
branches;
next	5.26.0.17;

5.26.0.17
date	91.03.06.16.04.00;	author paul;	state Exp;
branches;
next	;


desc
@@


5.26
log
@5.64 Berkeley release
@
text
@/*
 * Copyright (c) 1983 Eric P. Allman
 * Copyright (c) 1988 Regents of the University of California.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms are permitted provided
 * that: (1) source distributions retain this entire copyright notice and
 * comment, and (2) distributions including binaries display the following
 * acknowledgement:  ``This product includes software developed by the
 * University of California, Berkeley and its contributors'' in the
 * documentation or other materials provided with the distribution and in
 * all advertising materials mentioning features or use of this software.
 * 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 */

#ifndef lint
static char sccsid[] = "@@(#)conf.c	5.26 (Berkeley) 6/1/90";
#endif /* not lint */

# include <sys/ioctl.h>
# include <sys/param.h>
# include <pwd.h>
# include "sendmail.h"
# include "pathnames.h"

/*
**  CONF.C -- Sendmail Configuration Tables.
**
**	Defines the configuration of this installation.
**
**	Compilation Flags:
**		VMUNIX -- running on a Berkeley UNIX system.
**
**	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,
	"errors-to",		H_FROM,
		/* 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,
		/* 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,
	"via",			H_TRACE|H_FORCE,
	"mail-from",		H_TRACE|H_FORCE,

	NULL,			0,
};


/*
**  ARPANET error message numbers.
*/

char	Arpa_Info[] =		"050";	/* arbitrary info */
char	Arpa_TSyserr[] =	"451";	/* some (transient) system error */
char	Arpa_PSyserr[] =	"554";	/* some (permanent) system error */
char	Arpa_Usrerr[] =		"554";	/* some (fatal) user error */



/*
**  Location of system files/databases/etc.
*/

char	*ConfFile =	_PATH_SENDMAILCF;	/* runtime configuration */
char	*FreezeFile =	_PATH_SENDMAILFC;	/* frozen version of above */



/*
**  Miscellaneous stuff.
*/

int	DtableSize =	50;		/* max open files; reset in 4.2bsd */
extern int la;				/* load average */
\f

/*
**  SETDEFAULTS -- set default values
**
**	Because of the way freezing is done, these must be initialized
**	using direct code.
**
**	Parameters:
**		none.
**
**	Returns:
**		none.
**
**	Side Effects:
**		Initializes a bunch of global variables to their
**		default values.
*/

setdefaults()
{
	QueueLA = 8;
	QueueFactor = 10000;
	RefuseLA = 12;
	SpaceSub = ' ';
	WkRecipFact = 1000;
	WkClassFact = 1800;
	WkTimeFact = 9000;
	FileMode = 0644;
	DefUid = 1;
	DefGid = 1;
	setdefuser();
}


/*
**  SETDEFUSER -- set/reset DefUser using DefUid (for initgroups())
*/

setdefuser()
{
	struct passwd *defpwent;

	if (DefUser != NULL)
		free(DefUser);
	if ((defpwent = getpwuid(DefUid)) != NULL)
		DefUser = newstr(defpwent->pw_name);
	else
		DefUser = newstr("nobody");
}


/*
**  GETRUID -- get real user id (V7)
*/

getruid()
{
	if (OpMode == MD_DAEMON)
		return (RealUid);
	else
		return (getuid());
}


/*
**  GETRGID -- get real group id (V7).
*/

getrgid()
{
	if (OpMode == MD_DAEMON)
		return (RealGid);
	else
		return (getgid());
}

/*
**  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;
	extern struct passwd *getpwuid();

	/* cache the result */
	if (myname == NULL)
	{
		myname = getlogin();
		if (myname == NULL || myname[0] == '\0')
		{

			pw = getpwuid(getruid());
			if (pw != NULL)
				myname = newstr(pw->pw_name);
		}
		else
		{

			myname = newstr(myname);
			if ((pw = getpwnam(myname)) == NULL ||
			      getuid() != pw->pw_uid)
			{
				pw = getpwuid(getuid());
				if (pw != NULL)
					myname = newstr(pw->pw_name);
			}
		}
		if (myname == NULL || myname[0] == '\0')
		{
			syserr("Who are you?");
			myname = "postmaster";
		}
	}

	return (myname);
}
\f

/*
**  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
*/

# include <sys/stat.h>

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);
}
\f

/*
**  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 FALSE 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:
**		TRUE -- ok to send.
**		FALSE -- not ok.
**
**	Side Effects:
**		none (unless you include the usrerr stuff)
*/

bool
checkcompat(to)
	register ADDRESS *to;
{
# ifdef lint
	if (to == NULL)
		to++;
# endif lint
# ifdef EXAMPLE_CODE
	/* this code is intended as an example only */
	register STAB *s;

	s = stab("arpa", ST_MAILER, ST_FIND);
	if (s != NULL && CurEnv->e_from.q_mailer != LocalMailer &&
	    to->q_mailer == s->s_mailer)
	{
		usrerr("No ARPA mail through this machine: see your system administration");
		/* NoReturn = TRUE; to supress return copy */
		return (FALSE);
	}
# endif EXAMPLE_CODE
	return (TRUE);
}
\f

/*
**  HOLDSIGS -- arrange to hold all signals
**
**	Parameters:
**		none.
**
**	Returns:
**		none.
**
**	Side Effects:
**		Arranges that signals are held.
*/

holdsigs()
{
}
\f

/*
**  RLSESIGS -- arrange to release all signals
**
**	This undoes the effect of holdsigs.
**
**	Parameters:
**		none.
**
**	Returns:
**		none.
**
**	Side Effects:
**		Arranges that signals are released.
*/

rlsesigs()
{
}
\f

/*
**  GETLA -- get the current load average
**
**	This code stolen from la.c.
**
**	Parameters:
**		none.
**
**	Returns:
**		The current load average as an integer.
**
**	Side Effects:
**		none.
*/

#ifndef sun

getla()
{
	double avenrun[3];

	if (getloadavg(avenrun, sizeof(avenrun) / sizeof(avenrun[0])) < 0)
		return (0);
	return ((int) (avenrun[0] + 0.5));
}

#else /* sun */

#include <nlist.h>

struct	nlist Nl[] =
{
	{ "_avenrun" },
#define	X_AVENRUN	0
	{ 0 },
};


extern int la;

getla()
{
	static int kmem = -1;
	long avenrun[3];
	extern off_t lseek();

	if (kmem < 0)
	{
		kmem = open("/dev/kmem", 0, 0);
		if (kmem < 0)
			return (-1);
		(void) ioctl(kmem, (int) FIOCLEX, (char *) 0);
		nlist("/vmunix", Nl);
		if (Nl[0].n_type == 0)
			return (-1);
	}
	if (lseek(kmem, (off_t) Nl[X_AVENRUN].n_value, 0) == -1 ||
	    read(kmem, (char *) avenrun, sizeof(avenrun)) < sizeof(avenrun))
	{
		/* thank you Ian */
		return (-1);
	}
	return ((int) (avenrun[0] + FSCALE/2) >> FSHIFT);
}

#endif /* sun */
\f

/*
**  SHOULDQUEUE -- should this message be queued or sent?
**
**	Compares the message cost to the load average to decide.
**
**	Parameters:
**		pri -- the priority of the message in question.
**
**	Returns:
**		TRUE -- if this message should be queued up for the
**			time being.
**		FALSE -- if the load is low enough to send this message.
**
**	Side Effects:
**		none.
*/

bool
shouldqueue(pri)
	long pri;
{
	if (la < QueueLA)
		return (FALSE);
	return (pri > (QueueFactor / (la - QueueLA + 1)));
}
\f

/*
**  SETPROCTITLE -- set process title for ps
**
**	Parameters:
**		fmt -- a printf style format string.
**		a, b, c -- possible parameters to fmt.
**
**	Returns:
**		none.
**
**	Side Effects:
**		Clobbers argv of our main procedure so ps(1) will
**		display the title.
*/

/*VARARGS1*/
setproctitle(fmt, a, b, c)
	char *fmt;
{
# ifdef SETPROCTITLE
	register char *p;
	register int i;
	extern char **Argv;
	extern char *LastArgv;
	char buf[MAXLINE];

	(void) sprintf(buf, fmt, a, b, c);

	/* make ps print "(sendmail)" */
	p = Argv[0];
	*p++ = '-';

	i = strlen(buf);
	if (i > LastArgv - p - 2)
	{
		i = LastArgv - p - 2;
		buf[i] = '\0';
	}
	(void) strcpy(p, buf);
	p += i;
	while (p < LastArgv)
		*p++ = ' ';
# endif SETPROCTITLE
}
\f

/*
**  REAPCHILD -- pick up the body of my child, lest it become a zombie
**
**	Parameters:
**		none.
**
**	Returns:
**		none.
**
**	Side Effects:
**		Picks up extant zombies.
*/

# ifdef VMUNIX
# include <sys/wait.h>
# endif VMUNIX

reapchild()
{
# ifdef WNOHANG
	union wait status;

	while (wait3(&status, WNOHANG, (struct rusage *) NULL) > 0)
		continue;
# else WNOHANG
	auto int status;

	while (wait(&status) > 0)
		continue;
# endif WNOHANG
}
@


5.26.0.1
log
@IDA patches
@
text
@a86 1
	"apparently-to",	H_RCPT,
a120 3
#ifdef OUTPUT_PID
char	*PidFile =	_PATH_SENDMAILPID;	/* sendmail daemon PID */
#endif /* OUTPUT_PID */
a148 2
	int c;

a159 5

# if defined(NDBM) || defined(SDBM)
	for (c = 0; c < 128; c++)
		DbmTab[c].db_dbm = DB_NOTYETOPEN;
# endif /* !NDBM && !SDBM */
d163 1
a163 1
  /*
d350 1
a350 1
# endif /* lint */
d363 1
a363 1
# endif /* EXAMPLE_CODE */
d437 3
a441 3
# ifdef sequent
	return (1);
# else /* !sequent */
a462 2
	/* return ((int) (avenrun[0] + 0.5)); */
# endif /* sequent */
d533 1
a533 1
# endif /* SETPROCTITLE */
d550 1
a550 1
# endif /* VMUNIX */
d559 1
a559 1
# else /* !WNOHANG */
d564 1
a564 1
# endif /* WNOHANG */
@


5.26.0.2
log
@Patches for HP-UX from Andy Linton <root@@comp.vuw.ac.nz>.  Thanks Andy!
@
text
@a26 3
# if defined(hpux)
# include <sgtty.h>
# endif /* hpux */
d131 2
a132 6
#ifdef hpux
#include <stdio.h>
int             DtableSize = _NFILE;    /* max open files */
#else
int             DtableSize = 50;/* max open files; reset in 4.2bsd */
#endif
d426 1
a426 1
#if !defined(sun) && !defined (hpux)
d437 1
a437 1
#else /* sun  || hpux */
d443 1
a443 5
#ifdef hp9000s800
	{"avenrun"},
#else
	{"_avenrun"},
#endif hp9000s800
a453 3
# if defined(hpux)
	double avenrun[3];
# else
a454 1
# endif /* hpux */
d463 1
a463 5
#if defined(hpux)
		(void) nlist ("/hp-ux", Nl);
#else
		(void) nlist ("/vmunix", Nl);
#endif /* hpux */
a464 7
		{
			/*
			 * if nlist() has failed we can't use Nl to grope 
			 * about in kmem on subsequent calls to getla()
			 */
		  	close (kmem);
			kmem = -1;
a465 1
		}
a472 3
# if defined(hpux)
	return ((int) (avenrun[0] + 0.5));
# else
d474 1
a474 1
# endif /* hpux */
@


5.26.0.3
log
@Inserted _PATH_UNIX and _PATH_KMEM instead of "/vmunix" and "/dev/kmem".
@
text
@d474 1
a474 1
		kmem = open(_PATH_KMEM, 0, 0);
d478 5
a482 1
		(void) nlist (_PATH_UNIX, Nl);
@


5.26.0.4
log
@Encore specifics from Neil Rickert.
@
text
@d21 1
a21 1
# ifndef lint
d23 1
a23 1
# endif /* not lint */
d28 1
a28 1
#  include <sgtty.h>
d125 1
a125 1
# ifdef OUTPUT_PID
d127 1
a127 1
# endif /* OUTPUT_PID */
d134 2
a135 2
# ifdef hpux
#  include <stdio.h>
d137 1
a137 1
# else /* ! hpux */
d139 1
a139 1
# endif /* hpux */
d177 1
a177 1
# endif /* NDBM || SDBM */
d433 1
a433 1
# if !defined(UMAX)
a434 2
#  if !defined(sun) && !defined (hpux)

d444 1
a444 1
#  else /* sun  || hpux */
d446 1
a446 1
#   include <nlist.h>
d450 1
a450 1
#   ifdef hp9000s800
d452 1
a452 1
#   else /* !hp9000s800 */
d454 2
a455 2
#   endif /* hp9000s800 */
#   define	X_AVENRUN	0
d461 1
a461 1
#   ifdef sequent
d463 1
a463 1
#   else /* !sequent */
d465 1
a465 1
#    if defined(hpux)
d467 1
a467 1
#    else /* !hpux */
d469 1
a469 1
#    endif /* hpux */
d496 1
a496 1
#    if defined(hpux)
d498 1
a498 1
#    else /* !hpux */
d500 2
a501 2
#    endif /* hpux */
#   endif /* sequent */
d504 1
a504 11
#  endif /* !sun && !hpux */

# else /* !UMAX */
getla()
{
	double avenrun[3];
	
	get_stats(avenrun,(double*)0,(char *)0);
	return ((int) (avenrun[0] + 0.5));
}
# endif /* UMAX */
d588 1
a588 1
#  include <sys/wait.h>
@


5.26.0.5
log
@Redid the getla code to eliminate nested defines.  #elseif would sure be
nice.  
@
text
@d433 1
a433 3
/*
 * The old-fashioned, time-honored, go grubbing into the kernel method.
 */
d435 1
a435 2
#if defined(sun) || defined(hpux)
# include <nlist.h>
d437 13
d452 1
a452 1
# if defined(hp9000s800)
d454 1
a454 1
# else /* !hp9000s800 */
d456 2
a457 2
# endif /* hp9000s800 */
# define	X_AVENRUN	0
d463 3
d467 1
a467 1
# if defined(hpux)
d469 1
a469 1
# else /* !hpux */
d471 1
a471 1
# endif /* hpux */
d498 1
a498 1
# if defined(hpux)
d500 1
a500 1
# else /* !hpux */
d502 2
a503 1
# endif /* hpux */
d506 1
a506 1
#endif /* sun || hpux */
d508 1
a508 12
/*
 * The "it's too hard to do right" way, so punt it.
 */

#if defined(sequent)
   getla() { return(1); }	/* Fake it */
#endif /* sequent */

/*
 * Special ways for machines off the beaten path
 */
#if defined(UMAX)
d516 1
a516 15
#endif /* UMAX */

/*
 * Everybody else? Ha!
 */
#if !defined(sun) && !defined(hpux) && !defined(sequent) && !defined(UMAX)
getla()
{
	double avenrun[3];

	if (getloadavg(avenrun, sizeof(avenrun) / sizeof(avenrun[0])) < 0)
		return (0);
	return ((int) (avenrun[0] + 0.5));
}
#endif /* !sun && !hpux && !sequent && !UMAX */
@


5.26.0.6
log
@Re-did #statement indentation.  Added support for GDBM & MDBM.  Rolled in
getloadavg.c and deleted Makefile entry.  Changed Encore flag UMAX to
MMAX to avoid collision with #define used on Integrated Solutions boxes.
Bruce Lilly (bruce%balilly@@sonyd1.broadcast.sony.com) provided unixpc and
some bug fixes.  His varargs code was changed to work with the VSPRINTF
#define in conf.h.
@
text
@d21 1
a21 1
#ifndef lint
d23 1
a23 1
#endif /* not lint */
d25 8
a32 12
#include <sys/ioctl.h>
#include <sys/param.h>
#include <sys/types.h>
#if defined(hpux)
# include <sgtty.h>
#endif /* hpux */
#include <pwd.h>
#include "sendmail.h"
#include "pathnames.h"
#if defined(__convex__) && defined(SHARE)
# include <shares.h>
#endif /* __convex__ && SHARE */
d172 1
d174 1
a174 1
# if defined(NDBM) || defined(OTHERDBM)
d177 1
a177 1
# endif /* NDBM || OTHERDBM */
d181 1
a181 1
\f

/*
d223 1
a223 1
\f

/*
d266 1
a266 3
				if (pw != NULL) {
					if (myname)
						free(myname);
a267 1
				}
d437 1
a437 1
#if defined(sun) || defined(hpux) || defined(unixpc)
a450 4
#ifdef unixpc
extern	int	la;
#endif /* unixpc */

d454 1
a454 1
# if defined(hpux) || defined(unixpc)
d456 1
a456 1
# else /* !hpux && !unixpc */
d458 1
a458 1
# endif /* hpux || unixpc */
d485 1
a485 1
# if defined(hpux) || defined(unixpc)
d487 1
a487 1
# else /* !hpux && !unixpc */
d489 1
a489 1
# endif /* hpux || unixpc */
d492 1
a492 1
#endif /* sun || hpux || unixpc */
d498 1
a498 1
#if defined(sequent) || defined(IRIS)
d500 1
a500 1
#endif /* sequent || IRIS */
d505 1
a505 1
#if defined(MMAX)
d513 1
a513 1
#endif /* MMAX */
d518 1
a518 2
#if !defined(sun) && !defined(hpux) && !defined(unixpc) && \
    !defined(sequent) && !defined(IRIS) && !defined(MMAX)
d527 1
a527 33

#include <nlist.h>

struct	nlist Nl[] =
{
	{ "_avenrun" },
#define	X_AVENRUN	0
	{ 0 },
};

/* ARGSUSED */
getloadavg(avenrun, n)
	double *avenrun;
	int n;
{
	static int kmem = -1;
	extern off_t lseek();

	if (kmem < 0) {
		kmem = open(_PATH_KMEM, 0, 0);
		if (kmem < 0)
			return (-1);
		(void) ioctl(kmem, (int) FIOCLEX, (char *) 0);
		nlist(_PATH_UNIX, Nl);
		if (Nl[0].n_type == 0)
			return (-1);
	}
	if (lseek(kmem, (off_t) Nl[X_AVENRUN].n_value, 0) == -1 ||
	    read(kmem, (char *) avenrun, sizeof(avenrun)) < sizeof(avenrun))
		return (-1);
	return (0);
}
#endif /* !sun && !hpux && && !unixpc && !sequent && !IRIS && !MMAX */
a568 7
# ifdef VSPRINTF
setproctitle(va_alist)
va_dcl
{
	va_list	ap;
	register char *fmt;
# else /* !VSPRINTF */
a571 1
# endif /* VSPRINTF */
a578 6
#  ifdef VSPRINTF
	va_start(ap);
	fmt = va_arg(ap, char *);
	(void) vsprintf(buf, fmt, ap);
	va_end(ap);
#  else /* !VSPRINTF */
a579 1
#  endif /* VSPRINTF */
a626 4
#ifdef SIGCLD
	/* reset handler */
	(void) signal(SIGCLD, reapchild);
#endif /* SIGCLD */
@


5.26.0.7
log
@Check whether FIOCLEX is defined before kernel diving, fake load average
otherwise.
@
text
@d508 1
a508 1
#if defined(sequent) || !defined(FIOCLEX)
d510 1
a510 1
#endif /* sequent || !FIOCLEX */
d528 1
a528 1
#if defined(FIOCLEX) && !defined(sun) && !defined(hpux) && !defined(unixpc) && \
@


5.26.0.8
log
@Protect against X400 loops.  Provided by Francis Dupont (dupont@@inria.inria.fr)
@
text
@a106 1
	"x400-received",	H_TRACE,
@


5.26.0.9
log
@Gutted out load average code.  Replaced in the getloadavg.c file from
the X11R3 distribution.
@
text
@d28 3
d139 6
d428 1
a428 1
**	Calls getloadavg() which is derived from the X11R4 'xload' utility.
d440 22
d464 7
a470 1
        double avenrun;
d472 29
a500 3
        if (getloadavg(&avenrun) < 0)
                return (0);
        return ((int) (avenrun + 0.5));
d502 70
@


5.26.0.10
log
@Deleted extern declaration of getpwuid().
@
text
@d240 1
@


5.26.0.11
log
@Print the loadaverage for -d3.1.
@
text
@a435 4

	/* same test used in main.c */
	if (tTd(3, 1))
		printf("Load average: %3.1f\n", avenrun);
@


5.26.0.12
log
@Freeze/thaw code now included only if _PATH_SENDMAILFC is #define'd in
pathnames.h .
@
text
@a125 1
#ifdef _PATH_SENDMAILFC
a126 1
#endif /* _PATH_SENDMAILFC */
@


5.26.0.13
log
@Declare reapchild() to be SIG_TYPE.
@
text
@a544 1
SIG_TYPE
@


5.26.0.14
log
@Deleted #ifdef/#define OUTPUT_PID in favor of testing whether _PATH_SENDMAILPID
is set.  sendmail.h now #include's pathnames.h instead of the other
modules.
@
text
@d30 1
a125 1

d129 1
a129 2

#ifdef _PATH_SENDMAILPID
d131 1
a131 1
#endif /* _PATH_SENDMAILPID */
@


5.26.0.15
log
@Deleted #include <sys/types.h> as it's already included via sendmail.h from
useful.h.  #include "sendmail.h" relocated to top of #include list.
@
text
@a24 1
#include "sendmail.h"
d27 1
d29 1
@


5.26.0.16
log
@ANSIfied.
@
text
@a32 2
extern char *ttyname(), *getlogin();;

d58 2
a155 1
void
a181 1
void
d240 1
d309 2
a395 1
void
a413 1
void
d436 1
a436 1
        if (getloadavg((caddr_t) &avenrun) < 0)
a484 1
void
d486 1
a486 2
setproctitle(fmt, va_alist)
	const char *fmt;
d490 1
d493 1
a493 1
	const char *fmt;
d505 1
d545 1
a545 1
void
a547 1
	int pid;
d551 1
a551 4
	while ((pid = wait3(&status, WNOHANG, (struct rusage *) NULL)) > 0)
	{
		if (tTd(4, 2))
			printf("reapchild: wait3 (pid = %d)\n", pid);
a552 1
	}
d556 1
a556 4
	while ((pid = wait(&status)) > 0)
	{
		if (tTd(4, 2))
			printf("reapchild: wait (pid = %d)\n", pid);
a557 1
	}
@


5.26.0.17
log
@Changed reset of SIGCLD to SIGCHLD instead.  If SIGCHLD is not defined by
the system, then useful.h will equate it to SIGCLD in the SYSV universe.
It does no harm on systems that reset signals automatically.
@
text
@d172 1
a172 1
#if defined(NDBM) || defined(OTHERDBM)
d175 1
a175 1
#endif /* NDBM || OTHERDBM */
d303 1
a303 1
#include <sys/stat.h>
d363 1
a363 1
#ifdef lint
d366 2
a367 2
#endif /* lint */
#ifdef EXAMPLE_CODE
d379 1
a379 1
#endif /* EXAMPLE_CODE */
d487 1
a487 1
#ifdef VSPRINTF
d493 1
a493 1
#else /* !VSPRINTF */
d497 2
a498 2
#endif /* VSPRINTF */
#ifdef SETPROCTITLE
d505 1
a505 1
# ifdef VSPRINTF
d509 1
a509 1
# else /* !VSPRINTF */
d511 1
a511 1
# endif /* VSPRINTF */
d527 1
a527 1
#endif /* SETPROCTITLE */
d542 3
a544 3
#ifdef VMUNIX
# include <sys/wait.h>
#endif /* VMUNIX */
d550 1
a550 1
#ifdef WNOHANG
d559 1
a559 1
#else /* !WNOHANG */
d568 5
a572 5
#endif /* WNOHANG */
#ifdef SIGCHLD
	/* reset handler (required for SYSV when SIGCLD == SIGCHLD ???) XXX */
	(void) signal(SIGCHLD, reapchild);
#endif /* SIGCHLD */
@