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*5184Seric static char SccsId[] = "@(#)conf.c 3.41 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, 73*5184Seric "mail-from", H_FORCE, 0, 744147Seric "via", H_FORCE, 0, 754147Seric NULL, 0, 0, 762897Seric }; 774166Seric 784166Seric 794166Seric /* 804166Seric ** ARPANET error message numbers. 814166Seric */ 824166Seric 834166Seric char Arpa_Info[] = "050"; /* arbitrary info */ 844708Seric char Arpa_Syserr[] = "451"; /* some (transient) system error */ 854708Seric char Arpa_Usrerr[] = "554"; /* some (fatal) user error */ 864282Seric 874282Seric 884282Seric 894282Seric 904282Seric 914282Seric /* 924282Seric ** Location of system files/databases/etc. 934282Seric */ 944282Seric 954282Seric char *AliasFile = "/usr/lib/aliases"; /* alias file */ 964282Seric char *ConfFile = "/usr/lib/sendmail.cf"; /* runtime configuration */ 974778Seric char *StatFile = "/usr/lib/sendmail.st"; /* statistics summary */ 984581Seric char *HelpFile = "/usr/lib/sendmail.hf"; /* help file */ 995178Seric # ifdef QUEUE 1004620Seric char *QueueDir = "/usr/spool/mqueue"; /* queue of saved mail */ 1015178Seric # else QUEUE 1025178Seric char *QueueDir = "/tmp"; /* location of temp files */ 1035178Seric # endif QUEUE 1044620Seric char *XcriptFile = "/tmp/mailxXXXXXX"; /* template for transcript */ 1054315Seric 1064315Seric 1074414Seric /* 1084414Seric ** Other configuration. 1094414Seric */ 1104315Seric 1114414Seric int DefUid = 1; /* the uid to execute mailers as */ 1124414Seric int DefGid = 1; /* ditto for gid */ 1134620Seric time_t TimeOut = 3*24*60*60; /* default timeout for queue files */ 1144414Seric 1154414Seric 1164414Seric 1174315Seric /* 1184315Seric ** V6 system configuration. 1194315Seric */ 1204315Seric 1214315Seric # ifdef V6 1224315Seric char *StdTimezone = "PST"; /* std time timezone */ 1234315Seric char *DstTimezone = "PDT"; /* daylight time timezone */ 1244315Seric # endif V6 125294Seric 126294Seric # ifdef V6 127294Seric /* 1284190Seric ** TTYNAME -- return name of terminal. 129294Seric ** 130294Seric ** Parameters: 1314190Seric ** fd -- file descriptor to check. 132294Seric ** 133294Seric ** Returns: 1344190Seric ** pointer to full path of tty. 1354190Seric ** NULL if no tty. 136294Seric ** 137294Seric ** Side Effects: 138294Seric ** none. 139294Seric */ 140294Seric 141294Seric char * 1424190Seric ttyname(fd) 1434190Seric int fd; 144294Seric { 1454190Seric register char tn; 146294Seric static char pathn[] = "/dev/ttyx"; 147294Seric 148294Seric /* compute the pathname of the controlling tty */ 1494190Seric if ((tn = ttyn(fd)) == NULL) 150294Seric { 151294Seric errno = 0; 152294Seric return (NULL); 153294Seric } 1544190Seric pathn[8] = tn; 155294Seric return (pathn); 156294Seric } 157294Seric /* 158294Seric ** FDOPEN -- Open a stdio file given an open file descriptor. 159294Seric ** 160294Seric ** This is included here because it is standard in v7, but we 161294Seric ** need it in v6. 162294Seric ** 163294Seric ** Algorithm: 164294Seric ** Open /dev/null to create a descriptor. 165294Seric ** Close that descriptor. 166294Seric ** Copy the existing fd into the descriptor. 167294Seric ** 168294Seric ** Parameters: 169294Seric ** fd -- the open file descriptor. 170294Seric ** type -- "r", "w", or whatever. 171294Seric ** 172294Seric ** Returns: 173294Seric ** The file descriptor it creates. 174294Seric ** 175294Seric ** Side Effects: 176294Seric ** none 177294Seric ** 178294Seric ** Called By: 179294Seric ** deliver 180294Seric ** 181294Seric ** Notes: 182294Seric ** The mode of fd must match "type". 183294Seric */ 184294Seric 185294Seric FILE * 186294Seric fdopen(fd, type) 187294Seric int fd; 188294Seric char *type; 189294Seric { 190294Seric register FILE *f; 191294Seric 192294Seric f = fopen("/dev/null", type); 1934081Seric (void) close(fileno(f)); 194294Seric fileno(f) = fd; 195294Seric return (f); 196294Seric } 197294Seric /* 198294Seric ** INDEX -- Return pointer to character in string 199294Seric ** 200294Seric ** For V7 compatibility. 201294Seric ** 202294Seric ** Parameters: 203294Seric ** s -- a string to scan. 204294Seric ** c -- a character to look for. 205294Seric ** 206294Seric ** Returns: 207294Seric ** If c is in s, returns the address of the first 208294Seric ** instance of c in s. 209294Seric ** NULL if c is not in s. 210294Seric ** 211294Seric ** Side Effects: 212294Seric ** none. 213294Seric */ 214294Seric 2154437Seric char * 216294Seric index(s, c) 217294Seric register char *s; 218294Seric register char c; 219294Seric { 220294Seric while (*s != '\0') 221294Seric { 222294Seric if (*s++ == c) 223294Seric return (--s); 224294Seric } 225294Seric return (NULL); 226294Seric } 2274326Seric /* 2284326Seric ** UMASK -- fake the umask system call. 2294326Seric ** 2304326Seric ** Since V6 always acts like the umask is zero, we will just 2314326Seric ** assume the same thing. 2324326Seric */ 2334326Seric 2344326Seric /*ARGSUSED*/ 2354326Seric umask(nmask) 2364326Seric { 2374326Seric return (0); 2384326Seric } 2394326Seric 2404326Seric 2414326Seric /* 2424326Seric ** GETRUID -- get real user id. 2434326Seric */ 2444326Seric 2454326Seric getruid() 2464326Seric { 2474326Seric return (getuid() & 0377); 2484326Seric } 2494326Seric 2504326Seric 2514326Seric /* 2524326Seric ** GETRGID -- get real group id. 2534326Seric */ 2544326Seric 2554326Seric getrgid() 2564326Seric { 2574326Seric return (getgid() & 0377); 2584326Seric } 2594326Seric 2604326Seric 2614326Seric /* 2624326Seric ** GETEUID -- get effective user id. 2634326Seric */ 2644326Seric 2654326Seric geteuid() 2664326Seric { 2674326Seric return ((getuid() >> 8) & 0377); 2684326Seric } 2694326Seric 2704326Seric 2714326Seric /* 2724326Seric ** GETEGID -- get effective group id. 2734326Seric */ 2744326Seric 2754326Seric getegid() 2764326Seric { 2774326Seric return ((getgid() >> 8) & 0377); 2784326Seric } 2794326Seric 280294Seric # endif V6 2814326Seric 2824326Seric # ifndef V6 2834326Seric 2844326Seric /* 2854326Seric ** GETRUID -- get real user id (V7) 2864326Seric */ 2874326Seric 2884326Seric getruid() 2894326Seric { 2904536Seric if (Daemon) 2914536Seric return (RealUid); 2924536Seric else 2934536Seric return (getuid()); 2944326Seric } 2954326Seric 2964326Seric 2974326Seric /* 2984326Seric ** GETRGID -- get real group id (V7). 2994326Seric */ 3004326Seric 3014326Seric getrgid() 3024326Seric { 3034536Seric if (Daemon) 3044536Seric return (RealGid); 3054536Seric else 3064536Seric return (getgid()); 3074326Seric } 3084326Seric 3094326Seric # endif V6 3104190Seric /* 3114190Seric ** TTYPATH -- Get the path of the user's tty 312294Seric ** 313294Seric ** Returns the pathname of the user's tty. Returns NULL if 314294Seric ** the user is not logged in or if s/he has write permission 315294Seric ** denied. 316294Seric ** 317294Seric ** Parameters: 318294Seric ** none 319294Seric ** 320294Seric ** Returns: 321294Seric ** pathname of the user's tty. 322294Seric ** NULL if not logged in or write permission denied. 323294Seric ** 324294Seric ** Side Effects: 325294Seric ** none. 326294Seric ** 327294Seric ** WARNING: 328294Seric ** Return value is in a local buffer. 329294Seric ** 330294Seric ** Called By: 331294Seric ** savemail 332294Seric */ 333294Seric 334294Seric # include <sys/stat.h> 335294Seric 336294Seric char * 337294Seric ttypath() 338294Seric { 339294Seric struct stat stbuf; 340294Seric register char *pathn; 341294Seric extern char *ttyname(); 3424081Seric extern char *getlogin(); 343294Seric 344294Seric /* compute the pathname of the controlling tty */ 345294Seric if ((pathn = ttyname(2)) == NULL && (pathn = ttyname(1)) == NULL && (pathn = ttyname(0)) == NULL) 346294Seric { 347294Seric errno = 0; 348294Seric return (NULL); 349294Seric } 350294Seric 351294Seric /* see if we have write permission */ 3522967Seric if (stat(pathn, &stbuf) < 0 || !bitset(02, stbuf.st_mode)) 353294Seric { 354294Seric errno = 0; 355294Seric return (NULL); 356294Seric } 357294Seric 358294Seric /* see if the user is logged in */ 359294Seric if (getlogin() == NULL) 360294Seric return (NULL); 361294Seric 362294Seric /* looks good */ 363294Seric return (pathn); 364294Seric } 3652967Seric /* 3662967Seric ** CHECKCOMPAT -- check for From and To person compatible. 3672967Seric ** 3682967Seric ** This routine can be supplied on a per-installation basis 3692967Seric ** to determine whether a person is allowed to send a message. 3702967Seric ** This allows restriction of certain types of internet 3712967Seric ** forwarding or registration of users. 3722967Seric ** 3732967Seric ** If the hosts are found to be incompatible, an error 3742967Seric ** message should be given using "usrerr" and FALSE should 3752967Seric ** be returned. 3762967Seric ** 3774288Seric ** 'NoReturn' can be set to suppress the return-to-sender 3784288Seric ** function; this should be done on huge messages. 3794288Seric ** 3802967Seric ** Parameters: 3812967Seric ** to -- the person being sent to. 3822967Seric ** 3832967Seric ** Returns: 3842967Seric ** TRUE -- ok to send. 3852967Seric ** FALSE -- not ok. 3862967Seric ** 3872967Seric ** Side Effects: 3882967Seric ** none (unless you include the usrerr stuff) 3892967Seric */ 3902967Seric 3912967Seric bool 3922967Seric checkcompat(to) 3932967Seric register ADDRESS *to; 3942967Seric { 3954620Seric # ifdef ING70 3964437Seric register STAB *s; 3974620Seric # endif ING70 3984437Seric 3994595Seric if (to->q_mailer != LocalMailer && MsgSize > 100000) 4004288Seric { 4014288Seric usrerr("Message exceeds 100000 bytes"); 4024288Seric NoReturn++; 4034288Seric return (FALSE); 4044288Seric } 4054437Seric # ifdef ING70 4064437Seric s = stab("arpa", ST_MAILER, ST_FIND); 4074595Seric if (s != NULL && From.q_mailer != LocalMailer && to->q_mailer == s->s_mailer) 4084437Seric { 4094437Seric usrerr("No ARPA mail through this machine: see your system administration"); 4104437Seric return (FALSE); 4114437Seric } 4124437Seric # endif ING70 4132967Seric return (TRUE); 4142967Seric } 415