/* mts.c - definitions for the mail transport system */
static char ident
[] = "@(#)$Id: mts.c,v 2.16 1992/11/24 18:40:34 jromine Exp $";
#if defined(BSD41A) || defined(BSD42) || defined(SOCKETS)
#include "../h/strings.h"
#if defined(BSD42) || defined(SOCKETS)
#define NULLCP ((char *) 0)
static char *tailor_value ();
#if defined(SYS5) && !defined(_AIX)
#if !defined(__STDC__) && !defined(_AIX) && !defined(_POSIX_SOURCE)
char *index (), *malloc (), *mktemp (), *rindex (), *strcpy ();
struct passwd
*getpwuid ();
*mmdfldir and *uucpldir are the maildrop directories. If maildrops
are kept in the user's home directory, then these should be empty
strings. In this case, the appropriate ...lfil array should contain
the name of the file in the user's home directory. Usually, this is
static char *mtstailor
= "@(MHETCPATH)/mtstailor";
static char *localname
= "";
static char *localdomain
= "";
static char *systemname
= "";
static char *UUCPchan
= "";
char *mmdfldir
= "@(MHDROPATH)";
char *mmdflfil
= "@(MHDROPFIL)";
char *uucpldir
= "/usr/spool/mail";
char *mmdlm1
= "\001\001\001\001\n";
char *mmdlm2
= "\001\001\001\001\n";
static char *mmailid
= "0";
char *umincproc
= "@(MHETCPATH)/uminc";
int lockstyle
= LOK_UNIX
;
static char *lkstyle
= "0";
/* MTS specific variables */
char *Mailqdir
= "/usr/spool/netmail";
char *TMailqdir
= "/usr/tmp";
static char *syscpy
= "1";
char *Fromtmp
= "/tmp/rml.f.XXXXXX";
char *Msgtmp
= "/tmp/rml.m.XXXXXX";
char *Errtmp
= "/tmp/rml.e.XXXXXX";
static char *tmpmode
= "0600";
char *Okhosts
= "@(MHETCPATH)/Rmail.OkHosts";
char *Okdests
= "@(MHETCPATH)/Rmail.OkDests";
char *hostable
= "@(MHETCPATH)/hosts";
char *sendmail
= "/usr/lib/sendmail";
char *servers
= "localhost \01localnet";
/* BBoards-specific variables */
/* POP BBoards-specific variables */
char *popbblist
= "@(MHETCPATH)/hosts.popbb";
char *maildelivery
= "@(MHETCPATH)/maildelivery";
/* Aliasing Facility (doesn't belong here) */
static char *everyone
= "-1";
/* customize the MTS settings for MH by reading @(MHETCPATH)/mtstailor */
"localdomain", &localdomain
,
"systemname", &systemname
,
"maildelivery", &maildelivery
,
/* I'd like to use m_getfld() here, but not all programs loading mts.o may be
if (inited
++ || (fp
= fopen (mtstailor
, "r")) == NULL
)
while (fgets (buffer
, sizeof buffer
, fp
)) {
if ((cp
= index (buffer
, '\n')) == NULL
)
if (*buffer
== '#' || *buffer
== '\0')
if ((bp
= index (buffer
, ':')) == NULL
)
for (b
= binds
; b
-> keyword
; b
++)
if (strcmp (buffer
, b
-> keyword
) == 0)
if (b
-> keyword
&& (cp
= tailor_value (bp
)))
MMailids
= atoi (mmailid
);
if ((lockstyle
= atoi (lkstyle
)) < LOK_UNIX
|| lockstyle
> LOK_MMDF
)
(void) sscanf (tmpmode
, "0%o", &Tmpmode
);
Everyone
= atoi (everyone
);
static char *tailor_value (s
)
for (bp
= buffer
; *s
; bp
++, s
++)
#define grot(y,z) case y: *bp = z; break;
for (i
= 0; isdigit (*s
); s
++)
bp
= malloc ((unsigned) (strlen (buffer
) + 1));
(void) strcpy (bp
, buffer
);
#if defined(BSD42) || defined(SOCKETS)
register struct hostent
*hp
;
#endif /* BSD42 or SOCKETS */
#if defined(SYS5) && !defined(NETWORK)
#endif /* SYS5 and not NETWORK */
static char buffer
[BUFSIZ
] = "";
strcpy (buffer
, localname
);
(void) strcpy (buffer
, locname
);
if (rhost (&myname
) == -1)
(void) gethostname (buffer
, sizeof buffer
);
(void) strcpy (buffer
, myname
);
#if defined(BSD42) || defined(SOCKETS)
(void) gethostname (buffer
, sizeof buffer
);
if (hp
= gethostbyname (buffer
))
(void) strcpy (buffer
, hp
-> h_name
);
#endif /* BSD42 or SOCKETS */
(void) strcpy (buffer
, SystemName ());
(void) strcpy (buffer
, name
.nodename
);
strcat (buffer
, localdomain
);
#if defined(SYS5) && !defined(NETWORK)
#endif /* SYS5 and not NETWORK */
static char buffer
[BUFSIZ
] = "";
return strcpy (buffer
, systemname
);
(void) strcpy (buffer
, sysname
);
#if !defined(SYS5) || defined(NETWORK)
(void) gethostname (buffer
, sizeof buffer
);
#else /* SYS5 and not NETWORK */
(void) strcpy (buffer
, name
.nodename
);
#endif /* SYS5 and not NETWORK */
static char buffer
[BUFSIZ
] = "";
return strcpy (buffer
, UUCPchan
);
(void) strcpy (buffer
, uucpchan
);
(void) strcpy (buffer
, "uucp");
if (fp
= fopen ("/etc/systemid", "r")) {
if (fgets (name
, len
, fp
)) {
if (cp
= index (name
, '\n'))
(void) strncpy (name
, "altos", len
);
static char username
[BUFSIZ
];
static char fullname
[BUFSIZ
];
register struct passwd
*pw
;
if ((pw
= getpwuid (getuid ())) == NULL
|| *pw
-> pw_name
== NULL
) {
if (uid
== geteuid () && (cp
= getenv ("USER")) != NULL
&& (pw
= getpwnam (cp
)) != NULL
)
else if ((pw
= getpwuid (uid
)) == NULL
|| *pw
-> pw_name
== '\0') {
(void) strcpy (username
, "unknown");
(void) sprintf (fullname
, "The Unknown User-ID (%d)", getuid ());
for (cp
= fullname
; *np
&& *np
!= (MMailids
? '<' : ','); *cp
++ = *np
++)
for (cp
= username
; *np
&& *np
!= '>'; *cp
++ = *np
++)
if (MMailids
== 0 || *np
== '\0')
(void) strcpy (username
, pw
-> pw_name
);
if ((cp
= getenv ("SIGNATURE")) && *cp
)
(void) strcpy (fullname
, cp
);
if (index(fullname
, '.')) { /* quote any .'s */
sprintf (tmp
, "\"%s\"", fullname
);/* should quote "'s too */
#ifndef notdef /* Supposedly this works, I prefer the
if ((d
= fcntl (d1
, F_DUPFD
, d2
)) == NOTOK
)
static int dup2aux (d1
, d2
)
if ((d
= dup (d1
)) == NOTOK
)