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*4536Seric static char SccsId[] = "@(#)conf.c 3.34 10/17/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 # 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 1124414Seric /* 1134414Seric ** Other configuration. 1144414Seric */ 1154315Seric 1164414Seric int DefUid = 1; /* the uid to execute mailers as */ 1174414Seric int DefGid = 1; /* ditto for gid */ 1184414Seric 1194414Seric 1204414Seric 1214315Seric /* 1224315Seric ** V6 system configuration. 1234315Seric */ 1244315Seric 1254315Seric # ifdef V6 1264315Seric char *StdTimezone = "PST"; /* std time timezone */ 1274315Seric char *DstTimezone = "PDT"; /* daylight time timezone */ 1284315Seric # endif V6 129294Seric 130294Seric # ifdef V6 131294Seric /* 1324190Seric ** TTYNAME -- return name of terminal. 133294Seric ** 134294Seric ** Parameters: 1354190Seric ** fd -- file descriptor to check. 136294Seric ** 137294Seric ** Returns: 1384190Seric ** pointer to full path of tty. 1394190Seric ** NULL if no tty. 140294Seric ** 141294Seric ** Side Effects: 142294Seric ** none. 143294Seric */ 144294Seric 145294Seric char * 1464190Seric ttyname(fd) 1474190Seric int fd; 148294Seric { 1494190Seric register char tn; 150294Seric static char pathn[] = "/dev/ttyx"; 151294Seric 152294Seric /* compute the pathname of the controlling tty */ 1534190Seric if ((tn = ttyn(fd)) == NULL) 154294Seric { 155294Seric errno = 0; 156294Seric return (NULL); 157294Seric } 1584190Seric pathn[8] = tn; 159294Seric return (pathn); 160294Seric } 161294Seric /* 162294Seric ** FDOPEN -- Open a stdio file given an open file descriptor. 163294Seric ** 164294Seric ** This is included here because it is standard in v7, but we 165294Seric ** need it in v6. 166294Seric ** 167294Seric ** Algorithm: 168294Seric ** Open /dev/null to create a descriptor. 169294Seric ** Close that descriptor. 170294Seric ** Copy the existing fd into the descriptor. 171294Seric ** 172294Seric ** Parameters: 173294Seric ** fd -- the open file descriptor. 174294Seric ** type -- "r", "w", or whatever. 175294Seric ** 176294Seric ** Returns: 177294Seric ** The file descriptor it creates. 178294Seric ** 179294Seric ** Side Effects: 180294Seric ** none 181294Seric ** 182294Seric ** Called By: 183294Seric ** deliver 184294Seric ** 185294Seric ** Notes: 186294Seric ** The mode of fd must match "type". 187294Seric */ 188294Seric 189294Seric FILE * 190294Seric fdopen(fd, type) 191294Seric int fd; 192294Seric char *type; 193294Seric { 194294Seric register FILE *f; 195294Seric 196294Seric f = fopen("/dev/null", type); 1974081Seric (void) close(fileno(f)); 198294Seric fileno(f) = fd; 199294Seric return (f); 200294Seric } 201294Seric /* 202294Seric ** INDEX -- Return pointer to character in string 203294Seric ** 204294Seric ** For V7 compatibility. 205294Seric ** 206294Seric ** Parameters: 207294Seric ** s -- a string to scan. 208294Seric ** c -- a character to look for. 209294Seric ** 210294Seric ** Returns: 211294Seric ** If c is in s, returns the address of the first 212294Seric ** instance of c in s. 213294Seric ** NULL if c is not in s. 214294Seric ** 215294Seric ** Side Effects: 216294Seric ** none. 217294Seric */ 218294Seric 2194437Seric char * 220294Seric index(s, c) 221294Seric register char *s; 222294Seric register char c; 223294Seric { 224294Seric while (*s != '\0') 225294Seric { 226294Seric if (*s++ == c) 227294Seric return (--s); 228294Seric } 229294Seric return (NULL); 230294Seric } 2314326Seric /* 2324326Seric ** UMASK -- fake the umask system call. 2334326Seric ** 2344326Seric ** Since V6 always acts like the umask is zero, we will just 2354326Seric ** assume the same thing. 2364326Seric */ 2374326Seric 2384326Seric /*ARGSUSED*/ 2394326Seric umask(nmask) 2404326Seric { 2414326Seric return (0); 2424326Seric } 2434326Seric 2444326Seric 2454326Seric /* 2464326Seric ** GETRUID -- get real user id. 2474326Seric */ 2484326Seric 2494326Seric getruid() 2504326Seric { 2514326Seric return (getuid() & 0377); 2524326Seric } 2534326Seric 2544326Seric 2554326Seric /* 2564326Seric ** GETRGID -- get real group id. 2574326Seric */ 2584326Seric 2594326Seric getrgid() 2604326Seric { 2614326Seric return (getgid() & 0377); 2624326Seric } 2634326Seric 2644326Seric 2654326Seric /* 2664326Seric ** GETEUID -- get effective user id. 2674326Seric */ 2684326Seric 2694326Seric geteuid() 2704326Seric { 2714326Seric return ((getuid() >> 8) & 0377); 2724326Seric } 2734326Seric 2744326Seric 2754326Seric /* 2764326Seric ** GETEGID -- get effective group id. 2774326Seric */ 2784326Seric 2794326Seric getegid() 2804326Seric { 2814326Seric return ((getgid() >> 8) & 0377); 2824326Seric } 2834326Seric 284294Seric # endif V6 2854326Seric 2864326Seric # ifndef V6 2874326Seric 2884326Seric /* 2894326Seric ** GETRUID -- get real user id (V7) 2904326Seric */ 2914326Seric 2924326Seric getruid() 2934326Seric { 294*4536Seric if (Daemon) 295*4536Seric return (RealUid); 296*4536Seric else 297*4536Seric return (getuid()); 2984326Seric } 2994326Seric 3004326Seric 3014326Seric /* 3024326Seric ** GETRGID -- get real group id (V7). 3034326Seric */ 3044326Seric 3054326Seric getrgid() 3064326Seric { 307*4536Seric if (Daemon) 308*4536Seric return (RealGid); 309*4536Seric else 310*4536Seric return (getgid()); 3114326Seric } 3124326Seric 3134326Seric # endif V6 3144190Seric /* 3154190Seric ** TTYPATH -- Get the path of the user's tty 316294Seric ** 317294Seric ** Returns the pathname of the user's tty. Returns NULL if 318294Seric ** the user is not logged in or if s/he has write permission 319294Seric ** denied. 320294Seric ** 321294Seric ** Parameters: 322294Seric ** none 323294Seric ** 324294Seric ** Returns: 325294Seric ** pathname of the user's tty. 326294Seric ** NULL if not logged in or write permission denied. 327294Seric ** 328294Seric ** Side Effects: 329294Seric ** none. 330294Seric ** 331294Seric ** WARNING: 332294Seric ** Return value is in a local buffer. 333294Seric ** 334294Seric ** Called By: 335294Seric ** savemail 336294Seric */ 337294Seric 338294Seric # include <sys/stat.h> 339294Seric 340294Seric char * 341294Seric ttypath() 342294Seric { 343294Seric struct stat stbuf; 344294Seric register char *pathn; 345294Seric extern char *ttyname(); 3464081Seric extern char *getlogin(); 347294Seric 348294Seric /* compute the pathname of the controlling tty */ 349294Seric if ((pathn = ttyname(2)) == NULL && (pathn = ttyname(1)) == NULL && (pathn = ttyname(0)) == NULL) 350294Seric { 351294Seric errno = 0; 352294Seric return (NULL); 353294Seric } 354294Seric 355294Seric /* see if we have write permission */ 3562967Seric if (stat(pathn, &stbuf) < 0 || !bitset(02, stbuf.st_mode)) 357294Seric { 358294Seric errno = 0; 359294Seric return (NULL); 360294Seric } 361294Seric 362294Seric /* see if the user is logged in */ 363294Seric if (getlogin() == NULL) 364294Seric return (NULL); 365294Seric 366294Seric /* looks good */ 367294Seric return (pathn); 368294Seric } 3692967Seric /* 3702967Seric ** CHECKCOMPAT -- check for From and To person compatible. 3712967Seric ** 3722967Seric ** This routine can be supplied on a per-installation basis 3732967Seric ** to determine whether a person is allowed to send a message. 3742967Seric ** This allows restriction of certain types of internet 3752967Seric ** forwarding or registration of users. 3762967Seric ** 3772967Seric ** If the hosts are found to be incompatible, an error 3782967Seric ** message should be given using "usrerr" and FALSE should 3792967Seric ** be returned. 3802967Seric ** 3814288Seric ** 'NoReturn' can be set to suppress the return-to-sender 3824288Seric ** function; this should be done on huge messages. 3834288Seric ** 3842967Seric ** Parameters: 3852967Seric ** to -- the person being sent to. 3862967Seric ** 3872967Seric ** Returns: 3882967Seric ** TRUE -- ok to send. 3892967Seric ** FALSE -- not ok. 3902967Seric ** 3912967Seric ** Side Effects: 3922967Seric ** none (unless you include the usrerr stuff) 3932967Seric */ 3942967Seric 3952967Seric bool 3962967Seric checkcompat(to) 3972967Seric register ADDRESS *to; 3982967Seric { 3994437Seric register STAB *s; 4004437Seric 4014288Seric if (to->q_mailer != MN_LOCAL && MsgSize > 100000) 4024288Seric { 4034288Seric usrerr("Message exceeds 100000 bytes"); 4044288Seric NoReturn++; 4054288Seric return (FALSE); 4064288Seric } 4074437Seric # ifdef ING70 4084437Seric s = stab("arpa", ST_MAILER, ST_FIND); 4094440Seric if (s != NULL && From.q_mailer != MN_LOCAL && to->q_mailer == s->s_mailer->m_mno) 4104437Seric { 4114437Seric usrerr("No ARPA mail through this machine: see your system administration"); 4124437Seric return (FALSE); 4134437Seric } 4144437Seric # endif ING70 4152967Seric return (TRUE); 4162967Seric } 417