* Copyright (c) 1988 Regents of the University of California.
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of California at 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'' without express or implied warranty.
* Copyright (c) 1983 Eric P. Allman
static char sccsid
[] = "@(#)conf.c 5.15 (Berkeley) %G%";
** CONF.C -- Sendmail Configuration Tables.
** Defines the configuration of this installation.
** V6 -- running on a version 6 system. This determines
** whether to define certain routines between
** the two systems. If you are running a funny
** system, e.g., V6 with long tty names, this
** should be checked carefully.
** 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
= "/usr/lib/sendmail.cf"; /* runtime configuration */
char *FreezeFile
= "/usr/lib/sendmail.fc"; /* frozen version of above */
int DtableSize
= 50; /* max open files; reset in 4.2bsd */
** SETDEFAULTS -- set default values
** Because of the way freezing is done, these must be initialized
** Initializes a bunch of global variables to their
** TTYNAME -- return name of terminal.
** fd -- file descriptor to check.
** pointer to full path of tty.
static char pathn
[] = "/dev/ttyx";
/* compute the pathname of the controlling tty */
if ((tn
= ttyn(fd
)) == NULL
)
** FDOPEN -- Open a stdio file given an open file descriptor.
** This is included here because it is standard in v7, but we
** Open /dev/null to create a descriptor.
** Close that descriptor.
** Copy the existing fd into the descriptor.
** fd -- the open file descriptor.
** type -- "r", "w", or whatever.
** The file descriptor it creates.
** The mode of fd must match "type".
f
= fopen("/dev/null", type
);
** INDEX -- Return pointer to character in string
** s -- a string to scan.
** c -- a character to look for.
** If c is in s, returns the address of the first
** NULL if c is not in s.
** UMASK -- fake the umask system call.
** Since V6 always acts like the umask is zero, we will just
** assume the same thing.
** GETRUID -- get real user id.
return (getuid() & 0377);
** GETRGID -- get real group id.
return (getgid() & 0377);
** GETEUID -- get effective user id.
return ((getuid() >> 8) & 0377);
** GETEGID -- get effective group id.
return ((getgid() >> 8) & 0377);
** 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.
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
);
return ((int) (avenrun
[0] + 0.5));
** 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)