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.8 03/11/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 "-t", 201 "$u", 202 "-h", 203 "$c", 204 NULL 205 }; 206 207 static struct mailer BerkMailer = 208 { 209 "berk", "/usr/net/bin/sendberkmail", 210 M_FOPT|M_ARPAFMT|M_STRIPQ|M_MUSER, 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 # ifndef DUMBMAIL 236 "-d", 237 # endif DUMBMAIL 238 "$h!$u", 239 NULL 240 }; 241 242 static struct mailer UucpMailer = 243 { 244 "uucp", "/bin/mail", 245 M_ROPT|M_STRIPQ|M_ARPAFMT|M_MUSER, 246 EX_NOUSER, "$U!$f", UucpArgv, NULL, 247 }; 248 249 struct mailer *Mailer[] = 250 { 251 &LocalMailer, /* 0 -- must be 0 */ 252 &ProgMailer, /* 1 -- must be 1 */ 253 &BerkMailer, /* 2 */ 254 &ArpaMailer, /* 3 */ 255 &UucpMailer, /* 4 */ 256 NULL 257 }; 258 259 # define M_LOCAL 0 260 # define M_PROG 1 261 # define M_BERK 2 262 # define M_ARPA 3 263 # define M_UUCP 4 264 265 266 267 268 269 /* 270 ** Header info table 271 ** Final (null) entry contains the flags used for any other field. 272 */ 273 274 struct hdrinfo HdrInfo[] = 275 { 276 "date", 0, NULL, 277 "from", 0, NULL, 278 "to", 0, NULL, 279 "cc", 0, NULL, 280 "subject", 0, NULL, 281 "message-id", 0, &MsgId, 282 "message", H_EOH, NULL, 283 NULL, 0, NULL, 284 }; 285 286 # ifdef V6 287 /* 288 ** TTYPATH -- Get the path of the user's tty -- Version 6 version. 289 ** 290 ** Returns the pathname of the user's tty. Returns NULL if 291 ** the user is not logged in or if s/he has write permission 292 ** denied. 293 ** 294 ** Parameters: 295 ** none 296 ** 297 ** Returns: 298 ** pathname of the user's tty. 299 ** NULL if not logged in or write permission denied. 300 ** 301 ** Side Effects: 302 ** none. 303 ** 304 ** WARNING: 305 ** Return value is in a local buffer. 306 ** 307 ** Called By: 308 ** savemail 309 */ 310 311 # include <sys/types.h> 312 # include <sys/stat.h> 313 314 char * 315 ttypath() 316 { 317 struct stat stbuf; 318 register int i; 319 static char pathn[] = "/dev/ttyx"; 320 extern int errno; 321 322 /* compute the pathname of the controlling tty */ 323 if ((i = ttyn(2)) == 'x' && (i = ttyn(1)) == 'x' && (i = ttyn(0)) == 'x') 324 { 325 errno = 0; 326 return (NULL); 327 } 328 pathn[8] = i; 329 330 /* see if we have write permission */ 331 if (stat(pathn, &stbuf) < 0 || !bitset(02, stbuf.st_mode)) 332 { 333 errno = 0; 334 return (NULL); 335 } 336 337 /* see if the user is logged in */ 338 if (getlogin() == NULL) 339 return (NULL); 340 341 /* looks good */ 342 return (pathn); 343 } 344 /* 345 ** FDOPEN -- Open a stdio file given an open file descriptor. 346 ** 347 ** This is included here because it is standard in v7, but we 348 ** need it in v6. 349 ** 350 ** Algorithm: 351 ** Open /dev/null to create a descriptor. 352 ** Close that descriptor. 353 ** Copy the existing fd into the descriptor. 354 ** 355 ** Parameters: 356 ** fd -- the open file descriptor. 357 ** type -- "r", "w", or whatever. 358 ** 359 ** Returns: 360 ** The file descriptor it creates. 361 ** 362 ** Side Effects: 363 ** none 364 ** 365 ** Called By: 366 ** deliver 367 ** 368 ** Notes: 369 ** The mode of fd must match "type". 370 */ 371 372 FILE * 373 fdopen(fd, type) 374 int fd; 375 char *type; 376 { 377 register FILE *f; 378 379 f = fopen("/dev/null", type); 380 close(fileno(f)); 381 fileno(f) = fd; 382 return (f); 383 } 384 /* 385 ** INDEX -- Return pointer to character in string 386 ** 387 ** For V7 compatibility. 388 ** 389 ** Parameters: 390 ** s -- a string to scan. 391 ** c -- a character to look for. 392 ** 393 ** Returns: 394 ** If c is in s, returns the address of the first 395 ** instance of c in s. 396 ** NULL if c is not in s. 397 ** 398 ** Side Effects: 399 ** none. 400 */ 401 402 index(s, c) 403 register char *s; 404 register char c; 405 { 406 while (*s != '\0') 407 { 408 if (*s++ == c) 409 return (--s); 410 } 411 return (NULL); 412 } 413 # endif V6 414 415 # ifndef V6 416 /* 417 ** TTYPATH -- Get the path of the user's tty -- Version 7 version. 418 ** 419 ** Returns the pathname of the user's tty. Returns NULL if 420 ** the user is not logged in or if s/he has write permission 421 ** denied. 422 ** 423 ** Parameters: 424 ** none 425 ** 426 ** Returns: 427 ** pathname of the user's tty. 428 ** NULL if not logged in or write permission denied. 429 ** 430 ** Side Effects: 431 ** none. 432 ** 433 ** WARNING: 434 ** Return value is in a local buffer. 435 ** 436 ** Called By: 437 ** savemail 438 */ 439 440 # include <sys/types.h> 441 # include <sys/stat.h> 442 443 char * 444 ttypath() 445 { 446 struct stat stbuf; 447 register char *pathn; 448 extern int errno; 449 extern char *ttyname(); 450 451 /* compute the pathname of the controlling tty */ 452 if ((pathn = ttyname(2)) == NULL && (pathn = ttyname(1)) == NULL && (pathn = ttyname(0)) == NULL) 453 { 454 errno = 0; 455 return (NULL); 456 } 457 458 /* see if we have write permission */ 459 if (stat(pathn, &stbuf) < 0 || !bitset(02, stbuf.st_mode)) 460 { 461 errno = 0; 462 return (NULL); 463 } 464 465 /* see if the user is logged in */ 466 if (getlogin() == NULL) 467 return (NULL); 468 469 /* looks good */ 470 return (pathn); 471 } 472 # endif V6 473 /* 474 ** CHECKCOMPAT -- check for From and To person compatible. 475 ** 476 ** This routine can be supplied on a per-installation basis 477 ** to determine whether a person is allowed to send a message. 478 ** This allows restriction of certain types of internet 479 ** forwarding or registration of users. 480 ** 481 ** If the hosts are found to be incompatible, an error 482 ** message should be given using "usrerr" and FALSE should 483 ** be returned. 484 ** 485 ** Parameters: 486 ** to -- the person being sent to. 487 ** 488 ** Returns: 489 ** TRUE -- ok to send. 490 ** FALSE -- not ok. 491 ** 492 ** Side Effects: 493 ** none (unless you include the usrerr stuff) 494 */ 495 496 bool 497 checkcompat(to) 498 register ADDRESS *to; 499 { 500 return (TRUE); 501 } 502