1 # include <pwd.h> 2 # include "sendmail.h" 3 4 /* 5 ** CONF.C -- Sendmail Configuration Tables. 6 ** 7 ** Defines the configuration of this installation. 8 ** 9 ** Compilation Flags: 10 ** V6 -- running on a version 6 system. This determines 11 ** whether to define certain routines between 12 ** the two systems. If you are running a funny 13 ** system, e.g., V6 with long tty names, this 14 ** should be checked carefully. 15 ** 16 ** Configuration Variables: 17 ** HdrInfo -- a table describing well-known header fields. 18 ** Each entry has the field name and some flags, 19 ** which are described in sendmail.h. 20 ** StdTimezone -- name of local timezone in standard time 21 ** (V6 only). 22 ** DstTimezone -- name of local timezone in daylight savings 23 ** time (V6 only). 24 ** 25 ** Notes: 26 ** I have tried to put almost all the reasonable 27 ** configuration information into the configuration 28 ** file read at runtime. My intent is that anything 29 ** here is a function of the version of UNIX you 30 ** are running, or is really static -- for example 31 ** the headers are a superset of widely used 32 ** protocols. If you find yourself playing with 33 ** this file too much, you may be making a mistake! 34 */ 35 36 37 38 39 static char SccsId[] = "@(#)conf.c 3.38 10/31/81"; 40 41 42 # include <whoami.h> /* definitions of machine id's at berkeley */ 43 44 45 /* 46 ** Header info table 47 ** Final (null) entry contains the flags used for any other field. 48 ** 49 ** Not all of these are actually handled specially by sendmail 50 ** at this time. They are included as placeholders, to let 51 ** you know that "someday" I intend to have sendmail do 52 ** something with them. 53 */ 54 55 struct hdrinfo HdrInfo[] = 56 { 57 "date", H_CHECK, M_NEEDDATE, 58 "from", H_CHECK, M_NEEDFROM, 59 "original-from", 0, 0, 60 "sender", 0, 0, 61 "full-name", H_ACHECK, M_FULLNAME, 62 "to", H_ADDR, 0, 63 "cc", H_ADDR, 0, 64 "bcc", H_ADDR|H_ACHECK, 0, 65 "message-id", H_CHECK, M_MSGID, 66 "message", H_EOH, 0, 67 "text", H_EOH, 0, 68 "posted-date", 0, 0, 69 "return-receipt-to", 0, 0, 70 "received-date", H_CHECK, M_LOCAL, 71 "received-from", H_CHECK, M_LOCAL, 72 "precedence", 0, 0, 73 "via", H_FORCE, 0, 74 NULL, 0, 0, 75 }; 76 77 78 /* 79 ** ARPANET error message numbers. 80 */ 81 82 char Arpa_Info[] = "050"; /* arbitrary info */ 83 char Arpa_Syserr[] = "451"; /* some (transient) system error */ 84 char Arpa_Usrerr[] = "554"; /* some (fatal) user error */ 85 86 87 88 89 90 /* 91 ** Location of system files/databases/etc. 92 */ 93 94 char *AliasFile = "/usr/lib/aliases"; /* alias file */ 95 char *ConfFile = "/usr/lib/sendmail.cf"; /* runtime configuration */ 96 char *StatFile = "/usr/lib/mailstats"; /* statistics summary */ 97 char *HelpFile = "/usr/lib/sendmail.hf"; /* help file */ 98 char *QueueDir = "/usr/spool/mqueue"; /* queue of saved mail */ 99 char *XcriptFile = "/tmp/mailxXXXXXX"; /* template for transcript */ 100 101 102 /* 103 ** Other configuration. 104 */ 105 106 int DefUid = 1; /* the uid to execute mailers as */ 107 int DefGid = 1; /* ditto for gid */ 108 time_t TimeOut = 3*24*60*60; /* default timeout for queue files */ 109 110 111 112 /* 113 ** V6 system configuration. 114 */ 115 116 # ifdef V6 117 char *StdTimezone = "PST"; /* std time timezone */ 118 char *DstTimezone = "PDT"; /* daylight time timezone */ 119 # endif V6 120 121 # ifdef V6 122 /* 123 ** TTYNAME -- return name of terminal. 124 ** 125 ** Parameters: 126 ** fd -- file descriptor to check. 127 ** 128 ** Returns: 129 ** pointer to full path of tty. 130 ** NULL if no tty. 131 ** 132 ** Side Effects: 133 ** none. 134 */ 135 136 char * 137 ttyname(fd) 138 int fd; 139 { 140 register char tn; 141 static char pathn[] = "/dev/ttyx"; 142 143 /* compute the pathname of the controlling tty */ 144 if ((tn = ttyn(fd)) == NULL) 145 { 146 errno = 0; 147 return (NULL); 148 } 149 pathn[8] = tn; 150 return (pathn); 151 } 152 /* 153 ** FDOPEN -- Open a stdio file given an open file descriptor. 154 ** 155 ** This is included here because it is standard in v7, but we 156 ** need it in v6. 157 ** 158 ** Algorithm: 159 ** Open /dev/null to create a descriptor. 160 ** Close that descriptor. 161 ** Copy the existing fd into the descriptor. 162 ** 163 ** Parameters: 164 ** fd -- the open file descriptor. 165 ** type -- "r", "w", or whatever. 166 ** 167 ** Returns: 168 ** The file descriptor it creates. 169 ** 170 ** Side Effects: 171 ** none 172 ** 173 ** Called By: 174 ** deliver 175 ** 176 ** Notes: 177 ** The mode of fd must match "type". 178 */ 179 180 FILE * 181 fdopen(fd, type) 182 int fd; 183 char *type; 184 { 185 register FILE *f; 186 187 f = fopen("/dev/null", type); 188 (void) close(fileno(f)); 189 fileno(f) = fd; 190 return (f); 191 } 192 /* 193 ** INDEX -- Return pointer to character in string 194 ** 195 ** For V7 compatibility. 196 ** 197 ** Parameters: 198 ** s -- a string to scan. 199 ** c -- a character to look for. 200 ** 201 ** Returns: 202 ** If c is in s, returns the address of the first 203 ** instance of c in s. 204 ** NULL if c is not in s. 205 ** 206 ** Side Effects: 207 ** none. 208 */ 209 210 char * 211 index(s, c) 212 register char *s; 213 register char c; 214 { 215 while (*s != '\0') 216 { 217 if (*s++ == c) 218 return (--s); 219 } 220 return (NULL); 221 } 222 /* 223 ** UMASK -- fake the umask system call. 224 ** 225 ** Since V6 always acts like the umask is zero, we will just 226 ** assume the same thing. 227 */ 228 229 /*ARGSUSED*/ 230 umask(nmask) 231 { 232 return (0); 233 } 234 235 236 /* 237 ** GETRUID -- get real user id. 238 */ 239 240 getruid() 241 { 242 return (getuid() & 0377); 243 } 244 245 246 /* 247 ** GETRGID -- get real group id. 248 */ 249 250 getrgid() 251 { 252 return (getgid() & 0377); 253 } 254 255 256 /* 257 ** GETEUID -- get effective user id. 258 */ 259 260 geteuid() 261 { 262 return ((getuid() >> 8) & 0377); 263 } 264 265 266 /* 267 ** GETEGID -- get effective group id. 268 */ 269 270 getegid() 271 { 272 return ((getgid() >> 8) & 0377); 273 } 274 275 # endif V6 276 277 # ifndef V6 278 279 /* 280 ** GETRUID -- get real user id (V7) 281 */ 282 283 getruid() 284 { 285 if (Daemon) 286 return (RealUid); 287 else 288 return (getuid()); 289 } 290 291 292 /* 293 ** GETRGID -- get real group id (V7). 294 */ 295 296 getrgid() 297 { 298 if (Daemon) 299 return (RealGid); 300 else 301 return (getgid()); 302 } 303 304 # endif V6 305 /* 306 ** TTYPATH -- Get the path of the user's tty 307 ** 308 ** Returns the pathname of the user's tty. Returns NULL if 309 ** the user is not logged in or if s/he has write permission 310 ** denied. 311 ** 312 ** Parameters: 313 ** none 314 ** 315 ** Returns: 316 ** pathname of the user's tty. 317 ** NULL if not logged in or write permission denied. 318 ** 319 ** Side Effects: 320 ** none. 321 ** 322 ** WARNING: 323 ** Return value is in a local buffer. 324 ** 325 ** Called By: 326 ** savemail 327 */ 328 329 # include <sys/stat.h> 330 331 char * 332 ttypath() 333 { 334 struct stat stbuf; 335 register char *pathn; 336 extern char *ttyname(); 337 extern char *getlogin(); 338 339 /* compute the pathname of the controlling tty */ 340 if ((pathn = ttyname(2)) == NULL && (pathn = ttyname(1)) == NULL && (pathn = ttyname(0)) == NULL) 341 { 342 errno = 0; 343 return (NULL); 344 } 345 346 /* see if we have write permission */ 347 if (stat(pathn, &stbuf) < 0 || !bitset(02, stbuf.st_mode)) 348 { 349 errno = 0; 350 return (NULL); 351 } 352 353 /* see if the user is logged in */ 354 if (getlogin() == NULL) 355 return (NULL); 356 357 /* looks good */ 358 return (pathn); 359 } 360 /* 361 ** CHECKCOMPAT -- check for From and To person compatible. 362 ** 363 ** This routine can be supplied on a per-installation basis 364 ** to determine whether a person is allowed to send a message. 365 ** This allows restriction of certain types of internet 366 ** forwarding or registration of users. 367 ** 368 ** If the hosts are found to be incompatible, an error 369 ** message should be given using "usrerr" and FALSE should 370 ** be returned. 371 ** 372 ** 'NoReturn' can be set to suppress the return-to-sender 373 ** function; this should be done on huge messages. 374 ** 375 ** Parameters: 376 ** to -- the person being sent to. 377 ** 378 ** Returns: 379 ** TRUE -- ok to send. 380 ** FALSE -- not ok. 381 ** 382 ** Side Effects: 383 ** none (unless you include the usrerr stuff) 384 */ 385 386 bool 387 checkcompat(to) 388 register ADDRESS *to; 389 { 390 # ifdef ING70 391 register STAB *s; 392 # endif ING70 393 394 if (to->q_mailer != LocalMailer && MsgSize > 100000) 395 { 396 usrerr("Message exceeds 100000 bytes"); 397 NoReturn++; 398 return (FALSE); 399 } 400 # ifdef ING70 401 s = stab("arpa", ST_MAILER, ST_FIND); 402 if (s != NULL && From.q_mailer != LocalMailer && to->q_mailer == s->s_mailer) 403 { 404 usrerr("No ARPA mail through this machine: see your system administration"); 405 return (FALSE); 406 } 407 # endif ING70 408 return (TRUE); 409 } 410