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