1294Seric # include <pwd.h> 23309Seric # include "sendmail.h" 3404Seric 4294Seric /* 53309Seric ** CONF.C -- Sendmail Configuration Tables. 6294Seric ** 7294Seric ** Defines the configuration of this installation. 8294Seric ** 91388Seric ** Compilation Flags: 101388Seric ** V6 -- running on a version 6 system. This determines 111388Seric ** whether to define certain routines between 121388Seric ** the two systems. If you are running a funny 131388Seric ** system, e.g., V6 with long tty names, this 141388Seric ** should be checked carefully. 15294Seric ** 161388Seric ** Configuration Variables: 172897Seric ** HdrInfo -- a table describing well-known header fields. 182897Seric ** Each entry has the field name and some flags, 194147Seric ** which are described in sendmail.h. 204093Seric ** 214093Seric ** Notes: 224093Seric ** I have tried to put almost all the reasonable 234093Seric ** configuration information into the configuration 244093Seric ** file read at runtime. My intent is that anything 254093Seric ** here is a function of the version of UNIX you 264093Seric ** are running, or is really static -- for example 274093Seric ** the headers are a superset of widely used 284093Seric ** protocols. If you find yourself playing with 294093Seric ** this file too much, you may be making a mistake! 30294Seric */ 31294Seric 32294Seric 33294Seric 34294Seric 35*4193Seric static char SccsId[] = "@(#)conf.c 3.21 08/21/81"; 36294Seric 371388Seric 381388Seric # include <whoami.h> /* definitions of machine id's at berkeley */ 391388Seric 403061Seric 412897Seric /* 422897Seric ** Header info table 433057Seric ** Final (null) entry contains the flags used for any other field. 444147Seric ** 454147Seric ** Not all of these are actually handled specially by sendmail 464147Seric ** at this time. They are included as placeholders, to let 474147Seric ** you know that "someday" I intend to have sendmail do 484147Seric ** something with them. 492897Seric */ 502897Seric 512897Seric struct hdrinfo HdrInfo[] = 522897Seric { 534147Seric "date", H_CHECK, M_NEEDDATE, 544147Seric "from", H_CHECK, M_NEEDFROM, 554147Seric "sender", 0, 0, 564147Seric "full-name", H_ACHECK, M_FULLNAME, 574147Seric "to", 0, 0, 584147Seric "cc", 0, 0, 594147Seric "bcc", 0, 0, 604147Seric "message-id", H_CHECK, M_MSGID, 614147Seric "message", H_EOH, 0, 624147Seric "text", H_EOH, 0, 634147Seric "posted-date", 0, 0, 644147Seric "return-receipt-to", 0, 0, 65*4193Seric "received-date", H_CHECK, M_LOCAL, 66*4193Seric "received-from", H_CHECK, M_LOCAL, 674147Seric "precedence", 0, 0, 684147Seric "via", H_FORCE, 0, 694147Seric NULL, 0, 0, 702897Seric }; 714166Seric 724166Seric 734166Seric /* 744166Seric ** ARPANET error message numbers. 754166Seric */ 764166Seric 774166Seric # ifdef NEWFTP 784166Seric /* these are almost all unchecked */ 794166Seric char Arpa_Info[] = "010"; /* arbitrary info: this is WRONG! */ 804166Seric char Arpa_Enter[] = "354"; /* start mail input */ 814166Seric char Arpa_Mmsg[] = "250"; /* mail successful (MAIL cmd) */ 824166Seric char Arpa_Fmsg[] = "250"; /* mail successful (MLFL cmd) */ 834166Seric char Arpa_Syserr[] = "450"; /* some (transient) system error */ 844166Seric char Arpa_Usrerr[] = "550"; /* some (fatal) user error */ 854166Seric # else NEWFTP 864166Seric char Arpa_Info[] = "050"; /* arbitrary info */ 874166Seric char Arpa_Enter[] = "350"; /* start mail input */ 884166Seric char Arpa_Mmsg[] = "256"; /* mail successful (MAIL cmd) */ 894166Seric char Arpa_Fmsg[] = "250"; /* mail successful (MLFL cmd) */ 904166Seric char Arpa_Syserr[] = "455"; /* some (transient) system error */ 914166Seric char Arpa_Usrerr[] = "450"; /* some (fatal) user error */ 924166Seric # endif NEWFTP 93294Seric 94294Seric # ifdef V6 95294Seric /* 964190Seric ** TTYNAME -- return name of terminal. 97294Seric ** 98294Seric ** Parameters: 994190Seric ** fd -- file descriptor to check. 100294Seric ** 101294Seric ** Returns: 1024190Seric ** pointer to full path of tty. 1034190Seric ** NULL if no tty. 104294Seric ** 105294Seric ** Side Effects: 106294Seric ** none. 107294Seric */ 108294Seric 109294Seric char * 1104190Seric ttyname(fd) 1114190Seric int fd; 112294Seric { 1134190Seric register char tn; 114294Seric static char pathn[] = "/dev/ttyx"; 115294Seric 116294Seric /* compute the pathname of the controlling tty */ 1174190Seric if ((tn = ttyn(fd)) == NULL) 118294Seric { 119294Seric errno = 0; 120294Seric return (NULL); 121294Seric } 1224190Seric pathn[8] = tn; 123294Seric return (pathn); 124294Seric } 125294Seric /* 126294Seric ** FDOPEN -- Open a stdio file given an open file descriptor. 127294Seric ** 128294Seric ** This is included here because it is standard in v7, but we 129294Seric ** need it in v6. 130294Seric ** 131294Seric ** Algorithm: 132294Seric ** Open /dev/null to create a descriptor. 133294Seric ** Close that descriptor. 134294Seric ** Copy the existing fd into the descriptor. 135294Seric ** 136294Seric ** Parameters: 137294Seric ** fd -- the open file descriptor. 138294Seric ** type -- "r", "w", or whatever. 139294Seric ** 140294Seric ** Returns: 141294Seric ** The file descriptor it creates. 142294Seric ** 143294Seric ** Side Effects: 144294Seric ** none 145294Seric ** 146294Seric ** Called By: 147294Seric ** deliver 148294Seric ** 149294Seric ** Notes: 150294Seric ** The mode of fd must match "type". 151294Seric */ 152294Seric 153294Seric FILE * 154294Seric fdopen(fd, type) 155294Seric int fd; 156294Seric char *type; 157294Seric { 158294Seric register FILE *f; 159294Seric 160294Seric f = fopen("/dev/null", type); 1614081Seric (void) close(fileno(f)); 162294Seric fileno(f) = fd; 163294Seric return (f); 164294Seric } 165294Seric /* 166294Seric ** INDEX -- Return pointer to character in string 167294Seric ** 168294Seric ** For V7 compatibility. 169294Seric ** 170294Seric ** Parameters: 171294Seric ** s -- a string to scan. 172294Seric ** c -- a character to look for. 173294Seric ** 174294Seric ** Returns: 175294Seric ** If c is in s, returns the address of the first 176294Seric ** instance of c in s. 177294Seric ** NULL if c is not in s. 178294Seric ** 179294Seric ** Side Effects: 180294Seric ** none. 181294Seric */ 182294Seric 183294Seric index(s, c) 184294Seric register char *s; 185294Seric register char c; 186294Seric { 187294Seric while (*s != '\0') 188294Seric { 189294Seric if (*s++ == c) 190294Seric return (--s); 191294Seric } 192294Seric return (NULL); 193294Seric } 194294Seric # endif V6 1954190Seric /* 1964190Seric ** TTYPATH -- Get the path of the user's tty 197294Seric ** 198294Seric ** Returns the pathname of the user's tty. Returns NULL if 199294Seric ** the user is not logged in or if s/he has write permission 200294Seric ** denied. 201294Seric ** 202294Seric ** Parameters: 203294Seric ** none 204294Seric ** 205294Seric ** Returns: 206294Seric ** pathname of the user's tty. 207294Seric ** NULL if not logged in or write permission denied. 208294Seric ** 209294Seric ** Side Effects: 210294Seric ** none. 211294Seric ** 212294Seric ** WARNING: 213294Seric ** Return value is in a local buffer. 214294Seric ** 215294Seric ** Called By: 216294Seric ** savemail 217294Seric */ 218294Seric 219294Seric # include <sys/stat.h> 220294Seric 221294Seric char * 222294Seric ttypath() 223294Seric { 224294Seric struct stat stbuf; 225294Seric register char *pathn; 226294Seric extern char *ttyname(); 2274081Seric extern char *getlogin(); 228294Seric 229294Seric /* compute the pathname of the controlling tty */ 230294Seric if ((pathn = ttyname(2)) == NULL && (pathn = ttyname(1)) == NULL && (pathn = ttyname(0)) == NULL) 231294Seric { 232294Seric errno = 0; 233294Seric return (NULL); 234294Seric } 235294Seric 236294Seric /* see if we have write permission */ 2372967Seric if (stat(pathn, &stbuf) < 0 || !bitset(02, stbuf.st_mode)) 238294Seric { 239294Seric errno = 0; 240294Seric return (NULL); 241294Seric } 242294Seric 243294Seric /* see if the user is logged in */ 244294Seric if (getlogin() == NULL) 245294Seric return (NULL); 246294Seric 247294Seric /* looks good */ 248294Seric return (pathn); 249294Seric } 2502967Seric /* 2512967Seric ** CHECKCOMPAT -- check for From and To person compatible. 2522967Seric ** 2532967Seric ** This routine can be supplied on a per-installation basis 2542967Seric ** to determine whether a person is allowed to send a message. 2552967Seric ** This allows restriction of certain types of internet 2562967Seric ** forwarding or registration of users. 2572967Seric ** 2582967Seric ** If the hosts are found to be incompatible, an error 2592967Seric ** message should be given using "usrerr" and FALSE should 2602967Seric ** be returned. 2612967Seric ** 2622967Seric ** Parameters: 2632967Seric ** to -- the person being sent to. 2642967Seric ** 2652967Seric ** Returns: 2662967Seric ** TRUE -- ok to send. 2672967Seric ** FALSE -- not ok. 2682967Seric ** 2692967Seric ** Side Effects: 2702967Seric ** none (unless you include the usrerr stuff) 2712967Seric */ 2722967Seric 2732967Seric bool 2742967Seric checkcompat(to) 2752967Seric register ADDRESS *to; 2762967Seric { 2774081Seric # ifdef lint 2784081Seric ADDRESS *x = to; 2794081Seric 2804081Seric to = x; 2814081Seric # endif lint 2824081Seric 2832967Seric return (TRUE); 2842967Seric } 285