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*8060Seric SCCSID(@(#)conf.c 3.56 09/05/82); 404437Seric 414437Seric 424437Seric 434437Seric /* 442897Seric ** Header info table 453057Seric ** Final (null) entry contains the flags used for any other field. 464147Seric ** 474147Seric ** Not all of these are actually handled specially by sendmail 484147Seric ** at this time. They are included as placeholders, to let 494147Seric ** you know that "someday" I intend to have sendmail do 504147Seric ** something with them. 512897Seric */ 522897Seric 532897Seric struct hdrinfo HdrInfo[] = 542897Seric { 55*8060Seric /* date information */ 56*8060Seric "posted-date", 0, 0, 574147Seric "date", H_CHECK, M_NEEDDATE, 58*8060Seric "resent-date", 0, 0, 59*8060Seric "received-date", H_CHECK, M_LOCAL, 60*8060Seric /* originator fields, most to least significant */ 61*8060Seric "resent-sender", H_FROM, 0, 62*8060Seric "resent-from", H_FROM, 0, 63*8060Seric "sender", H_FROM, 0, 64*8060Seric "from", H_FROM|H_CHECK, M_NEEDFROM, 654369Seric "original-from", 0, 0, 664147Seric "full-name", H_ACHECK, M_FULLNAME, 67*8060Seric "received-from", H_CHECK, M_LOCAL, 68*8060Seric "return-receipt-to", H_FROM, 0, 69*8060Seric /* destination fields */ 70*8060Seric "to", H_RCPT, 0, 71*8060Seric "resent-to", H_RCPT, 0, 72*8060Seric "cc", H_RCPT, 0, 73*8060Seric "resent-cc", H_RCPT, 0, 74*8060Seric "bcc", H_RCPT, 0, 75*8060Seric "resent-bcc", H_RCPT, 0, 76*8060Seric /* message identification and control */ 777669Seric "message-id", 0, 0, 78*8060Seric "resent-message-id", 0, 0, 79*8060Seric "precedence", 0, 0, 804147Seric "message", H_EOH, 0, 814147Seric "text", H_EOH, 0, 82*8060Seric /* trace fields */ 83*8060Seric "received", H_TRACE|H_FORCE, 0, 84*8060Seric "via", H_TRACE|H_FORCE, 0, 85*8060Seric "mail-from", H_TRACE|H_FORCE, 0, 86*8060Seric 874147Seric NULL, 0, 0, 882897Seric }; 894166Seric 904166Seric 914166Seric /* 924166Seric ** ARPANET error message numbers. 934166Seric */ 944166Seric 957956Seric char Arpa_Info[] = "050"; /* arbitrary info */ 967956Seric char Arpa_TSyserr[] = "451"; /* some (transient) system error */ 977956Seric char Arpa_PSyserr[] = "554"; /* some (permanent) system error */ 987956Seric char Arpa_Usrerr[] = "554"; /* some (fatal) user error */ 994282Seric 1004282Seric 1014282Seric 1024282Seric 1034282Seric 1044282Seric /* 1054282Seric ** Location of system files/databases/etc. 1064282Seric */ 1074282Seric 1084282Seric char *AliasFile = "/usr/lib/aliases"; /* alias file */ 1094282Seric char *ConfFile = "/usr/lib/sendmail.cf"; /* runtime configuration */ 1104778Seric char *StatFile = "/usr/lib/sendmail.st"; /* statistics summary */ 1114581Seric char *HelpFile = "/usr/lib/sendmail.hf"; /* help file */ 1125178Seric # ifdef QUEUE 1134620Seric char *QueueDir = "/usr/spool/mqueue"; /* queue of saved mail */ 1145178Seric # else QUEUE 1155178Seric char *QueueDir = "/tmp"; /* location of temp files */ 1165178Seric # endif QUEUE 1174620Seric char *XcriptFile = "/tmp/mailxXXXXXX"; /* template for transcript */ 1184315Seric 1194315Seric 1204414Seric /* 1214414Seric ** Other configuration. 1224414Seric */ 1234315Seric 1247354Seric int DefUid = 1; /* the uid to execute mailers as */ 1257354Seric int DefGid = 1; /* ditto for gid */ 1267354Seric time_t TimeOut = 3*24*60*60L; /* default timeout for queue files */ 1277354Seric int ReadTimeout = 10*60; /* timeout on external reads */ 1287679Seric int LogLevel = 9; /* default logging level */ 1294414Seric 1304414Seric 1314414Seric 1324315Seric /* 1334315Seric ** V6 system configuration. 1344315Seric */ 1354315Seric 1364315Seric # ifdef V6 1374315Seric char *StdTimezone = "PST"; /* std time timezone */ 1384315Seric char *DstTimezone = "PDT"; /* daylight time timezone */ 1394315Seric # endif V6 140294Seric 141294Seric # ifdef V6 142294Seric /* 1434190Seric ** TTYNAME -- return name of terminal. 144294Seric ** 145294Seric ** Parameters: 1464190Seric ** fd -- file descriptor to check. 147294Seric ** 148294Seric ** Returns: 1494190Seric ** pointer to full path of tty. 1504190Seric ** NULL if no tty. 151294Seric ** 152294Seric ** Side Effects: 153294Seric ** none. 154294Seric */ 155294Seric 156294Seric char * 1574190Seric ttyname(fd) 1584190Seric int fd; 159294Seric { 1604190Seric register char tn; 161294Seric static char pathn[] = "/dev/ttyx"; 162294Seric 163294Seric /* compute the pathname of the controlling tty */ 1644190Seric if ((tn = ttyn(fd)) == NULL) 165294Seric { 166294Seric errno = 0; 167294Seric return (NULL); 168294Seric } 1694190Seric pathn[8] = tn; 170294Seric return (pathn); 171294Seric } 172294Seric /* 173294Seric ** FDOPEN -- Open a stdio file given an open file descriptor. 174294Seric ** 175294Seric ** This is included here because it is standard in v7, but we 176294Seric ** need it in v6. 177294Seric ** 178294Seric ** Algorithm: 179294Seric ** Open /dev/null to create a descriptor. 180294Seric ** Close that descriptor. 181294Seric ** Copy the existing fd into the descriptor. 182294Seric ** 183294Seric ** Parameters: 184294Seric ** fd -- the open file descriptor. 185294Seric ** type -- "r", "w", or whatever. 186294Seric ** 187294Seric ** Returns: 188294Seric ** The file descriptor it creates. 189294Seric ** 190294Seric ** Side Effects: 191294Seric ** none 192294Seric ** 193294Seric ** Called By: 194294Seric ** deliver 195294Seric ** 196294Seric ** Notes: 197294Seric ** The mode of fd must match "type". 198294Seric */ 199294Seric 200294Seric FILE * 201294Seric fdopen(fd, type) 202294Seric int fd; 203294Seric char *type; 204294Seric { 205294Seric register FILE *f; 206294Seric 207294Seric f = fopen("/dev/null", type); 2084081Seric (void) close(fileno(f)); 209294Seric fileno(f) = fd; 210294Seric return (f); 211294Seric } 212294Seric /* 213294Seric ** INDEX -- Return pointer to character in string 214294Seric ** 215294Seric ** For V7 compatibility. 216294Seric ** 217294Seric ** Parameters: 218294Seric ** s -- a string to scan. 219294Seric ** c -- a character to look for. 220294Seric ** 221294Seric ** Returns: 222294Seric ** If c is in s, returns the address of the first 223294Seric ** instance of c in s. 224294Seric ** NULL if c is not in s. 225294Seric ** 226294Seric ** Side Effects: 227294Seric ** none. 228294Seric */ 229294Seric 2304437Seric char * 231294Seric index(s, c) 232294Seric register char *s; 233294Seric register char c; 234294Seric { 235294Seric while (*s != '\0') 236294Seric { 237294Seric if (*s++ == c) 238294Seric return (--s); 239294Seric } 240294Seric return (NULL); 241294Seric } 2424326Seric /* 2434326Seric ** UMASK -- fake the umask system call. 2444326Seric ** 2454326Seric ** Since V6 always acts like the umask is zero, we will just 2464326Seric ** assume the same thing. 2474326Seric */ 2484326Seric 2494326Seric /*ARGSUSED*/ 2504326Seric umask(nmask) 2514326Seric { 2524326Seric return (0); 2534326Seric } 2544326Seric 2554326Seric 2564326Seric /* 2574326Seric ** GETRUID -- get real user id. 2584326Seric */ 2594326Seric 2604326Seric getruid() 2614326Seric { 2624326Seric return (getuid() & 0377); 2634326Seric } 2644326Seric 2654326Seric 2664326Seric /* 2674326Seric ** GETRGID -- get real group id. 2684326Seric */ 2694326Seric 2704326Seric getrgid() 2714326Seric { 2724326Seric return (getgid() & 0377); 2734326Seric } 2744326Seric 2754326Seric 2764326Seric /* 2774326Seric ** GETEUID -- get effective user id. 2784326Seric */ 2794326Seric 2804326Seric geteuid() 2814326Seric { 2824326Seric return ((getuid() >> 8) & 0377); 2834326Seric } 2844326Seric 2854326Seric 2864326Seric /* 2874326Seric ** GETEGID -- get effective group id. 2884326Seric */ 2894326Seric 2904326Seric getegid() 2914326Seric { 2924326Seric return ((getgid() >> 8) & 0377); 2934326Seric } 2944326Seric 295294Seric # endif V6 2964326Seric 2974326Seric # ifndef V6 2984326Seric 2994326Seric /* 3004326Seric ** GETRUID -- get real user id (V7) 3014326Seric */ 3024326Seric 3034326Seric getruid() 3044326Seric { 3056996Seric if (Mode == MD_DAEMON) 3064536Seric return (RealUid); 3074536Seric else 3084536Seric return (getuid()); 3094326Seric } 3104326Seric 3114326Seric 3124326Seric /* 3134326Seric ** GETRGID -- get real group id (V7). 3144326Seric */ 3154326Seric 3164326Seric getrgid() 3174326Seric { 3186996Seric if (Mode == MD_DAEMON) 3194536Seric return (RealGid); 3204536Seric else 3214536Seric return (getgid()); 3224326Seric } 3234326Seric 3244326Seric # endif V6 3254190Seric /* 3264190Seric ** TTYPATH -- Get the path of the user's tty 327294Seric ** 328294Seric ** Returns the pathname of the user's tty. Returns NULL if 329294Seric ** the user is not logged in or if s/he has write permission 330294Seric ** denied. 331294Seric ** 332294Seric ** Parameters: 333294Seric ** none 334294Seric ** 335294Seric ** Returns: 336294Seric ** pathname of the user's tty. 337294Seric ** NULL if not logged in or write permission denied. 338294Seric ** 339294Seric ** Side Effects: 340294Seric ** none. 341294Seric ** 342294Seric ** WARNING: 343294Seric ** Return value is in a local buffer. 344294Seric ** 345294Seric ** Called By: 346294Seric ** savemail 347294Seric */ 348294Seric 349294Seric # include <sys/stat.h> 350294Seric 351294Seric char * 352294Seric ttypath() 353294Seric { 354294Seric struct stat stbuf; 355294Seric register char *pathn; 356294Seric extern char *ttyname(); 3574081Seric extern char *getlogin(); 358294Seric 359294Seric /* compute the pathname of the controlling tty */ 360294Seric if ((pathn = ttyname(2)) == NULL && (pathn = ttyname(1)) == NULL && (pathn = ttyname(0)) == NULL) 361294Seric { 362294Seric errno = 0; 363294Seric return (NULL); 364294Seric } 365294Seric 366294Seric /* see if we have write permission */ 3672967Seric if (stat(pathn, &stbuf) < 0 || !bitset(02, stbuf.st_mode)) 368294Seric { 369294Seric errno = 0; 370294Seric return (NULL); 371294Seric } 372294Seric 373294Seric /* see if the user is logged in */ 374294Seric if (getlogin() == NULL) 375294Seric return (NULL); 376294Seric 377294Seric /* looks good */ 378294Seric return (pathn); 379294Seric } 3802967Seric /* 3812967Seric ** CHECKCOMPAT -- check for From and To person compatible. 3822967Seric ** 3832967Seric ** This routine can be supplied on a per-installation basis 3842967Seric ** to determine whether a person is allowed to send a message. 3852967Seric ** This allows restriction of certain types of internet 3862967Seric ** forwarding or registration of users. 3872967Seric ** 3882967Seric ** If the hosts are found to be incompatible, an error 3892967Seric ** message should be given using "usrerr" and FALSE should 3902967Seric ** be returned. 3912967Seric ** 3924288Seric ** 'NoReturn' can be set to suppress the return-to-sender 3934288Seric ** function; this should be done on huge messages. 3944288Seric ** 3952967Seric ** Parameters: 3962967Seric ** to -- the person being sent to. 3972967Seric ** 3982967Seric ** Returns: 3992967Seric ** TRUE -- ok to send. 4002967Seric ** FALSE -- not ok. 4012967Seric ** 4022967Seric ** Side Effects: 4032967Seric ** none (unless you include the usrerr stuff) 4042967Seric */ 4052967Seric 4062967Seric bool 4072967Seric checkcompat(to) 4082967Seric register ADDRESS *to; 4092967Seric { 4104620Seric # ifdef ING70 4114437Seric register STAB *s; 4124620Seric # endif ING70 4134437Seric 4146899Seric if (to->q_mailer != LocalMailer && CurEnv->e_msgsize > 100000) 4154288Seric { 4164288Seric usrerr("Message exceeds 100000 bytes"); 4174288Seric NoReturn++; 4184288Seric return (FALSE); 4194288Seric } 4204437Seric # ifdef ING70 4214437Seric s = stab("arpa", ST_MAILER, ST_FIND); 4226899Seric if (s != NULL && CurEnv->e_from.q_mailer != LocalMailer && to->q_mailer == s->s_mailer) 4234437Seric { 4244437Seric usrerr("No ARPA mail through this machine: see your system administration"); 4254437Seric return (FALSE); 4264437Seric } 4274437Seric # endif ING70 4282967Seric return (TRUE); 4292967Seric } 430