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 ** 21 ** Notes: 22 ** I have tried to put almost all the reasonable 23 ** configuration information into the configuration 24 ** file read at runtime. My intent is that anything 25 ** here is a function of the version of UNIX you 26 ** are running, or is really static -- for example 27 ** the headers are a superset of widely used 28 ** protocols. If you find yourself playing with 29 ** this file too much, you may be making a mistake! 30 */ 31 32 33 34 35 SCCSID(@(#)conf.c 3.71 04/30/83); 36 37 38 39 /* 40 ** Header info table 41 ** Final (null) entry contains the flags used for any other field. 42 ** 43 ** Not all of these are actually handled specially by sendmail 44 ** at this time. They are included as placeholders, to let 45 ** you know that "someday" I intend to have sendmail do 46 ** something with them. 47 */ 48 49 struct hdrinfo HdrInfo[] = 50 { 51 /* originator fields, most to least significant */ 52 "resent-sender", H_FROM|H_RESENT, 53 "resent-from", H_FROM|H_RESENT, 54 "sender", H_FROM, 55 "from", H_FROM, 56 "full-name", H_ACHECK, 57 "return-receipt-to", H_FROM, 58 "errors-to", H_FROM, 59 /* destination fields */ 60 "to", H_RCPT, 61 "resent-to", H_RCPT|H_RESENT, 62 "cc", H_RCPT, 63 "resent-cc", H_RCPT|H_RESENT, 64 "bcc", H_RCPT|H_ACHECK, 65 "resent-bcc", H_RCPT|H_ACHECK|H_RESENT, 66 /* message identification and control */ 67 "message-id", 0, 68 "resent-message-id", H_RESENT, 69 "message", H_EOH, 70 "text", H_EOH, 71 /* date fields */ 72 "date", 0, 73 "resent-date", H_RESENT, 74 /* trace fields */ 75 "received", H_TRACE|H_FORCE, 76 "via", H_TRACE|H_FORCE, 77 "mail-from", H_TRACE|H_FORCE, 78 79 NULL, 0, 80 }; 81 82 83 /* 84 ** ARPANET error message numbers. 85 */ 86 87 char Arpa_Info[] = "050"; /* arbitrary info */ 88 char Arpa_TSyserr[] = "451"; /* some (transient) system error */ 89 char Arpa_PSyserr[] = "554"; /* some (permanent) system error */ 90 char Arpa_Usrerr[] = "554"; /* some (fatal) user error */ 91 92 93 94 /* 95 ** Location of system files/databases/etc. 96 */ 97 98 char *ConfFile = "/usr/lib/sendmail.cf"; /* runtime configuration */ 99 char *FreezeFile = "/usr/lib/sendmail.fc"; /* frozen version of above */ 100 101 102 103 /* 104 ** Some other configuration.... 105 */ 106 107 char SpaceSub = '.'; 108 109 # ifdef V6 110 /* 111 ** TTYNAME -- return name of terminal. 112 ** 113 ** Parameters: 114 ** fd -- file descriptor to check. 115 ** 116 ** Returns: 117 ** pointer to full path of tty. 118 ** NULL if no tty. 119 ** 120 ** Side Effects: 121 ** none. 122 */ 123 124 char * 125 ttyname(fd) 126 int fd; 127 { 128 register char tn; 129 static char pathn[] = "/dev/ttyx"; 130 131 /* compute the pathname of the controlling tty */ 132 if ((tn = ttyn(fd)) == NULL) 133 { 134 errno = 0; 135 return (NULL); 136 } 137 pathn[8] = tn; 138 return (pathn); 139 } 140 /* 141 ** FDOPEN -- Open a stdio file given an open file descriptor. 142 ** 143 ** This is included here because it is standard in v7, but we 144 ** need it in v6. 145 ** 146 ** Algorithm: 147 ** Open /dev/null to create a descriptor. 148 ** Close that descriptor. 149 ** Copy the existing fd into the descriptor. 150 ** 151 ** Parameters: 152 ** fd -- the open file descriptor. 153 ** type -- "r", "w", or whatever. 154 ** 155 ** Returns: 156 ** The file descriptor it creates. 157 ** 158 ** Side Effects: 159 ** none 160 ** 161 ** Called By: 162 ** deliver 163 ** 164 ** Notes: 165 ** The mode of fd must match "type". 166 */ 167 168 FILE * 169 fdopen(fd, type) 170 int fd; 171 char *type; 172 { 173 register FILE *f; 174 175 f = fopen("/dev/null", type); 176 (void) close(fileno(f)); 177 fileno(f) = fd; 178 return (f); 179 } 180 /* 181 ** INDEX -- Return pointer to character in string 182 ** 183 ** For V7 compatibility. 184 ** 185 ** Parameters: 186 ** s -- a string to scan. 187 ** c -- a character to look for. 188 ** 189 ** Returns: 190 ** If c is in s, returns the address of the first 191 ** instance of c in s. 192 ** NULL if c is not in s. 193 ** 194 ** Side Effects: 195 ** none. 196 */ 197 198 char * 199 index(s, c) 200 register char *s; 201 register char c; 202 { 203 while (*s != '\0') 204 { 205 if (*s++ == c) 206 return (--s); 207 } 208 return (NULL); 209 } 210 /* 211 ** UMASK -- fake the umask system call. 212 ** 213 ** Since V6 always acts like the umask is zero, we will just 214 ** assume the same thing. 215 */ 216 217 /*ARGSUSED*/ 218 umask(nmask) 219 { 220 return (0); 221 } 222 223 224 /* 225 ** GETRUID -- get real user id. 226 */ 227 228 getruid() 229 { 230 return (getuid() & 0377); 231 } 232 233 234 /* 235 ** GETRGID -- get real group id. 236 */ 237 238 getrgid() 239 { 240 return (getgid() & 0377); 241 } 242 243 244 /* 245 ** GETEUID -- get effective user id. 246 */ 247 248 geteuid() 249 { 250 return ((getuid() >> 8) & 0377); 251 } 252 253 254 /* 255 ** GETEGID -- get effective group id. 256 */ 257 258 getegid() 259 { 260 return ((getgid() >> 8) & 0377); 261 } 262 263 # endif V6 264 265 # ifndef V6 266 267 /* 268 ** GETRUID -- get real user id (V7) 269 */ 270 271 getruid() 272 { 273 if (OpMode == MD_DAEMON) 274 return (RealUid); 275 else 276 return (getuid()); 277 } 278 279 280 /* 281 ** GETRGID -- get real group id (V7). 282 */ 283 284 getrgid() 285 { 286 if (OpMode == MD_DAEMON) 287 return (RealGid); 288 else 289 return (getgid()); 290 } 291 292 # endif V6 293 /* 294 ** USERNAME -- return the user id of the logged in user. 295 ** 296 ** Parameters: 297 ** none. 298 ** 299 ** Returns: 300 ** The login name of the logged in user. 301 ** 302 ** Side Effects: 303 ** none. 304 ** 305 ** Notes: 306 ** The return value is statically allocated. 307 */ 308 309 char * 310 username() 311 { 312 extern char *getlogin(); 313 314 return (getlogin()); 315 } 316 /* 317 ** TTYPATH -- Get the path of the user's tty 318 ** 319 ** Returns the pathname of the user's tty. Returns NULL if 320 ** the user is not logged in or if s/he has write permission 321 ** denied. 322 ** 323 ** Parameters: 324 ** none 325 ** 326 ** Returns: 327 ** pathname of the user's tty. 328 ** NULL if not logged in or write permission denied. 329 ** 330 ** Side Effects: 331 ** none. 332 ** 333 ** WARNING: 334 ** Return value is in a local buffer. 335 ** 336 ** Called By: 337 ** savemail 338 */ 339 340 # include <sys/stat.h> 341 342 char * 343 ttypath() 344 { 345 struct stat stbuf; 346 register char *pathn; 347 extern char *ttyname(); 348 extern char *getlogin(); 349 350 /* compute the pathname of the controlling tty */ 351 if ((pathn = ttyname(2)) == NULL && (pathn = ttyname(1)) == NULL && 352 (pathn = ttyname(0)) == NULL) 353 { 354 errno = 0; 355 return (NULL); 356 } 357 358 /* see if we have write permission */ 359 if (stat(pathn, &stbuf) < 0 || !bitset(02, stbuf.st_mode)) 360 { 361 errno = 0; 362 return (NULL); 363 } 364 365 /* see if the user is logged in */ 366 if (getlogin() == NULL) 367 return (NULL); 368 369 /* looks good */ 370 return (pathn); 371 } 372 /* 373 ** CHECKCOMPAT -- check for From and To person compatible. 374 ** 375 ** This routine can be supplied on a per-installation basis 376 ** to determine whether a person is allowed to send a message. 377 ** This allows restriction of certain types of internet 378 ** forwarding or registration of users. 379 ** 380 ** If the hosts are found to be incompatible, an error 381 ** message should be given using "usrerr" and FALSE should 382 ** be returned. 383 ** 384 ** 'NoReturn' can be set to suppress the return-to-sender 385 ** function; this should be done on huge messages. 386 ** 387 ** Parameters: 388 ** to -- the person being sent to. 389 ** 390 ** Returns: 391 ** TRUE -- ok to send. 392 ** FALSE -- not ok. 393 ** 394 ** Side Effects: 395 ** none (unless you include the usrerr stuff) 396 */ 397 398 bool 399 checkcompat(to) 400 register ADDRESS *to; 401 { 402 # ifdef lint 403 if (to == NULL) 404 to++; 405 # endif lint 406 # ifdef EXAMPLE_CODE 407 /* this code is intended as an example only */ 408 register STAB *s; 409 410 s = stab("arpa", ST_MAILER, ST_FIND); 411 if (s != NULL && CurEnv->e_from.q_mailer != LocalMailer && 412 to->q_mailer == s->s_mailer) 413 { 414 usrerr("No ARPA mail through this machine: see your system administration"); 415 /* NoReturn = TRUE; to supress return copy */ 416 return (FALSE); 417 } 418 # endif EXAMPLE_CODE 419 return (TRUE); 420 } 421 /* 422 ** HOLDSIGS -- arrange to hold all signals 423 ** 424 ** Parameters: 425 ** none. 426 ** 427 ** Returns: 428 ** none. 429 ** 430 ** Side Effects: 431 ** Arranges that signals are held. 432 */ 433 434 holdsigs() 435 { 436 } 437 /* 438 ** RLSESIGS -- arrange to release all signals 439 ** 440 ** This undoes the effect of holdsigs. 441 ** 442 ** Parameters: 443 ** none. 444 ** 445 ** Returns: 446 ** none. 447 ** 448 ** Side Effects: 449 ** Arranges that signals are released. 450 */ 451 452 rlsesigs() 453 { 454 } 455