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