* Copyright (c) 1983 Eric P. Allman
* Copyright (c) 1988 Regents of the University of California.
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not 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 MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
static char sccsid
[] = "@(#)conf.c 5.22 (Berkeley) %G%";
** CONF.C -- Sendmail Configuration Tables.
** Defines the configuration of this installation.
** 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.
** 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!
** 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
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
,
"return-receipt-to", H_FROM
,
"resent-to", H_RCPT
|H_RESENT
,
"resent-cc", H_RCPT
|H_RESENT
,
"resent-bcc", H_RCPT
|H_ACHECK
|H_RESENT
,
/* message identification and control */
"resent-message-id", H_RESENT
,
"received", H_TRACE
|H_FORCE
,
"mail-from", H_TRACE
|H_FORCE
,
** 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
= "/etc/sendmail.cf"; /* runtime configuration */
char *FreezeFile
= "/etc/sendmail.fc"; /* frozen version of above */
int DtableSize
= 50; /* max open files; reset in 4.2bsd */
extern int la
; /* load average */
** SETDEFAULTS -- set default values
** Because of the way freezing is done, these must be initialized
** Initializes a bunch of global variables to their
** GETRUID -- get real user id (V7)
** GETRGID -- get real group id (V7).
** USERNAME -- return the user id of the logged in user.
** The login name of the logged in user.
** The return value is statically allocated.
static char *myname
= NULL
;
register struct passwd
*pw
;
extern struct passwd
*getpwuid();
if (myname
== NULL
|| myname
[0] == '\0')
pw
= getpwuid(getruid());
if(getuid() != pw
->pw_uid
)
if (myname
== NULL
|| myname
[0] == '\0')
** 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
** pathname of the user's tty.
** NULL if not logged in or write permission denied.
** Return value is in a local buffer.
/* compute the pathname of the controlling tty */
if ((pathn
= ttyname(2)) == NULL
&& (pathn
= ttyname(1)) == NULL
&&
(pathn
= ttyname(0)) == NULL
)
/* see if we have write permission */
if (stat(pathn
, &stbuf
) < 0 || !bitset(02, stbuf
.st_mode
))
/* see if the user is logged in */
** 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
** 'NoReturn' can be set to suppress the return-to-sender
** function; this should be done on huge messages.
** to -- the person being sent to.
** none (unless you include the usrerr stuff)
/* this code is intended as an example only */
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 */
** HOLDSIGS -- arrange to hold all signals
** Arranges that signals are held.
** RLSESIGS -- arrange to release all signals
** This undoes the effect of holdsigs.
** Arranges that signals are released.
** GETLA -- get the current load average
** This code stolen from la.c.
** The current load average as an integer.
if (getloadavg(avenrun
, sizeof(avenrun
) / sizeof(avenrun
[0])) < 0)
return ((int) (avenrun
[0] + 0.5));
kmem
= open("/dev/kmem", 0, 0);
(void) ioctl(kmem
, (int) FIOCLEX
, (char *) 0);
if (lseek(kmem
, (off_t
) Nl
[X_AVENRUN
].n_value
, 0) == -1 ||
read(kmem
, (char *) avenrun
, sizeof(avenrun
)) < sizeof(avenrun
))
return ((int) (avenrun
[0] + FSCALE
/2) >> FSHIFT
);
** SHOULDQUEUE -- should this message be queued or sent?
** Compares the message cost to the load average to decide.
** pri -- the priority of the message in question.
** TRUE -- if this message should be queued up for the
** FALSE -- if the load is low enough to send this message.
return (pri
> (QueueFactor
/ (la
- QueueLA
+ 1)));
** SETPROCTITLE -- set process title for ps
** fmt -- a printf style format string.
** a, b, c -- possible parameters to fmt.
** Clobbers argv of our main procedure so ps(1) will
setproctitle(fmt
, a
, b
, c
)
(void) sprintf(buf
, fmt
, a
, b
, c
);
/* make ps print "(sendmail)" */
if (i
> LastArgv
- p
- 2)
** REAPCHILD -- pick up the body of my child, lest it become a zombie
** Picks up extant zombies.
while (wait3(&status
, WNOHANG
, (struct rusage
*) NULL
) > 0)
while (wait(&status
) > 0)