9 date 94.03.23.23.35.23; author jromine; state Exp;
14 date 93.09.01.20.55.38; author jromine; state Exp;
19 date 93.08.19.23.36.12; author jromine; state Exp;
24 date 93.08.19.23.08.05; author jromine; state Exp;
29 date 92.11.24.18.40.34; author jromine; state Exp;
34 date 92.11.02.18.58.12; author jromine; state Exp;
39 date 92.05.19.20.51.57; author jromine; state Exp;
44 date 92.05.12.21.46.45; author jromine; state Exp;
49 date 92.02.10.18.12.35; author jromine; state Exp;
54 date 92.02.05.17.08.16; author jromine; state Exp;
59 date 92.02.03.17.49.13; author jromine; state Exp;
64 date 92.02.03.16.34.00; author jromine; state Exp;
69 date 92.01.31.21.37.07; author jromine; state Exp;
74 date 91.02.14.15.17.56; author mh; state Exp;
79 date 90.11.05.12.06.39; author mh; state Exp;
84 date 90.04.05.15.29.04; author sources; state Exp;
89 date 90.04.05.14.42.56; author sources; state Exp;
94 date 90.04.02.14.27.00; author sources; state Exp;
99 date 90.02.07.13.00.42; author sources; state Exp;
104 date 90.02.05.14.46.23; author sources; state Exp;
109 date 89.11.17.15.56.27; author sources; state Exp;
114 date 89.11.17.15.44.15; author sources; state Exp;
125 @change "client" to "clientname"
126 make default to use LocalName()
129 @/* mts.c - definitions for the mail transport system */
131 static char ident[] = "@@(#)$Id: mts.c,v 2.19 1993/09/01 20:55:38 jromine Exp jromine $";
137 #if defined(BSD41A) || defined(BSD42) || defined(SOCKETS)
141 #include "../h/strings.h"
146 #if defined(BSD42) || defined(SOCKETS)
153 #include <sys/utsname.h>
162 #define NULLCP ((char *) 0)
166 static char *tailor_value ();
169 #if defined(SYS5) && !defined(_AIX)
171 #define rindex strrchr
174 #if !defined(__STDC__) && !defined(_AIX) && !defined(_POSIX_SOURCE)
175 char *index (), *malloc (), *mktemp (), *rindex (), *strcpy ();
178 struct passwd *getpwuid ();
180 #endif /* !__STDC__ */
185 *mmdfldir and *uucpldir are the maildrop directories. If maildrops
186 are kept in the user's home directory, then these should be empty
187 strings. In this case, the appropriate ...lfil array should contain
188 the name of the file in the user's home directory. Usually, this is
189 something like ".mail".
192 static char *mtstailor = "@@(MHETCPATH)/mtstailor";
194 static char *localname = "";
195 static char *localdomain = "";
196 static char *systemname = "";
198 static char *UUCPchan = "";
200 char *mmdfldir = "@@(MHDROPATH)";
201 char *mmdflfil = "@@(MHDROPFIL)";
202 char *uucpldir = "/usr/spool/mail";
206 char *mmdlm1 = "\001\001\001\001\n";
207 char *mmdlm2 = "\001\001\001\001\n";
210 static int MMailids = 0;
211 static char *mmailid = "0";
215 char *umincproc = "@@(MHETCPATH)/uminc";
217 char *umincproc = NULL;
221 int lockstyle = LOK_UNIX;
222 static char *lkstyle = "0";
227 /* MTS specific variables */
230 char *Mailqdir = "/usr/spool/netmail";
231 char *TMailqdir = "/usr/tmp";
233 static char *syscpy = "1";
234 char *Overseer = "root";
235 char *Mailer = "root";
236 char *Fromtmp = "/tmp/rml.f.XXXXXX";
237 char *Msgtmp = "/tmp/rml.m.XXXXXX";
238 char *Errtmp = "/tmp/rml.e.XXXXXX";
240 static char *tmpmode = "0600";
241 char *Okhosts = "@@(MHETCPATH)/Rmail.OkHosts";
242 char *Okdests = "@@(MHETCPATH)/Rmail.OkDests";
249 char *hostable = "@@(MHETCPATH)/hosts";
250 char *sendmail = "/usr/lib/sendmail";
256 char *clientname = (char *)0;
257 char *servers = "localhost \01localnet";
261 /* BBoards-specific variables */
263 char *bb_domain = "";
266 /* POP BBoards-specific variables */
269 char *popbbhost = "";
270 char *popbbuser = "";
271 char *popbblist = "@@(MHETCPATH)/hosts.popbb";
277 char *maildelivery = "@@(MHETCPATH)/maildelivery";
280 /* Aliasing Facility (doesn't belong here) */
282 int Everyone = NOTOK;
283 static char *everyone = "-1";
288 /* customize the MTS settings for MH by reading @@(MHETCPATH)/mtstailor */
294 "localname", &localname,
295 "localdomain", &localdomain,
296 "systemname", &systemname,
298 "uucpchan", &UUCPchan,
300 "mmdfldir", &mmdfldir,
301 "mmdflfil", &mmdflfil,
302 "uucpldir", &uucpldir,
303 "uucplfil", &uucplfil,
307 "umincproc", &umincproc,
308 "lockstyle", &lkstyle,
309 "lockldir", &lockldir,
312 "mailqdir", &Mailqdir,
313 "tmailqdir", &TMailqdir,
315 "overseer", &Overseer,
329 "hostable", &hostable,
330 "sendmail", &sendmail,
333 "clientname", &clientname,
337 "bbdomain", &bb_domain,
340 "popbbhost", &popbbhost,
341 "popbbuser", &popbbuser,
342 "popbblist", &popbblist,
345 "nntphost", &popbbhost,
348 "maildelivery", &maildelivery,
350 "everyone", &everyone,
358 /* I'd like to use m_getfld() here, but not all programs loading mts.o may be
359 MH-style programs... */
369 register struct bind *b;
371 static int inited = 0;
373 if (inited++ || (fp = fopen (mtstailor, "r")) == NULL)
376 while (fgets (buffer, sizeof buffer, fp)) {
377 if ((cp = index (buffer, '\n')) == NULL)
380 if (*buffer == '#' || *buffer == '\0')
382 if ((bp = index (buffer, ':')) == NULL)
385 while (isspace (*bp))
388 for (b = binds; b -> keyword; b++)
389 if (strcmp (buffer, b -> keyword) == 0)
391 if (b -> keyword && (cp = tailor_value (bp)))
397 MMailids = atoi (mmailid);
398 if ((lockstyle = atoi (lkstyle)) < LOK_UNIX || lockstyle > LOK_MMDF)
399 lockstyle = LOK_UNIX;
401 Syscpy = atoi (syscpy);
402 (void) sscanf (tmpmode, "0%o", &Tmpmode);
404 Everyone = atoi (everyone);
411 static char *tailor_value (s)
419 for (bp = buffer; *s; bp++, s++)
424 #define grot(y,z) case y: *bp = z; break;
441 r = *s != '0' ? 10 : 8;
442 for (i = 0; isdigit (*s); s++)
443 i = i * r + *s - '0';
450 bp = malloc ((unsigned) (strlen (buffer) + 1));
452 (void) strcpy (bp, buffer);
463 #if defined(BSD42) || defined(SOCKETS)
464 register struct hostent *hp;
465 #endif /* BSD42 or SOCKETS */
466 #if defined(SYS5) && !defined(NETWORK)
468 #endif /* SYS5 and not NETWORK */
469 static char buffer[BUFSIZ] = "";
476 strcpy (buffer, localname);
480 (void) strcpy (buffer, locname);
481 #else /* not locname */
485 if (rhost (&myname) == -1)
486 (void) gethostname (buffer, sizeof buffer);
488 (void) strcpy (buffer, myname);
492 #if defined(BSD42) || defined(SOCKETS)
493 (void) gethostname (buffer, sizeof buffer);
497 if (hp = gethostbyname (buffer))
498 (void) strcpy (buffer, hp -> h_name);
499 #endif /* BSD42 or SOCKETS */
500 #else /* not NETWORK */
502 (void) strcpy (buffer, SystemName ());
504 (void) uname (&name);
505 (void) strcpy (buffer, name.nodename);
507 #endif /* not NETWORK */
508 #endif /* not locname */
511 strcat (buffer, ".");
512 strcat (buffer, localdomain);
519 char *SystemName () {
520 #if defined(SYS5) && !defined(NETWORK)
522 #endif /* SYS5 and not NETWORK */
523 static char buffer[BUFSIZ] = "";
530 return strcpy (buffer, systemname);
533 (void) strcpy (buffer, sysname);
535 #if !defined(SYS5) || defined(NETWORK)
536 (void) gethostname (buffer, sizeof buffer);
537 #else /* SYS5 and not NETWORK */
539 (void) uname (&name);
540 (void) strcpy (buffer, name.nodename);
542 #endif /* SYS5 and not NETWORK */
552 static char buffer[BUFSIZ] = "";
563 return strcpy (buffer, UUCPchan);
566 (void) strcpy (buffer, uucpchan);
568 (void) strcpy (buffer, "uucp");
569 #endif /* uucpchan */
577 gethostname (name, len)
584 if (fp = fopen ("/etc/systemid", "r")) {
585 if (fgets (name, len, fp)) {
586 if (cp = index (name, '\n'))
593 (void) strncpy (name, "altos", len);
601 static char username[BUFSIZ];
602 static char fullname[BUFSIZ];
611 register struct passwd *pw;
617 if ((pw = getpwuid (getuid ())) == NULL
618 || pw -> pw_name == NULL
619 || *pw -> pw_name == NULL) {
622 if (uid == geteuid () && (cp = getenv ("USER")) != NULL
623 && (pw = getpwnam (cp)) != NULL)
624 strcpy (username, cp);
625 else if ((pw = getpwuid (uid)) == NULL
626 || pw -> pw_name == NULL
627 || *pw -> pw_name == '\0') {
629 (void) strcpy (username, "unknown");
630 (void) sprintf (fullname, "The Unknown User-ID (%d)", getuid ());
636 for (cp = fullname; *np && *np != (MMailids ? '<' : ','); *cp++ = *np++)
639 for (cp = fullname; *np && *np != (MMailids ? '<' : ','); )
640 if (*np == '&') { /* blech! */
641 (void) strcpy(cp, pw -> pw_name);
654 for (cp = username; *np && *np != '>'; *cp++ = *np++)
658 if (MMailids == 0 || *np == '\0')
659 (void) strcpy (username, pw -> pw_name);
661 if ((cp = getenv ("SIGNATURE")) && *cp)
662 (void) strcpy (fullname, cp);
663 if (index(fullname, '.')) { /* quote any .'s */
665 sprintf (tmp, "\"%s\"", fullname);/* should quote "'s too */
666 strcpy (fullname, tmp);
673 char *getfullname () {
674 if (username[0] == '\0')
683 #ifndef notdef /* Supposedly this works, I prefer the
684 recursive solution... */
698 if ((d = fcntl (d1, F_DUPFD, d2)) == NOTOK)
716 return dup2aux (d1, d2);
720 static int dup2aux (d1, d2)
728 if ((d = dup (d1)) == NOTOK)
733 i = dup2aux (d1, d2);
746 @and "client" (clientname) tailor option
751 static char ident[] = "@@(#)$Id: mts.c,v 2.18 1993/08/19 23:36:12 jromine Exp jromine $";
754 char *clientname = "";
757 "client", &clientname,
763 @use GCOS_HACK (instead of FINGER_HACK)
768 static char ident[] = "@@(#)$Id: mts.c,v 2.17 1993/08/19 23:08:05 jromine Exp jromine $";
781 static char ident[] = "@@(#)$Id: mts.c,v 2.16 1992/11/24 18:40:34 jromine Exp jromine $";
795 static char ident[] = "@@(#)$Id: mts.c,v 2.15 1992/11/02 18:58:12 jromine Exp jromine $";
808 static char ident[] = "@@(#)$Id: mts.c,v 2.14 1992/05/19 20:51:57 jromine Exp jromine $";
811 char *tailor_value ();
822 static char ident[] = "@@(#)$Id: mts.c,v 2.13 1992/05/12 21:46:45 jromine Exp jromine $";
836 static char ident[] = "@@(#)$Id: mts.c,v 2.12 1992/02/10 18:12:35 jromine Exp jromine $";
846 add "localdomain" tailor option
851 static char ident[] = "@@(#)$Id: mts.c,v 2.11 1992/02/05 17:08:16 jromine Exp jromine $";
903 #endif BSD42 or SOCKETS
906 #endif SYS5 and not NETWORK
915 #endif BSD42 or SOCKETS
927 #endif SYS5 and not NETWORK
933 #else SYS5 and not NETWORK
937 #endif SYS5 and not NETWORK
978 @put getpwnam(USER) under #ifdef KPOP
979 this is a major lose for shared accounts
984 static char ident[] = "@@(#)$Id: mts.c,v 2.10 1992/02/03 17:49:13 jromine Exp $";
989 return strcpy (buffer, localname);
1003 static char ident[] = "@@(#)$Id: mts.c,v 2.9 1992/02/03 16:34:00 jromine Exp jromine $";
1018 static char ident[] = "@@(#)$Id: mts.c,v 2.8 1992/01/31 21:37:07 jromine Exp jromine $";
1031 static char ident[] = "@@(#)$Id: mts.c,v 2.7 1991/02/14 15:17:56 mh Exp jromine $";
1039 @set signature from gecos field of passwd file. $SIGNATURE
1045 static char ident[] = "@@(#)$Id: mts.c,v 2.6 90/11/05 12:06:39 mh Exp Locker: mh $";
1048 #endif not (defined(BSD41A) || defined(BSD42) || defined(SOCKETS))
1051 #endif BSD42 or SOCKETS
1063 if (*buffer == '#' || *buffer == NULL)
1081 static char username[BUFSIZ] = "";
1082 static char fullname[BUFSIZ] = "";
1086 if ((pw = getpwuid (getuid ())) == NULL
1087 || pw -> pw_name == NULL
1088 || *pw -> pw_name == NULL) {
1097 if (MMailids == 0 || *np == NULL)
1100 if (username[0] == NULL)
1106 @quote bad signatures with "..."
1112 static char ident[] = "@@(#)$Id: mts.c,v 2.5 90/04/05 15:29:04 sources Exp Locker: mh $";
1115 np = pw -> pw_gecos;
1116 for (cp = fullname; *np && *np != '<'; *cp++ = *np++)
1121 if (MMailids == 0 || *np == NULL) {
1128 sprintf (tmp, "\"%s\"", fullname);
1139 static char ident[] = "@@(#)$Id:$";
1142 * If the fullname contains any .'s, quote it
1144 if (index(fullname, '.')) {
1146 sprintf (tmp, "\"%s\"", fullname);
1147 strcpy (fullname, tmp);
1160 static char ident[] = "$Id:";
1166 @"intruder" -> "unknown"
1167 quote any full names with "."s
1181 (void) strcpy (username, "intruder");
1188 @new #define SOCKETS for non-bsd machines with socket(), et. al.
1192 #define grot(x) case 'x': *bp = '\x'; break
1204 @changes for SUN40 shared libraries and NNTP under bbc
1209 #if defined(BSD41A) || defined(BSD42)
1212 #endif not (defined(BSD41A) || defined(BSD42))