1 # include <stdio.h> 2 # include <pwd.h> 3 # include "postbox.h" 4 5 /* 6 ** CONF.C -- Postbox Configuration Tables. 7 ** 8 ** Defines the configuration of this installation. 9 ** 10 ** Compilation Flags: 11 ** HASARPA -- set if this machine has a connection to 12 ** the Arpanet. 13 ** HASUUCP -- set if this machine has a connection to 14 ** the UUCP network. 15 ** NETV6MAIL -- set if you want to use "v6mail" that 16 ** comes with the Berkeley network. Normally 17 ** /bin/mail will work fine, but around Berkeley 18 ** we use v6mail because it is a "fixed target". 19 ** Also, only v6mail has the "/dev/mail" stuff 20 ** in it (for biff(1)). 21 ** V6 -- running on a version 6 system. This determines 22 ** whether to define certain routines between 23 ** the two systems. If you are running a funny 24 ** system, e.g., V6 with long tty names, this 25 ** should be checked carefully. 26 ** DUMBMAIL -- set if your /bin/mail doesn't have the 27 ** -d flag. 28 ** 29 ** Configuration Variables: 30 ** Mailer -- a table of mailers known to the system. 31 ** The fields are: 32 ** - the pathname of the mailer. 33 ** - a list of flags describing the properties 34 ** of this mailer: 35 ** M_FOPT -- if set, the mailer has a picky "-f" 36 ** option. In this mode, the mailer will 37 ** only accept the "-f" option if the 38 ** sender is actually "root", "network", 39 ** and possibly (but not necessarily) if 40 ** the -f argument matches the real sender. 41 ** The effect is that if the "-f" option 42 ** is given to postbox then it will be 43 ** passed through (as arguments 1 & 2) to 44 ** the mailer. 45 ** M_ROPT -- identical to M_FOPT, except uses 46 ** -r instead. 47 ** M_QUIET -- if set, don't print a message if 48 ** the mailer returns bad status. 49 ** M_RESTR -- if set, this mailer is restricted 50 ** to use by "daemon"; otherwise, we do a 51 ** setuid(getuid()) before calling the 52 ** mailer. 53 ** M_NHDR -- if set, the mailer doesn't want us 54 ** to insert a UNIX "From" line before 55 ** outputing. 56 ** M_NOHOST -- if set, this mailer doesn't care 57 ** about the host part (e.g., the local 58 ** mailer). 59 ** M_STRIPQ -- if set, strip quote (`"') 60 ** characters out of parameters as you 61 ** transliterate them into the argument 62 ** vector. For example, the local mailer 63 ** is called directly, so these should be 64 ** stripped, but the program-mailer (i.e., 65 ** csh) should leave them in. 66 ** M_NEEDDATE -- this mailer requires a Date: 67 ** field in the message. 68 ** M_NEEDFROM -- this mailer requires a From: 69 ** field in the message. 70 ** M_MSGID -- this mailer requires a Message-Id 71 ** field in the message. 72 ** M_ARPAFMT == M_NEEDDATE|M_NEEDFROM|M_MSGID. 73 ** - an exit status to use as the code for the 74 ** error message print if the mailer returns 75 ** something we don't understand. 76 ** - A list of names that are to be considered 77 ** "local" (and hence are stripped off) for 78 ** this mailer. 79 ** - An argument vector to be passed to the 80 ** mailer with the following substitutions: 81 ** $f - the from person name. 82 ** $u - the target user name. 83 ** $h - the target user host. 84 ** $c - the hop count. 85 ** >>>>>>>>>> Entry zero must be for the local 86 ** >> NOTE >> mailer and entry one must be for 87 ** >>>>>>>>>> the shell. 88 ** HdrInfo -- a table describing well-known header fields. 89 ** Each entry has the field name and some flags, 90 ** which can be: 91 ** - H_EOH -- this field is equivalent to a blank 92 ** line; i.e., it signifies end of header. 93 ** - H_DELETE -- delete this field. 94 ** There is also a field pointing to a pointer 95 ** that should be set to point to this header. 96 */ 97 98 99 100 101 static char SccsId[] = "@(#)conf.c 3.9 03/12/81"; 102 103 104 # include <whoami.h> /* definitions of machine id's at berkeley */ 105 106 # ifdef BERKELEY 107 108 # define NETV6MAIL /* use /usr/net/bin/v6mail for local delivery */ 109 110 /* Specific Configurations for Berkeley Machines */ 111 112 /* Berkeley people: mail changes to ingvax:eric or they will be lost! */ 113 114 # ifdef ING70 115 # include "c.ing70.h" 116 # endif ING70 117 118 # ifdef INGVAX 119 # include "c.ingvax.h" 120 # endif INGVAX 121 122 # ifdef CSVAX 123 # include "c.csvax.h" 124 # endif CSVAX 125 126 # ifdef ARPAVAX 127 # include "c.arpavax.h" 128 # endif ARPAVAX 129 130 # ifdef CORY 131 # include "c.cory.h" 132 # endif CORY 133 134 # ifdef ONYX 135 # include "c.onyx.h" 136 # endif ONYX 137 138 # ifdef IMAGE 139 # include "c.image.h" 140 # endif IMAGE 141 142 # ifdef ESVAX 143 # include "c.esvax.h" 144 # endif ESVAX 145 146 # ifdef EECS40 147 # include "c.eecs40.h" 148 # endif EECS40 149 150 # else BERKELEY 151 152 # define HASUUCP /* default to having UUCP net */ 153 154 # endif BERKELEY 155 156 157 158 /* local mail -- must be #0 */ 159 static char *LocalArgv[] = 160 { 161 "...local%mail", 162 "-d", 163 "$u", 164 NULL 165 }; 166 167 static struct mailer LocalMailer = 168 { 169 # ifdef NETV6MAIL 170 "local", "/usr/net/bin/v6mail", 171 # else 172 "local", "/bin/mail", 173 # endif 174 M_ROPT|M_NOHOST|M_STRIPQ|M_ARPAFMT|M_MUSER|M_NHDR, 175 EX_NOUSER, "$f", LocalArgv, NULL, 176 }; 177 178 /* pipes through programs -- must be #1 -- also used for files */ 179 static char *ProgArgv[] = 180 { 181 "...prog%mail", 182 "-fc", 183 "$u", 184 NULL 185 }; 186 187 static struct mailer ProgMailer = 188 { 189 "prog", "/bin/csh", 190 M_NOHOST|M_ARPAFMT, 191 EX_UNAVAILABLE, "$f", ProgArgv, NULL, 192 }; 193 194 /* local berkeley mail */ 195 static char *BerkArgv[] = 196 { 197 "...berk%mail", 198 "-m", 199 "$h", 200 "-h", 201 "$c", 202 "-t", 203 "$u", 204 NULL 205 }; 206 207 static struct mailer BerkMailer = 208 { 209 "berk", "/usr/net/bin/sendberkmail", 210 M_FOPT|M_ARPAFMT|M_STRIPQ, 211 EX_UNAVAILABLE, "$B:$f", BerkArgv, NULL, 212 }; 213 214 /* arpanet mail */ 215 static char *ArpaArgv[] = 216 { 217 "...arpa%mail", 218 "$f", 219 "$h", 220 "$u", 221 NULL 222 }; 223 224 static struct mailer ArpaMailer = 225 { 226 "arpa", "/usr/lib/mailers/arpa", 227 M_STRIPQ|M_ARPAFMT|M_USR_UPPER, 228 0, "$f@$A", ArpaArgv, NULL, 229 }; 230 231 /* uucp mail (cheat & use Bell's v7 mail) */ 232 static char *UucpArgv[] = 233 { 234 "...uucp%mail", 235 "-", 236 "$h!rmail", 237 "($u)", 238 NULL 239 }; 240 241 static struct mailer UucpMailer = 242 { 243 "uucp", "/usr/bin/uux", 244 M_ROPT|M_STRIPQ|M_ARPAFMT|M_MUSER, 245 EX_NOUSER, "$U!$f", UucpArgv, NULL, 246 }; 247 248 struct mailer *Mailer[] = 249 { 250 &LocalMailer, /* 0 -- must be 0 */ 251 &ProgMailer, /* 1 -- must be 1 */ 252 &BerkMailer, /* 2 */ 253 &ArpaMailer, /* 3 */ 254 &UucpMailer, /* 4 */ 255 NULL 256 }; 257 258 # define M_LOCAL 0 259 # define M_PROG 1 260 # define M_BERK 2 261 # define M_ARPA 3 262 # define M_UUCP 4 263 264 265 266 267 268 /* 269 ** Header info table 270 ** Final (null) entry contains the flags used for any other field. 271 */ 272 273 struct hdrinfo HdrInfo[] = 274 { 275 "date", 0, NULL, 276 "from", 0, NULL, 277 "to", 0, NULL, 278 "cc", 0, NULL, 279 "subject", 0, NULL, 280 "message-id", 0, &MsgId, 281 "message", H_EOH, NULL, 282 NULL, 0, NULL, 283 }; 284 285 # ifdef V6 286 /* 287 ** TTYPATH -- Get the path of the user's tty -- Version 6 version. 288 ** 289 ** Returns the pathname of the user's tty. Returns NULL if 290 ** the user is not logged in or if s/he has write permission 291 ** denied. 292 ** 293 ** Parameters: 294 ** none 295 ** 296 ** Returns: 297 ** pathname of the user's tty. 298 ** NULL if not logged in or write permission denied. 299 ** 300 ** Side Effects: 301 ** none. 302 ** 303 ** WARNING: 304 ** Return value is in a local buffer. 305 ** 306 ** Called By: 307 ** savemail 308 */ 309 310 # include <sys/types.h> 311 # include <sys/stat.h> 312 313 char * 314 ttypath() 315 { 316 struct stat stbuf; 317 register int i; 318 static char pathn[] = "/dev/ttyx"; 319 extern int errno; 320 321 /* compute the pathname of the controlling tty */ 322 if ((i = ttyn(2)) == 'x' && (i = ttyn(1)) == 'x' && (i = ttyn(0)) == 'x') 323 { 324 errno = 0; 325 return (NULL); 326 } 327 pathn[8] = i; 328 329 /* see if we have write permission */ 330 if (stat(pathn, &stbuf) < 0 || !bitset(02, stbuf.st_mode)) 331 { 332 errno = 0; 333 return (NULL); 334 } 335 336 /* see if the user is logged in */ 337 if (getlogin() == NULL) 338 return (NULL); 339 340 /* looks good */ 341 return (pathn); 342 } 343 /* 344 ** FDOPEN -- Open a stdio file given an open file descriptor. 345 ** 346 ** This is included here because it is standard in v7, but we 347 ** need it in v6. 348 ** 349 ** Algorithm: 350 ** Open /dev/null to create a descriptor. 351 ** Close that descriptor. 352 ** Copy the existing fd into the descriptor. 353 ** 354 ** Parameters: 355 ** fd -- the open file descriptor. 356 ** type -- "r", "w", or whatever. 357 ** 358 ** Returns: 359 ** The file descriptor it creates. 360 ** 361 ** Side Effects: 362 ** none 363 ** 364 ** Called By: 365 ** deliver 366 ** 367 ** Notes: 368 ** The mode of fd must match "type". 369 */ 370 371 FILE * 372 fdopen(fd, type) 373 int fd; 374 char *type; 375 { 376 register FILE *f; 377 378 f = fopen("/dev/null", type); 379 close(fileno(f)); 380 fileno(f) = fd; 381 return (f); 382 } 383 /* 384 ** INDEX -- Return pointer to character in string 385 ** 386 ** For V7 compatibility. 387 ** 388 ** Parameters: 389 ** s -- a string to scan. 390 ** c -- a character to look for. 391 ** 392 ** Returns: 393 ** If c is in s, returns the address of the first 394 ** instance of c in s. 395 ** NULL if c is not in s. 396 ** 397 ** Side Effects: 398 ** none. 399 */ 400 401 index(s, c) 402 register char *s; 403 register char c; 404 { 405 while (*s != '\0') 406 { 407 if (*s++ == c) 408 return (--s); 409 } 410 return (NULL); 411 } 412 # endif V6 413 414 # ifndef V6 415 /* 416 ** TTYPATH -- Get the path of the user's tty -- Version 7 version. 417 ** 418 ** Returns the pathname of the user's tty. Returns NULL if 419 ** the user is not logged in or if s/he has write permission 420 ** denied. 421 ** 422 ** Parameters: 423 ** none 424 ** 425 ** Returns: 426 ** pathname of the user's tty. 427 ** NULL if not logged in or write permission denied. 428 ** 429 ** Side Effects: 430 ** none. 431 ** 432 ** WARNING: 433 ** Return value is in a local buffer. 434 ** 435 ** Called By: 436 ** savemail 437 */ 438 439 # include <sys/types.h> 440 # include <sys/stat.h> 441 442 char * 443 ttypath() 444 { 445 struct stat stbuf; 446 register char *pathn; 447 extern int errno; 448 extern char *ttyname(); 449 450 /* compute the pathname of the controlling tty */ 451 if ((pathn = ttyname(2)) == NULL && (pathn = ttyname(1)) == NULL && (pathn = ttyname(0)) == NULL) 452 { 453 errno = 0; 454 return (NULL); 455 } 456 457 /* see if we have write permission */ 458 if (stat(pathn, &stbuf) < 0 || !bitset(02, stbuf.st_mode)) 459 { 460 errno = 0; 461 return (NULL); 462 } 463 464 /* see if the user is logged in */ 465 if (getlogin() == NULL) 466 return (NULL); 467 468 /* looks good */ 469 return (pathn); 470 } 471 # endif V6 472 /* 473 ** CHECKCOMPAT -- check for From and To person compatible. 474 ** 475 ** This routine can be supplied on a per-installation basis 476 ** to determine whether a person is allowed to send a message. 477 ** This allows restriction of certain types of internet 478 ** forwarding or registration of users. 479 ** 480 ** If the hosts are found to be incompatible, an error 481 ** message should be given using "usrerr" and FALSE should 482 ** be returned. 483 ** 484 ** Parameters: 485 ** to -- the person being sent to. 486 ** 487 ** Returns: 488 ** TRUE -- ok to send. 489 ** FALSE -- not ok. 490 ** 491 ** Side Effects: 492 ** none (unless you include the usrerr stuff) 493 */ 494 495 bool 496 checkcompat(to) 497 register ADDRESS *to; 498 { 499 return (TRUE); 500 } 501