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*5178Seric static char SccsId[] = "@(#)conf.c 3.40 12/05/81"; 404437Seric 414437Seric 424437Seric # include <whoami.h> /* definitions of machine id's at berkeley */ 434437Seric 444437Seric 454437Seric /* 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, 594369Seric "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 char Arpa_Info[] = "050"; /* arbitrary info */ 834708Seric char Arpa_Syserr[] = "451"; /* some (transient) system error */ 844708Seric char Arpa_Usrerr[] = "554"; /* some (fatal) user error */ 854282Seric 864282Seric 874282Seric 884282Seric 894282Seric 904282Seric /* 914282Seric ** Location of system files/databases/etc. 924282Seric */ 934282Seric 944282Seric char *AliasFile = "/usr/lib/aliases"; /* alias file */ 954282Seric char *ConfFile = "/usr/lib/sendmail.cf"; /* runtime configuration */ 964778Seric char *StatFile = "/usr/lib/sendmail.st"; /* statistics summary */ 974581Seric char *HelpFile = "/usr/lib/sendmail.hf"; /* help file */ 98*5178Seric # ifdef QUEUE 994620Seric char *QueueDir = "/usr/spool/mqueue"; /* queue of saved mail */ 100*5178Seric # else QUEUE 101*5178Seric char *QueueDir = "/tmp"; /* location of temp files */ 102*5178Seric # endif QUEUE 1034620Seric char *XcriptFile = "/tmp/mailxXXXXXX"; /* template for transcript */ 1044315Seric 1054315Seric 1064414Seric /* 1074414Seric ** Other configuration. 1084414Seric */ 1094315Seric 1104414Seric int DefUid = 1; /* the uid to execute mailers as */ 1114414Seric int DefGid = 1; /* ditto for gid */ 1124620Seric time_t TimeOut = 3*24*60*60; /* default timeout for queue files */ 1134414Seric 1144414Seric 1154414Seric 1164315Seric /* 1174315Seric ** V6 system configuration. 1184315Seric */ 1194315Seric 1204315Seric # ifdef V6 1214315Seric char *StdTimezone = "PST"; /* std time timezone */ 1224315Seric char *DstTimezone = "PDT"; /* daylight time timezone */ 1234315Seric # endif V6 124294Seric 125294Seric # ifdef V6 126294Seric /* 1274190Seric ** TTYNAME -- return name of terminal. 128294Seric ** 129294Seric ** Parameters: 1304190Seric ** fd -- file descriptor to check. 131294Seric ** 132294Seric ** Returns: 1334190Seric ** pointer to full path of tty. 1344190Seric ** NULL if no tty. 135294Seric ** 136294Seric ** Side Effects: 137294Seric ** none. 138294Seric */ 139294Seric 140294Seric char * 1414190Seric ttyname(fd) 1424190Seric int fd; 143294Seric { 1444190Seric register char tn; 145294Seric static char pathn[] = "/dev/ttyx"; 146294Seric 147294Seric /* compute the pathname of the controlling tty */ 1484190Seric if ((tn = ttyn(fd)) == NULL) 149294Seric { 150294Seric errno = 0; 151294Seric return (NULL); 152294Seric } 1534190Seric pathn[8] = tn; 154294Seric return (pathn); 155294Seric } 156294Seric /* 157294Seric ** FDOPEN -- Open a stdio file given an open file descriptor. 158294Seric ** 159294Seric ** This is included here because it is standard in v7, but we 160294Seric ** need it in v6. 161294Seric ** 162294Seric ** Algorithm: 163294Seric ** Open /dev/null to create a descriptor. 164294Seric ** Close that descriptor. 165294Seric ** Copy the existing fd into the descriptor. 166294Seric ** 167294Seric ** Parameters: 168294Seric ** fd -- the open file descriptor. 169294Seric ** type -- "r", "w", or whatever. 170294Seric ** 171294Seric ** Returns: 172294Seric ** The file descriptor it creates. 173294Seric ** 174294Seric ** Side Effects: 175294Seric ** none 176294Seric ** 177294Seric ** Called By: 178294Seric ** deliver 179294Seric ** 180294Seric ** Notes: 181294Seric ** The mode of fd must match "type". 182294Seric */ 183294Seric 184294Seric FILE * 185294Seric fdopen(fd, type) 186294Seric int fd; 187294Seric char *type; 188294Seric { 189294Seric register FILE *f; 190294Seric 191294Seric f = fopen("/dev/null", type); 1924081Seric (void) close(fileno(f)); 193294Seric fileno(f) = fd; 194294Seric return (f); 195294Seric } 196294Seric /* 197294Seric ** INDEX -- Return pointer to character in string 198294Seric ** 199294Seric ** For V7 compatibility. 200294Seric ** 201294Seric ** Parameters: 202294Seric ** s -- a string to scan. 203294Seric ** c -- a character to look for. 204294Seric ** 205294Seric ** Returns: 206294Seric ** If c is in s, returns the address of the first 207294Seric ** instance of c in s. 208294Seric ** NULL if c is not in s. 209294Seric ** 210294Seric ** Side Effects: 211294Seric ** none. 212294Seric */ 213294Seric 2144437Seric char * 215294Seric index(s, c) 216294Seric register char *s; 217294Seric register char c; 218294Seric { 219294Seric while (*s != '\0') 220294Seric { 221294Seric if (*s++ == c) 222294Seric return (--s); 223294Seric } 224294Seric return (NULL); 225294Seric } 2264326Seric /* 2274326Seric ** UMASK -- fake the umask system call. 2284326Seric ** 2294326Seric ** Since V6 always acts like the umask is zero, we will just 2304326Seric ** assume the same thing. 2314326Seric */ 2324326Seric 2334326Seric /*ARGSUSED*/ 2344326Seric umask(nmask) 2354326Seric { 2364326Seric return (0); 2374326Seric } 2384326Seric 2394326Seric 2404326Seric /* 2414326Seric ** GETRUID -- get real user id. 2424326Seric */ 2434326Seric 2444326Seric getruid() 2454326Seric { 2464326Seric return (getuid() & 0377); 2474326Seric } 2484326Seric 2494326Seric 2504326Seric /* 2514326Seric ** GETRGID -- get real group id. 2524326Seric */ 2534326Seric 2544326Seric getrgid() 2554326Seric { 2564326Seric return (getgid() & 0377); 2574326Seric } 2584326Seric 2594326Seric 2604326Seric /* 2614326Seric ** GETEUID -- get effective user id. 2624326Seric */ 2634326Seric 2644326Seric geteuid() 2654326Seric { 2664326Seric return ((getuid() >> 8) & 0377); 2674326Seric } 2684326Seric 2694326Seric 2704326Seric /* 2714326Seric ** GETEGID -- get effective group id. 2724326Seric */ 2734326Seric 2744326Seric getegid() 2754326Seric { 2764326Seric return ((getgid() >> 8) & 0377); 2774326Seric } 2784326Seric 279294Seric # endif V6 2804326Seric 2814326Seric # ifndef V6 2824326Seric 2834326Seric /* 2844326Seric ** GETRUID -- get real user id (V7) 2854326Seric */ 2864326Seric 2874326Seric getruid() 2884326Seric { 2894536Seric if (Daemon) 2904536Seric return (RealUid); 2914536Seric else 2924536Seric return (getuid()); 2934326Seric } 2944326Seric 2954326Seric 2964326Seric /* 2974326Seric ** GETRGID -- get real group id (V7). 2984326Seric */ 2994326Seric 3004326Seric getrgid() 3014326Seric { 3024536Seric if (Daemon) 3034536Seric return (RealGid); 3044536Seric else 3054536Seric return (getgid()); 3064326Seric } 3074326Seric 3084326Seric # endif V6 3094190Seric /* 3104190Seric ** TTYPATH -- Get the path of the user's tty 311294Seric ** 312294Seric ** Returns the pathname of the user's tty. Returns NULL if 313294Seric ** the user is not logged in or if s/he has write permission 314294Seric ** denied. 315294Seric ** 316294Seric ** Parameters: 317294Seric ** none 318294Seric ** 319294Seric ** Returns: 320294Seric ** pathname of the user's tty. 321294Seric ** NULL if not logged in or write permission denied. 322294Seric ** 323294Seric ** Side Effects: 324294Seric ** none. 325294Seric ** 326294Seric ** WARNING: 327294Seric ** Return value is in a local buffer. 328294Seric ** 329294Seric ** Called By: 330294Seric ** savemail 331294Seric */ 332294Seric 333294Seric # include <sys/stat.h> 334294Seric 335294Seric char * 336294Seric ttypath() 337294Seric { 338294Seric struct stat stbuf; 339294Seric register char *pathn; 340294Seric extern char *ttyname(); 3414081Seric extern char *getlogin(); 342294Seric 343294Seric /* compute the pathname of the controlling tty */ 344294Seric if ((pathn = ttyname(2)) == NULL && (pathn = ttyname(1)) == NULL && (pathn = ttyname(0)) == NULL) 345294Seric { 346294Seric errno = 0; 347294Seric return (NULL); 348294Seric } 349294Seric 350294Seric /* see if we have write permission */ 3512967Seric if (stat(pathn, &stbuf) < 0 || !bitset(02, stbuf.st_mode)) 352294Seric { 353294Seric errno = 0; 354294Seric return (NULL); 355294Seric } 356294Seric 357294Seric /* see if the user is logged in */ 358294Seric if (getlogin() == NULL) 359294Seric return (NULL); 360294Seric 361294Seric /* looks good */ 362294Seric return (pathn); 363294Seric } 3642967Seric /* 3652967Seric ** CHECKCOMPAT -- check for From and To person compatible. 3662967Seric ** 3672967Seric ** This routine can be supplied on a per-installation basis 3682967Seric ** to determine whether a person is allowed to send a message. 3692967Seric ** This allows restriction of certain types of internet 3702967Seric ** forwarding or registration of users. 3712967Seric ** 3722967Seric ** If the hosts are found to be incompatible, an error 3732967Seric ** message should be given using "usrerr" and FALSE should 3742967Seric ** be returned. 3752967Seric ** 3764288Seric ** 'NoReturn' can be set to suppress the return-to-sender 3774288Seric ** function; this should be done on huge messages. 3784288Seric ** 3792967Seric ** Parameters: 3802967Seric ** to -- the person being sent to. 3812967Seric ** 3822967Seric ** Returns: 3832967Seric ** TRUE -- ok to send. 3842967Seric ** FALSE -- not ok. 3852967Seric ** 3862967Seric ** Side Effects: 3872967Seric ** none (unless you include the usrerr stuff) 3882967Seric */ 3892967Seric 3902967Seric bool 3912967Seric checkcompat(to) 3922967Seric register ADDRESS *to; 3932967Seric { 3944620Seric # ifdef ING70 3954437Seric register STAB *s; 3964620Seric # endif ING70 3974437Seric 3984595Seric if (to->q_mailer != LocalMailer && MsgSize > 100000) 3994288Seric { 4004288Seric usrerr("Message exceeds 100000 bytes"); 4014288Seric NoReturn++; 4024288Seric return (FALSE); 4034288Seric } 4044437Seric # ifdef ING70 4054437Seric s = stab("arpa", ST_MAILER, ST_FIND); 4064595Seric if (s != NULL && From.q_mailer != LocalMailer && to->q_mailer == s->s_mailer) 4074437Seric { 4084437Seric usrerr("No ARPA mail through this machine: see your system administration"); 4094437Seric return (FALSE); 4104437Seric } 4114437Seric # endif ING70 4122967Seric return (TRUE); 4132967Seric } 414