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. 204315Seric ** StdTimezone -- name of local timezone in standard time 214315Seric ** (V6 only). 224315Seric ** DstTimezone -- name of local timezone in daylight savings 234315Seric ** time (V6 only). 244093Seric ** 254093Seric ** Notes: 264093Seric ** I have tried to put almost all the reasonable 274093Seric ** configuration information into the configuration 284093Seric ** file read at runtime. My intent is that anything 294093Seric ** here is a function of the version of UNIX you 304093Seric ** are running, or is really static -- for example 314093Seric ** the headers are a superset of widely used 324093Seric ** protocols. If you find yourself playing with 334093Seric ** this file too much, you may be making a mistake! 34294Seric */ 35294Seric 36294Seric 37294Seric 38294Seric 39*4369Seric static char SccsId[] = "@(#)conf.c 3.30 09/12/81"; 40294Seric 411388Seric 421388Seric # include <whoami.h> /* definitions of machine id's at berkeley */ 431388Seric 443061Seric 452897Seric /* 462897Seric ** Header info table 473057Seric ** Final (null) entry contains the flags used for any other field. 484147Seric ** 494147Seric ** Not all of these are actually handled specially by sendmail 504147Seric ** at this time. They are included as placeholders, to let 514147Seric ** you know that "someday" I intend to have sendmail do 524147Seric ** something with them. 532897Seric */ 542897Seric 552897Seric struct hdrinfo HdrInfo[] = 562897Seric { 574147Seric "date", H_CHECK, M_NEEDDATE, 584147Seric "from", H_CHECK, M_NEEDFROM, 59*4369Seric "original-from", 0, 0, 604147Seric "sender", 0, 0, 614147Seric "full-name", H_ACHECK, M_FULLNAME, 624263Seric "to", H_ADDR, 0, 634263Seric "cc", H_ADDR, 0, 644263Seric "bcc", H_ADDR|H_ACHECK, 0, 654147Seric "message-id", H_CHECK, M_MSGID, 664147Seric "message", H_EOH, 0, 674147Seric "text", H_EOH, 0, 684147Seric "posted-date", 0, 0, 694147Seric "return-receipt-to", 0, 0, 704193Seric "received-date", H_CHECK, M_LOCAL, 714193Seric "received-from", H_CHECK, M_LOCAL, 724147Seric "precedence", 0, 0, 734147Seric "via", H_FORCE, 0, 744147Seric NULL, 0, 0, 752897Seric }; 764166Seric 774166Seric 784166Seric /* 794166Seric ** ARPANET error message numbers. 804166Seric */ 814166Seric 824166Seric # ifdef NEWFTP 834166Seric /* these are almost all unchecked */ 844166Seric char Arpa_Info[] = "010"; /* arbitrary info: this is WRONG! */ 854166Seric char Arpa_Enter[] = "354"; /* start mail input */ 864166Seric char Arpa_Mmsg[] = "250"; /* mail successful (MAIL cmd) */ 874166Seric char Arpa_Fmsg[] = "250"; /* mail successful (MLFL cmd) */ 884166Seric char Arpa_Syserr[] = "450"; /* some (transient) system error */ 894166Seric char Arpa_Usrerr[] = "550"; /* some (fatal) user error */ 904166Seric # else NEWFTP 914166Seric char Arpa_Info[] = "050"; /* arbitrary info */ 924166Seric char Arpa_Enter[] = "350"; /* start mail input */ 934166Seric char Arpa_Mmsg[] = "256"; /* mail successful (MAIL cmd) */ 944166Seric char Arpa_Fmsg[] = "250"; /* mail successful (MLFL cmd) */ 954166Seric char Arpa_Syserr[] = "455"; /* some (transient) system error */ 964166Seric char Arpa_Usrerr[] = "450"; /* some (fatal) user error */ 974166Seric # endif NEWFTP 984282Seric 994282Seric 1004282Seric 1014282Seric 1024282Seric 1034282Seric /* 1044282Seric ** Location of system files/databases/etc. 1054282Seric */ 1064282Seric 1074282Seric char *AliasFile = "/usr/lib/aliases"; /* alias file */ 1084282Seric char *ConfFile = "/usr/lib/sendmail.cf"; /* runtime configuration */ 1094282Seric char *StatFile = "/usr/eric/mailstats"; /* statistics summary */ 1104315Seric 1114315Seric 1124315Seric 1134315Seric /* 1144315Seric ** V6 system configuration. 1154315Seric */ 1164315Seric 1174315Seric # ifdef V6 1184315Seric char *StdTimezone = "PST"; /* std time timezone */ 1194315Seric char *DstTimezone = "PDT"; /* daylight time timezone */ 1204315Seric # endif V6 121294Seric 122294Seric # ifdef V6 123294Seric /* 1244190Seric ** TTYNAME -- return name of terminal. 125294Seric ** 126294Seric ** Parameters: 1274190Seric ** fd -- file descriptor to check. 128294Seric ** 129294Seric ** Returns: 1304190Seric ** pointer to full path of tty. 1314190Seric ** NULL if no tty. 132294Seric ** 133294Seric ** Side Effects: 134294Seric ** none. 135294Seric */ 136294Seric 137294Seric char * 1384190Seric ttyname(fd) 1394190Seric int fd; 140294Seric { 1414190Seric register char tn; 142294Seric static char pathn[] = "/dev/ttyx"; 143294Seric 144294Seric /* compute the pathname of the controlling tty */ 1454190Seric if ((tn = ttyn(fd)) == NULL) 146294Seric { 147294Seric errno = 0; 148294Seric return (NULL); 149294Seric } 1504190Seric pathn[8] = tn; 151294Seric return (pathn); 152294Seric } 153294Seric /* 154294Seric ** FDOPEN -- Open a stdio file given an open file descriptor. 155294Seric ** 156294Seric ** This is included here because it is standard in v7, but we 157294Seric ** need it in v6. 158294Seric ** 159294Seric ** Algorithm: 160294Seric ** Open /dev/null to create a descriptor. 161294Seric ** Close that descriptor. 162294Seric ** Copy the existing fd into the descriptor. 163294Seric ** 164294Seric ** Parameters: 165294Seric ** fd -- the open file descriptor. 166294Seric ** type -- "r", "w", or whatever. 167294Seric ** 168294Seric ** Returns: 169294Seric ** The file descriptor it creates. 170294Seric ** 171294Seric ** Side Effects: 172294Seric ** none 173294Seric ** 174294Seric ** Called By: 175294Seric ** deliver 176294Seric ** 177294Seric ** Notes: 178294Seric ** The mode of fd must match "type". 179294Seric */ 180294Seric 181294Seric FILE * 182294Seric fdopen(fd, type) 183294Seric int fd; 184294Seric char *type; 185294Seric { 186294Seric register FILE *f; 187294Seric 188294Seric f = fopen("/dev/null", type); 1894081Seric (void) close(fileno(f)); 190294Seric fileno(f) = fd; 191294Seric return (f); 192294Seric } 193294Seric /* 194294Seric ** INDEX -- Return pointer to character in string 195294Seric ** 196294Seric ** For V7 compatibility. 197294Seric ** 198294Seric ** Parameters: 199294Seric ** s -- a string to scan. 200294Seric ** c -- a character to look for. 201294Seric ** 202294Seric ** Returns: 203294Seric ** If c is in s, returns the address of the first 204294Seric ** instance of c in s. 205294Seric ** NULL if c is not in s. 206294Seric ** 207294Seric ** Side Effects: 208294Seric ** none. 209294Seric */ 210294Seric 211294Seric index(s, c) 212294Seric register char *s; 213294Seric register char c; 214294Seric { 215294Seric while (*s != '\0') 216294Seric { 217294Seric if (*s++ == c) 218294Seric return (--s); 219294Seric } 220294Seric return (NULL); 221294Seric } 2224326Seric /* 2234326Seric ** UMASK -- fake the umask system call. 2244326Seric ** 2254326Seric ** Since V6 always acts like the umask is zero, we will just 2264326Seric ** assume the same thing. 2274326Seric */ 2284326Seric 2294326Seric /*ARGSUSED*/ 2304326Seric umask(nmask) 2314326Seric { 2324326Seric return (0); 2334326Seric } 2344326Seric 2354326Seric 2364326Seric /* 2374326Seric ** GETRUID -- get real user id. 2384326Seric */ 2394326Seric 2404326Seric getruid() 2414326Seric { 2424326Seric return (getuid() & 0377); 2434326Seric } 2444326Seric 2454326Seric 2464326Seric /* 2474326Seric ** GETRGID -- get real group id. 2484326Seric */ 2494326Seric 2504326Seric getrgid() 2514326Seric { 2524326Seric return (getgid() & 0377); 2534326Seric } 2544326Seric 2554326Seric 2564326Seric /* 2574326Seric ** GETEUID -- get effective user id. 2584326Seric */ 2594326Seric 2604326Seric geteuid() 2614326Seric { 2624326Seric return ((getuid() >> 8) & 0377); 2634326Seric } 2644326Seric 2654326Seric 2664326Seric /* 2674326Seric ** GETEGID -- get effective group id. 2684326Seric */ 2694326Seric 2704326Seric getegid() 2714326Seric { 2724326Seric return ((getgid() >> 8) & 0377); 2734326Seric } 2744326Seric 275294Seric # endif V6 2764326Seric 2774326Seric # ifndef V6 2784326Seric 2794326Seric /* 2804326Seric ** GETRUID -- get real user id (V7) 2814326Seric */ 2824326Seric 2834326Seric getruid() 2844326Seric { 2854326Seric return (getuid()); 2864326Seric } 2874326Seric 2884326Seric 2894326Seric /* 2904326Seric ** GETRGID -- get real group id (V7). 2914326Seric */ 2924326Seric 2934326Seric getrgid() 2944326Seric { 2954326Seric return (getgid()); 2964326Seric } 2974326Seric 2984326Seric # endif V6 2994190Seric /* 3004190Seric ** TTYPATH -- Get the path of the user's tty 301294Seric ** 302294Seric ** Returns the pathname of the user's tty. Returns NULL if 303294Seric ** the user is not logged in or if s/he has write permission 304294Seric ** denied. 305294Seric ** 306294Seric ** Parameters: 307294Seric ** none 308294Seric ** 309294Seric ** Returns: 310294Seric ** pathname of the user's tty. 311294Seric ** NULL if not logged in or write permission denied. 312294Seric ** 313294Seric ** Side Effects: 314294Seric ** none. 315294Seric ** 316294Seric ** WARNING: 317294Seric ** Return value is in a local buffer. 318294Seric ** 319294Seric ** Called By: 320294Seric ** savemail 321294Seric */ 322294Seric 323294Seric # include <sys/stat.h> 324294Seric 325294Seric char * 326294Seric ttypath() 327294Seric { 328294Seric struct stat stbuf; 329294Seric register char *pathn; 330294Seric extern char *ttyname(); 3314081Seric extern char *getlogin(); 332294Seric 333294Seric /* compute the pathname of the controlling tty */ 334294Seric if ((pathn = ttyname(2)) == NULL && (pathn = ttyname(1)) == NULL && (pathn = ttyname(0)) == NULL) 335294Seric { 336294Seric errno = 0; 337294Seric return (NULL); 338294Seric } 339294Seric 340294Seric /* see if we have write permission */ 3412967Seric if (stat(pathn, &stbuf) < 0 || !bitset(02, stbuf.st_mode)) 342294Seric { 343294Seric errno = 0; 344294Seric return (NULL); 345294Seric } 346294Seric 347294Seric /* see if the user is logged in */ 348294Seric if (getlogin() == NULL) 349294Seric return (NULL); 350294Seric 351294Seric /* looks good */ 352294Seric return (pathn); 353294Seric } 3542967Seric /* 3552967Seric ** CHECKCOMPAT -- check for From and To person compatible. 3562967Seric ** 3572967Seric ** This routine can be supplied on a per-installation basis 3582967Seric ** to determine whether a person is allowed to send a message. 3592967Seric ** This allows restriction of certain types of internet 3602967Seric ** forwarding or registration of users. 3612967Seric ** 3622967Seric ** If the hosts are found to be incompatible, an error 3632967Seric ** message should be given using "usrerr" and FALSE should 3642967Seric ** be returned. 3652967Seric ** 3664288Seric ** 'NoReturn' can be set to suppress the return-to-sender 3674288Seric ** function; this should be done on huge messages. 3684288Seric ** 3692967Seric ** Parameters: 3702967Seric ** to -- the person being sent to. 3712967Seric ** 3722967Seric ** Returns: 3732967Seric ** TRUE -- ok to send. 3742967Seric ** FALSE -- not ok. 3752967Seric ** 3762967Seric ** Side Effects: 3772967Seric ** none (unless you include the usrerr stuff) 3782967Seric */ 3792967Seric 3802967Seric bool 3812967Seric checkcompat(to) 3822967Seric register ADDRESS *to; 3832967Seric { 3844288Seric if (to->q_mailer != MN_LOCAL && MsgSize > 100000) 3854288Seric { 3864288Seric usrerr("Message exceeds 100000 bytes"); 3874288Seric NoReturn++; 3884288Seric return (FALSE); 3894288Seric } 3902967Seric return (TRUE); 3912967Seric } 392