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*6996Seric SCCSID(@(#)conf.c 3.47 05/31/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 { 554147Seric "date", H_CHECK, M_NEEDDATE, 565915Seric "from", H_ADDR|H_CHECK, M_NEEDFROM, 574369Seric "original-from", 0, 0, 585915Seric "sender", H_ADDR, 0, 594147Seric "full-name", H_ACHECK, M_FULLNAME, 605915Seric "to", H_ADDR|H_RCPT, 0, 615915Seric "cc", H_ADDR|H_RCPT, 0, 625915Seric "bcc", H_ADDR|H_ACHECK|H_RCPT, 0, 634147Seric "message-id", H_CHECK, M_MSGID, 644147Seric "message", H_EOH, 0, 654147Seric "text", H_EOH, 0, 664147Seric "posted-date", 0, 0, 674147Seric "return-receipt-to", 0, 0, 684193Seric "received-date", H_CHECK, M_LOCAL, 694193Seric "received-from", H_CHECK, M_LOCAL, 704147Seric "precedence", 0, 0, 715184Seric "mail-from", H_FORCE, 0, 724147Seric "via", H_FORCE, 0, 734147Seric NULL, 0, 0, 742897Seric }; 754166Seric 764166Seric 774166Seric /* 784166Seric ** ARPANET error message numbers. 794166Seric */ 804166Seric 814166Seric char Arpa_Info[] = "050"; /* arbitrary info */ 824708Seric char Arpa_Syserr[] = "451"; /* some (transient) system error */ 834708Seric char Arpa_Usrerr[] = "554"; /* some (fatal) user error */ 844282Seric 854282Seric 864282Seric 874282Seric 884282Seric 894282Seric /* 904282Seric ** Location of system files/databases/etc. 914282Seric */ 924282Seric 934282Seric char *AliasFile = "/usr/lib/aliases"; /* alias file */ 944282Seric char *ConfFile = "/usr/lib/sendmail.cf"; /* runtime configuration */ 954778Seric char *StatFile = "/usr/lib/sendmail.st"; /* statistics summary */ 964581Seric char *HelpFile = "/usr/lib/sendmail.hf"; /* help file */ 975178Seric # ifdef QUEUE 984620Seric char *QueueDir = "/usr/spool/mqueue"; /* queue of saved mail */ 995178Seric # else QUEUE 1005178Seric char *QueueDir = "/tmp"; /* location of temp files */ 1015178Seric # endif QUEUE 1024620Seric char *XcriptFile = "/tmp/mailxXXXXXX"; /* template for transcript */ 1034315Seric 1044315Seric 1054414Seric /* 1064414Seric ** Other configuration. 1074414Seric */ 1084315Seric 1094414Seric int DefUid = 1; /* the uid to execute mailers as */ 1104414Seric int DefGid = 1; /* ditto for gid */ 1116283Seric time_t TimeOut = 3*24*60*60L; /* default timeout for queue files */ 1124414Seric 1134414Seric 1144414Seric 1154315Seric /* 1164315Seric ** V6 system configuration. 1174315Seric */ 1184315Seric 1194315Seric # ifdef V6 1204315Seric char *StdTimezone = "PST"; /* std time timezone */ 1214315Seric char *DstTimezone = "PDT"; /* daylight time timezone */ 1224315Seric # endif V6 123294Seric 124294Seric # ifdef V6 125294Seric /* 1264190Seric ** TTYNAME -- return name of terminal. 127294Seric ** 128294Seric ** Parameters: 1294190Seric ** fd -- file descriptor to check. 130294Seric ** 131294Seric ** Returns: 1324190Seric ** pointer to full path of tty. 1334190Seric ** NULL if no tty. 134294Seric ** 135294Seric ** Side Effects: 136294Seric ** none. 137294Seric */ 138294Seric 139294Seric char * 1404190Seric ttyname(fd) 1414190Seric int fd; 142294Seric { 1434190Seric register char tn; 144294Seric static char pathn[] = "/dev/ttyx"; 145294Seric 146294Seric /* compute the pathname of the controlling tty */ 1474190Seric if ((tn = ttyn(fd)) == NULL) 148294Seric { 149294Seric errno = 0; 150294Seric return (NULL); 151294Seric } 1524190Seric pathn[8] = tn; 153294Seric return (pathn); 154294Seric } 155294Seric /* 156294Seric ** FDOPEN -- Open a stdio file given an open file descriptor. 157294Seric ** 158294Seric ** This is included here because it is standard in v7, but we 159294Seric ** need it in v6. 160294Seric ** 161294Seric ** Algorithm: 162294Seric ** Open /dev/null to create a descriptor. 163294Seric ** Close that descriptor. 164294Seric ** Copy the existing fd into the descriptor. 165294Seric ** 166294Seric ** Parameters: 167294Seric ** fd -- the open file descriptor. 168294Seric ** type -- "r", "w", or whatever. 169294Seric ** 170294Seric ** Returns: 171294Seric ** The file descriptor it creates. 172294Seric ** 173294Seric ** Side Effects: 174294Seric ** none 175294Seric ** 176294Seric ** Called By: 177294Seric ** deliver 178294Seric ** 179294Seric ** Notes: 180294Seric ** The mode of fd must match "type". 181294Seric */ 182294Seric 183294Seric FILE * 184294Seric fdopen(fd, type) 185294Seric int fd; 186294Seric char *type; 187294Seric { 188294Seric register FILE *f; 189294Seric 190294Seric f = fopen("/dev/null", type); 1914081Seric (void) close(fileno(f)); 192294Seric fileno(f) = fd; 193294Seric return (f); 194294Seric } 195294Seric /* 196294Seric ** INDEX -- Return pointer to character in string 197294Seric ** 198294Seric ** For V7 compatibility. 199294Seric ** 200294Seric ** Parameters: 201294Seric ** s -- a string to scan. 202294Seric ** c -- a character to look for. 203294Seric ** 204294Seric ** Returns: 205294Seric ** If c is in s, returns the address of the first 206294Seric ** instance of c in s. 207294Seric ** NULL if c is not in s. 208294Seric ** 209294Seric ** Side Effects: 210294Seric ** none. 211294Seric */ 212294Seric 2134437Seric char * 214294Seric index(s, c) 215294Seric register char *s; 216294Seric register char c; 217294Seric { 218294Seric while (*s != '\0') 219294Seric { 220294Seric if (*s++ == c) 221294Seric return (--s); 222294Seric } 223294Seric return (NULL); 224294Seric } 2254326Seric /* 2264326Seric ** UMASK -- fake the umask system call. 2274326Seric ** 2284326Seric ** Since V6 always acts like the umask is zero, we will just 2294326Seric ** assume the same thing. 2304326Seric */ 2314326Seric 2324326Seric /*ARGSUSED*/ 2334326Seric umask(nmask) 2344326Seric { 2354326Seric return (0); 2364326Seric } 2374326Seric 2384326Seric 2394326Seric /* 2404326Seric ** GETRUID -- get real user id. 2414326Seric */ 2424326Seric 2434326Seric getruid() 2444326Seric { 2454326Seric return (getuid() & 0377); 2464326Seric } 2474326Seric 2484326Seric 2494326Seric /* 2504326Seric ** GETRGID -- get real group id. 2514326Seric */ 2524326Seric 2534326Seric getrgid() 2544326Seric { 2554326Seric return (getgid() & 0377); 2564326Seric } 2574326Seric 2584326Seric 2594326Seric /* 2604326Seric ** GETEUID -- get effective user id. 2614326Seric */ 2624326Seric 2634326Seric geteuid() 2644326Seric { 2654326Seric return ((getuid() >> 8) & 0377); 2664326Seric } 2674326Seric 2684326Seric 2694326Seric /* 2704326Seric ** GETEGID -- get effective group id. 2714326Seric */ 2724326Seric 2734326Seric getegid() 2744326Seric { 2754326Seric return ((getgid() >> 8) & 0377); 2764326Seric } 2774326Seric 278294Seric # endif V6 2794326Seric 2804326Seric # ifndef V6 2814326Seric 2824326Seric /* 2834326Seric ** GETRUID -- get real user id (V7) 2844326Seric */ 2854326Seric 2864326Seric getruid() 2874326Seric { 288*6996Seric if (Mode == MD_DAEMON) 2894536Seric return (RealUid); 2904536Seric else 2914536Seric return (getuid()); 2924326Seric } 2934326Seric 2944326Seric 2954326Seric /* 2964326Seric ** GETRGID -- get real group id (V7). 2974326Seric */ 2984326Seric 2994326Seric getrgid() 3004326Seric { 301*6996Seric if (Mode == MD_DAEMON) 3024536Seric return (RealGid); 3034536Seric else 3044536Seric return (getgid()); 3054326Seric } 3064326Seric 3074326Seric # endif V6 3084190Seric /* 3094190Seric ** TTYPATH -- Get the path of the user's tty 310294Seric ** 311294Seric ** Returns the pathname of the user's tty. Returns NULL if 312294Seric ** the user is not logged in or if s/he has write permission 313294Seric ** denied. 314294Seric ** 315294Seric ** Parameters: 316294Seric ** none 317294Seric ** 318294Seric ** Returns: 319294Seric ** pathname of the user's tty. 320294Seric ** NULL if not logged in or write permission denied. 321294Seric ** 322294Seric ** Side Effects: 323294Seric ** none. 324294Seric ** 325294Seric ** WARNING: 326294Seric ** Return value is in a local buffer. 327294Seric ** 328294Seric ** Called By: 329294Seric ** savemail 330294Seric */ 331294Seric 332294Seric # include <sys/stat.h> 333294Seric 334294Seric char * 335294Seric ttypath() 336294Seric { 337294Seric struct stat stbuf; 338294Seric register char *pathn; 339294Seric extern char *ttyname(); 3404081Seric extern char *getlogin(); 341294Seric 342294Seric /* compute the pathname of the controlling tty */ 343294Seric if ((pathn = ttyname(2)) == NULL && (pathn = ttyname(1)) == NULL && (pathn = ttyname(0)) == NULL) 344294Seric { 345294Seric errno = 0; 346294Seric return (NULL); 347294Seric } 348294Seric 349294Seric /* see if we have write permission */ 3502967Seric if (stat(pathn, &stbuf) < 0 || !bitset(02, stbuf.st_mode)) 351294Seric { 352294Seric errno = 0; 353294Seric return (NULL); 354294Seric } 355294Seric 356294Seric /* see if the user is logged in */ 357294Seric if (getlogin() == NULL) 358294Seric return (NULL); 359294Seric 360294Seric /* looks good */ 361294Seric return (pathn); 362294Seric } 3632967Seric /* 3642967Seric ** CHECKCOMPAT -- check for From and To person compatible. 3652967Seric ** 3662967Seric ** This routine can be supplied on a per-installation basis 3672967Seric ** to determine whether a person is allowed to send a message. 3682967Seric ** This allows restriction of certain types of internet 3692967Seric ** forwarding or registration of users. 3702967Seric ** 3712967Seric ** If the hosts are found to be incompatible, an error 3722967Seric ** message should be given using "usrerr" and FALSE should 3732967Seric ** be returned. 3742967Seric ** 3754288Seric ** 'NoReturn' can be set to suppress the return-to-sender 3764288Seric ** function; this should be done on huge messages. 3774288Seric ** 3782967Seric ** Parameters: 3792967Seric ** to -- the person being sent to. 3802967Seric ** 3812967Seric ** Returns: 3822967Seric ** TRUE -- ok to send. 3832967Seric ** FALSE -- not ok. 3842967Seric ** 3852967Seric ** Side Effects: 3862967Seric ** none (unless you include the usrerr stuff) 3872967Seric */ 3882967Seric 3892967Seric bool 3902967Seric checkcompat(to) 3912967Seric register ADDRESS *to; 3922967Seric { 3934620Seric # ifdef ING70 3944437Seric register STAB *s; 3954620Seric # endif ING70 3964437Seric 3976899Seric if (to->q_mailer != LocalMailer && CurEnv->e_msgsize > 100000) 3984288Seric { 3994288Seric usrerr("Message exceeds 100000 bytes"); 4004288Seric NoReturn++; 4014288Seric return (FALSE); 4024288Seric } 4034437Seric # ifdef ING70 4044437Seric s = stab("arpa", ST_MAILER, ST_FIND); 4056899Seric if (s != NULL && CurEnv->e_from.q_mailer != LocalMailer && to->q_mailer == s->s_mailer) 4064437Seric { 4074437Seric usrerr("No ARPA mail through this machine: see your system administration"); 4084437Seric return (FALSE); 4094437Seric } 4104437Seric # endif ING70 4112967Seric return (TRUE); 4122967Seric } 413