1 /* 2 * Copyright (c) 1983 Eric P. Allman 3 * Copyright (c) 1988 Regents of the University of California. 4 * All rights reserved. 5 * 6 * %sccs.include.redist.c% 7 */ 8 9 #ifndef lint 10 static char sccsid[] = "@(#)deliver.c 5.60 (Berkeley) 07/12/92"; 11 #endif /* not lint */ 12 13 #include "sendmail.h" 14 #include <sys/signal.h> 15 #include <sys/stat.h> 16 #include <netdb.h> 17 #include <fcntl.h> 18 #include <errno.h> 19 #ifdef NAMED_BIND 20 #include <sys/param.h> 21 #include <arpa/nameser.h> 22 #include <resolv.h> 23 #endif 24 25 /* 26 ** DELIVER -- Deliver a message to a list of addresses. 27 ** 28 ** This routine delivers to everyone on the same host as the 29 ** user on the head of the list. It is clever about mailers 30 ** that don't handle multiple users. It is NOT guaranteed 31 ** that it will deliver to all these addresses however -- so 32 ** deliver should be called once for each address on the 33 ** list. 34 ** 35 ** Parameters: 36 ** e -- the envelope to deliver. 37 ** firstto -- head of the address list to deliver to. 38 ** 39 ** Returns: 40 ** zero -- successfully delivered. 41 ** else -- some failure, see ExitStat for more info. 42 ** 43 ** Side Effects: 44 ** The standard input is passed off to someone. 45 */ 46 47 deliver(e, firstto) 48 register ENVELOPE *e; 49 ADDRESS *firstto; 50 { 51 char *host; /* host being sent to */ 52 char *user; /* user being sent to */ 53 char **pvp; 54 register char **mvp; 55 register char *p; 56 register MAILER *m; /* mailer for this recipient */ 57 ADDRESS *ctladdr; 58 register MCI *mci; 59 register ADDRESS *to = firstto; 60 bool clever = FALSE; /* running user smtp to this mailer */ 61 ADDRESS *tochain = NULL; /* chain of users in this mailer call */ 62 int rcode; /* response code */ 63 char *from; /* pointer to from person */ 64 char *pv[MAXPV+1]; 65 char tobuf[MAXLINE-50]; /* text line of to people */ 66 char buf[MAXNAME]; 67 char tfrombuf[MAXNAME]; /* translated from person */ 68 char rpathbuf[MAXNAME]; /* translated return path */ 69 extern bool checkcompat(); 70 extern ADDRESS *getctladdr(); 71 extern char *remotename(); 72 extern MCI *openmailer(); 73 74 errno = 0; 75 if (bitset(QDONTSEND, to->q_flags)) 76 return (0); 77 78 #ifdef NAMED_BIND 79 /* unless interactive, try twice, over a minute */ 80 if (OpMode == MD_DAEMON || OpMode == MD_SMTP) { 81 _res.retrans = 30; 82 _res.retry = 2; 83 } 84 #endif 85 86 m = to->q_mailer; 87 host = to->q_host; 88 89 if (tTd(10, 1)) 90 printf("\n--deliver, mailer=%d, host=`%s', first user=`%s'\n", 91 m->m_mno, host, to->q_user); 92 93 /* 94 ** If this mailer is expensive, and if we don't want to make 95 ** connections now, just mark these addresses and return. 96 ** This is useful if we want to batch connections to 97 ** reduce load. This will cause the messages to be 98 ** queued up, and a daemon will come along to send the 99 ** messages later. 100 ** This should be on a per-mailer basis. 101 */ 102 103 if (NoConnect && !QueueRun && bitnset(M_EXPENSIVE, m->m_flags) && 104 !Verbose) 105 { 106 for (; to != NULL; to = to->q_next) 107 { 108 if (bitset(QDONTSEND, to->q_flags) || to->q_mailer != m) 109 continue; 110 to->q_flags |= QQUEUEUP|QDONTSEND; 111 e->e_to = to->q_paddr; 112 message(Arpa_Info, "queued"); 113 if (LogLevel > 4) 114 logdelivery("queued", e); 115 } 116 e->e_to = NULL; 117 return (0); 118 } 119 120 /* 121 ** Do initial argv setup. 122 ** Insert the mailer name. Notice that $x expansion is 123 ** NOT done on the mailer name. Then, if the mailer has 124 ** a picky -f flag, we insert it as appropriate. This 125 ** code does not check for 'pv' overflow; this places a 126 ** manifest lower limit of 4 for MAXPV. 127 ** The from address rewrite is expected to make 128 ** the address relative to the other end. 129 */ 130 131 /* rewrite from address, using rewriting rules */ 132 (void) strcpy(rpathbuf, remotename(e->e_returnpath, m, TRUE, TRUE, e)); 133 if (e->e_returnpath == e->e_sender) 134 { 135 from = rpathbuf; 136 } 137 else 138 { 139 (void) strcpy(tfrombuf, remotename(e->e_sender, m, TRUE, TRUE, e)); 140 from = tfrombuf; 141 } 142 143 define('f', e->e_returnpath, e); /* raw return path */ 144 define('<', rpathbuf, e); /* translated return path */ 145 define('g', from, e); /* translated sender */ 146 define('h', host, e); /* to host */ 147 Errors = 0; 148 pvp = pv; 149 *pvp++ = m->m_argv[0]; 150 151 /* insert -f or -r flag as appropriate */ 152 if (FromFlag && (bitnset(M_FOPT, m->m_flags) || bitnset(M_ROPT, m->m_flags))) 153 { 154 if (bitnset(M_FOPT, m->m_flags)) 155 *pvp++ = "-f"; 156 else 157 *pvp++ = "-r"; 158 *pvp++ = newstr(rpathbuf); 159 } 160 161 /* 162 ** Append the other fixed parts of the argv. These run 163 ** up to the first entry containing "$u". There can only 164 ** be one of these, and there are only a few more slots 165 ** in the pv after it. 166 */ 167 168 for (mvp = m->m_argv; (p = *++mvp) != NULL; ) 169 { 170 while ((p = index(p, '\001')) != NULL) 171 if (*++p == 'u') 172 break; 173 if (p != NULL) 174 break; 175 176 /* this entry is safe -- go ahead and process it */ 177 expand(*mvp, buf, &buf[sizeof buf - 1], e); 178 *pvp++ = newstr(buf); 179 if (pvp >= &pv[MAXPV - 3]) 180 { 181 syserr("Too many parameters to %s before $u", pv[0]); 182 return (-1); 183 } 184 } 185 186 /* 187 ** If we have no substitution for the user name in the argument 188 ** list, we know that we must supply the names otherwise -- and 189 ** SMTP is the answer!! 190 */ 191 192 if (*mvp == NULL) 193 { 194 /* running SMTP */ 195 # ifdef SMTP 196 clever = TRUE; 197 *pvp = NULL; 198 # else SMTP 199 /* oops! we don't implement SMTP */ 200 syserr("SMTP style mailer"); 201 return (EX_SOFTWARE); 202 # endif SMTP 203 } 204 205 /* 206 ** At this point *mvp points to the argument with $u. We 207 ** run through our address list and append all the addresses 208 ** we can. If we run out of space, do not fret! We can 209 ** always send another copy later. 210 */ 211 212 tobuf[0] = '\0'; 213 e->e_to = tobuf; 214 ctladdr = NULL; 215 for (; to != NULL; to = to->q_next) 216 { 217 /* avoid sending multiple recipients to dumb mailers */ 218 if (tobuf[0] != '\0' && !bitnset(M_MUSER, m->m_flags)) 219 break; 220 221 /* if already sent or not for this host, don't send */ 222 if (bitset(QDONTSEND, to->q_flags) || 223 strcmp(to->q_host, host) != 0 || 224 to->q_mailer != firstto->q_mailer) 225 continue; 226 227 /* avoid overflowing tobuf */ 228 if (sizeof tobuf < (strlen(to->q_paddr) + strlen(tobuf) + 2)) 229 break; 230 231 if (tTd(10, 1)) 232 { 233 printf("\nsend to "); 234 printaddr(to, FALSE); 235 } 236 237 /* compute effective uid/gid when sending */ 238 if (to->q_mailer == ProgMailer) 239 ctladdr = getctladdr(to); 240 241 user = to->q_user; 242 e->e_to = to->q_paddr; 243 to->q_flags |= QDONTSEND; 244 245 /* 246 ** Check to see that these people are allowed to 247 ** talk to each other. 248 */ 249 250 if (m->m_maxsize != 0 && e->e_msgsize > m->m_maxsize) 251 { 252 NoReturn = TRUE; 253 usrerr("Message is too large; %ld bytes max", m->m_maxsize); 254 giveresponse(EX_UNAVAILABLE, m, e); 255 continue; 256 } 257 if (!checkcompat(to, e)) 258 { 259 giveresponse(EX_UNAVAILABLE, m, e); 260 continue; 261 } 262 263 /* 264 ** Strip quote bits from names if the mailer is dumb 265 ** about them. 266 */ 267 268 if (bitnset(M_STRIPQ, m->m_flags)) 269 { 270 stripquotes(user); 271 stripquotes(host); 272 } 273 274 /* hack attack -- delivermail compatibility */ 275 if (m == ProgMailer && *user == '|') 276 user++; 277 278 /* 279 ** If an error message has already been given, don't 280 ** bother to send to this address. 281 ** 282 ** >>>>>>>>>> This clause assumes that the local mailer 283 ** >> NOTE >> cannot do any further aliasing; that 284 ** >>>>>>>>>> function is subsumed by sendmail. 285 */ 286 287 if (bitset(QBADADDR|QQUEUEUP, to->q_flags)) 288 continue; 289 290 /* save statistics.... */ 291 markstats(e, to); 292 293 /* 294 ** See if this user name is "special". 295 ** If the user name has a slash in it, assume that this 296 ** is a file -- send it off without further ado. Note 297 ** that this type of addresses is not processed along 298 ** with the others, so we fudge on the To person. 299 */ 300 301 if (m == LocalMailer) 302 { 303 if (user[0] == '/') 304 { 305 rcode = mailfile(user, getctladdr(to), e); 306 giveresponse(rcode, m, e); 307 if (rcode == EX_OK) 308 to->q_flags |= QSENT; 309 continue; 310 } 311 } 312 313 /* 314 ** Address is verified -- add this user to mailer 315 ** argv, and add it to the print list of recipients. 316 */ 317 318 /* link together the chain of recipients */ 319 to->q_tchain = tochain; 320 tochain = to; 321 322 /* create list of users for error messages */ 323 (void) strcat(tobuf, ","); 324 (void) strcat(tobuf, to->q_paddr); 325 define('u', user, e); /* to user */ 326 define('z', to->q_home, e); /* user's home */ 327 328 /* 329 ** Expand out this user into argument list. 330 */ 331 332 if (!clever) 333 { 334 expand(*mvp, buf, &buf[sizeof buf - 1], e); 335 *pvp++ = newstr(buf); 336 if (pvp >= &pv[MAXPV - 2]) 337 { 338 /* allow some space for trailing parms */ 339 break; 340 } 341 } 342 } 343 344 /* see if any addresses still exist */ 345 if (tobuf[0] == '\0') 346 { 347 define('g', (char *) NULL, e); 348 define('<', (char *) NULL, e); 349 return (0); 350 } 351 352 /* print out messages as full list */ 353 e->e_to = tobuf + 1; 354 355 /* 356 ** Fill out any parameters after the $u parameter. 357 */ 358 359 while (!clever && *++mvp != NULL) 360 { 361 expand(*mvp, buf, &buf[sizeof buf - 1], e); 362 *pvp++ = newstr(buf); 363 if (pvp >= &pv[MAXPV]) 364 syserr("deliver: pv overflow after $u for %s", pv[0]); 365 } 366 *pvp++ = NULL; 367 368 /* 369 ** Call the mailer. 370 ** The argument vector gets built, pipes 371 ** are created as necessary, and we fork & exec as 372 ** appropriate. 373 ** If we are running SMTP, we just need to clean up. 374 */ 375 376 if (ctladdr == NULL) 377 ctladdr = &e->e_from; 378 #ifdef NAMED_BIND 379 if (ConfigLevel < 2) 380 _res.options &= ~(RES_DEFNAMES | RES_DNSRCH); /* XXX */ 381 #endif 382 mci = openmailer(m, pv, ctladdr, clever, e); 383 if (mci == NULL) 384 { 385 /* catastrophic error */ 386 rcode = -1; 387 goto give_up; 388 } 389 else if (mci->mci_state != MCIS_OPEN) 390 { 391 /* couldn't open the mailer */ 392 rcode = mci->mci_exitstat; 393 if (rcode == EX_OK) 394 { 395 /* shouldn't happen */ 396 rcode = EX_SOFTWARE; 397 } 398 } 399 else if (!clever) 400 { 401 /* 402 ** Format and send message. 403 */ 404 405 putfromline(mci->mci_out, m, e); 406 (*e->e_puthdr)(mci->mci_out, m, e); 407 putline("\n", mci->mci_out, m); 408 (*e->e_putbody)(mci->mci_out, m, e); 409 410 /* get the exit status */ 411 rcode = endmailer(mci, pv[0]); 412 } 413 else 414 #ifdef SMTP 415 { 416 /* 417 ** Send the MAIL FROM: protocol 418 */ 419 420 rcode = smtpmailfrom(m, mci, e); 421 if (rcode == EX_OK) 422 { 423 register char *t = tobuf; 424 register int i; 425 426 /* send the recipient list */ 427 tobuf[0] = '\0'; 428 for (to = tochain; to != NULL; to = to->q_tchain) 429 { 430 e->e_to = to->q_paddr; 431 if ((i = smtprcpt(to, m, mci, e)) != EX_OK) 432 { 433 markfailure(e, to, i); 434 giveresponse(i, m, e); 435 } 436 else 437 { 438 *t++ = ','; 439 for (p = to->q_paddr; *p; *t++ = *p++) 440 continue; 441 } 442 } 443 444 /* now send the data */ 445 if (tobuf[0] == '\0') 446 { 447 e->e_to = NULL; 448 if (bitset(MCIF_CACHED, mci->mci_flags)) 449 smtprset(m, mci, e); 450 } 451 else 452 { 453 e->e_to = tobuf + 1; 454 rcode = smtpdata(m, mci, e); 455 } 456 457 /* now close the connection */ 458 if (!bitset(MCIF_CACHED, mci->mci_flags)) 459 smtpquit(m, mci, e); 460 } 461 } 462 #else /* not SMTP */ 463 { 464 syserr("deliver: need SMTP compiled to use clever mailer"); 465 rcode = -1; 466 goto give_up; 467 } 468 #endif /* SMTP */ 469 #ifdef NAMED_BIND 470 if (ConfigLevel < 2) 471 _res.options |= RES_DEFNAMES | RES_DNSRCH; /* XXX */ 472 #endif 473 474 /* arrange a return receipt if requested */ 475 if (e->e_receiptto != NULL && bitnset(M_LOCAL, m->m_flags)) 476 { 477 e->e_flags |= EF_SENDRECEIPT; 478 /* do we want to send back more info? */ 479 } 480 481 /* 482 ** Do final status disposal. 483 ** We check for something in tobuf for the SMTP case. 484 ** If we got a temporary failure, arrange to queue the 485 ** addressees. 486 */ 487 488 give_up: 489 if (tobuf[0] != '\0') 490 giveresponse(rcode, m, e); 491 for (to = tochain; to != NULL; to = to->q_tchain) 492 { 493 if (rcode != EX_OK) 494 markfailure(e, to, rcode); 495 else 496 to->q_flags |= QSENT; 497 } 498 499 /* 500 ** Restore state and return. 501 */ 502 503 errno = 0; 504 define('g', (char *) NULL, e); 505 define('<', (char *) NULL, e); 506 return (rcode); 507 } 508 /* 509 ** MARKFAILURE -- mark a failure on a specific address. 510 ** 511 ** Parameters: 512 ** e -- the envelope we are sending. 513 ** q -- the address to mark. 514 ** rcode -- the code signifying the particular failure. 515 ** 516 ** Returns: 517 ** none. 518 ** 519 ** Side Effects: 520 ** marks the address (and possibly the envelope) with the 521 ** failure so that an error will be returned or 522 ** the message will be queued, as appropriate. 523 */ 524 525 markfailure(e, q, rcode) 526 register ENVELOPE *e; 527 register ADDRESS *q; 528 int rcode; 529 { 530 if (rcode == EX_OK) 531 return; 532 else if (rcode != EX_TEMPFAIL && rcode != EX_IOERR && rcode != EX_OSERR) 533 q->q_flags |= QBADADDR; 534 else if (curtime() > e->e_ctime + TimeOut) 535 { 536 extern char *pintvl(); 537 char buf[MAXLINE]; 538 539 if (!bitset(EF_TIMEOUT, e->e_flags)) 540 { 541 (void) sprintf(buf, "Cannot send message for %s", 542 pintvl(TimeOut, FALSE)); 543 if (e->e_message != NULL) 544 free(e->e_message); 545 e->e_message = newstr(buf); 546 message(Arpa_Info, buf); 547 } 548 q->q_flags |= QBADADDR; 549 e->e_flags |= EF_TIMEOUT; 550 } 551 else 552 q->q_flags |= QQUEUEUP; 553 } 554 /* 555 ** DOFORK -- do a fork, retrying a couple of times on failure. 556 ** 557 ** This MUST be a macro, since after a vfork we are running 558 ** two processes on the same stack!!! 559 ** 560 ** Parameters: 561 ** none. 562 ** 563 ** Returns: 564 ** From a macro??? You've got to be kidding! 565 ** 566 ** Side Effects: 567 ** Modifies the ==> LOCAL <== variable 'pid', leaving: 568 ** pid of child in parent, zero in child. 569 ** -1 on unrecoverable error. 570 ** 571 ** Notes: 572 ** I'm awfully sorry this looks so awful. That's 573 ** vfork for you..... 574 */ 575 576 # define NFORKTRIES 5 577 578 # ifndef FORK 579 # define FORK fork 580 # endif 581 582 # define DOFORK(fORKfN) \ 583 {\ 584 register int i;\ 585 \ 586 for (i = NFORKTRIES; --i >= 0; )\ 587 {\ 588 pid = fORKfN();\ 589 if (pid >= 0)\ 590 break;\ 591 if (i > 0)\ 592 sleep((unsigned) NFORKTRIES - i);\ 593 }\ 594 } 595 /* 596 ** DOFORK -- simple fork interface to DOFORK. 597 ** 598 ** Parameters: 599 ** none. 600 ** 601 ** Returns: 602 ** pid of child in parent. 603 ** zero in child. 604 ** -1 on error. 605 ** 606 ** Side Effects: 607 ** returns twice, once in parent and once in child. 608 */ 609 610 dofork() 611 { 612 register int pid; 613 614 DOFORK(fork); 615 return (pid); 616 } 617 /* 618 ** ENDMAILER -- Wait for mailer to terminate. 619 ** 620 ** We should never get fatal errors (e.g., segmentation 621 ** violation), so we report those specially. For other 622 ** errors, we choose a status message (into statmsg), 623 ** and if it represents an error, we print it. 624 ** 625 ** Parameters: 626 ** pid -- pid of mailer. 627 ** name -- name of mailer (for error messages). 628 ** 629 ** Returns: 630 ** exit code of mailer. 631 ** 632 ** Side Effects: 633 ** none. 634 */ 635 636 endmailer(mci, name) 637 register MCI *mci; 638 char *name; 639 { 640 int st; 641 642 /* close any connections */ 643 if (mci->mci_in != NULL) 644 (void) fclose(mci->mci_in); 645 if (mci->mci_out != NULL) 646 (void) fclose(mci->mci_out); 647 mci->mci_in = mci->mci_out = NULL; 648 mci->mci_state = MCIS_CLOSED; 649 650 /* in the IPC case there is nothing to wait for */ 651 if (mci->mci_pid == 0) 652 return (EX_OK); 653 654 /* wait for the mailer process to die and collect status */ 655 st = waitfor(mci->mci_pid); 656 if (st == -1) 657 { 658 syserr("endmailer %s: wait", name); 659 return (EX_SOFTWARE); 660 } 661 662 /* see if it died a horrid death */ 663 if ((st & 0377) != 0) 664 { 665 syserr("mailer %s died with signal %o", name, st); 666 ExitStat = EX_TEMPFAIL; 667 return (EX_TEMPFAIL); 668 } 669 670 /* normal death -- return status */ 671 st = (st >> 8) & 0377; 672 return (st); 673 } 674 /* 675 ** OPENMAILER -- open connection to mailer. 676 ** 677 ** Parameters: 678 ** m -- mailer descriptor. 679 ** pvp -- parameter vector to pass to mailer. 680 ** ctladdr -- controlling address for user. 681 ** clever -- create a full duplex connection. 682 ** 683 ** Returns: 684 ** The mail connection info struct for this connection. 685 ** NULL on failure. 686 ** 687 ** Side Effects: 688 ** creates a mailer in a subprocess. 689 */ 690 691 MCI * 692 openmailer(m, pvp, ctladdr, clever, e) 693 MAILER *m; 694 char **pvp; 695 ADDRESS *ctladdr; 696 bool clever; 697 ENVELOPE *e; 698 { 699 int pid; 700 register MCI *mci; 701 int mpvect[2]; 702 int rpvect[2]; 703 extern FILE *fdopen(); 704 705 if (tTd(11, 1)) 706 { 707 printf("openmailer:"); 708 printav(pvp); 709 } 710 errno = 0; 711 712 CurHostName = m->m_mailer; 713 714 /* 715 ** Deal with the special case of mail handled through an IPC 716 ** connection. 717 ** In this case we don't actually fork. We must be 718 ** running SMTP for this to work. We will return a 719 ** zero pid to indicate that we are running IPC. 720 ** We also handle a debug version that just talks to stdin/out. 721 */ 722 723 /* check for Local Person Communication -- not for mortals!!! */ 724 if (strcmp(m->m_mailer, "[LPC]") == 0) 725 { 726 mci = (MCI *) xalloc(sizeof *mci); 727 bzero((char *) mci, sizeof *mci); 728 mci->mci_in = stdin; 729 mci->mci_out = stdout; 730 mci->mci_state = clever ? MCIS_OPENING : MCIS_OPEN; 731 mci->mci_mailer = m; 732 } 733 else if (strcmp(m->m_mailer, "[IPC]") == 0 || 734 strcmp(m->m_mailer, "[TCP]") == 0) 735 { 736 #ifdef DAEMON 737 register STAB *st; 738 extern STAB *stab(); 739 register int i, j; 740 register u_short port; 741 int nmx; 742 char *mxhosts[MAXMXHOSTS + 1]; 743 extern MCI *mci_get(); 744 745 CurHostName = pvp[1]; 746 #ifdef NAMED_BIND 747 if (CurHostName != NULL && CurHostName[0] != '\0' && 748 CurHostName[0] != '[') 749 { 750 int rcode; 751 char buf[MAXNAME]; 752 753 expand("\001j", buf, &buf[sizeof(buf) - 1], e); 754 nmx = getmxrr(CurHostName, mxhosts, buf, &rcode); 755 if (nmx < 0) 756 { 757 mci = mci_get(CurHostName, m); 758 mci->mci_exitstat = rcode; 759 mci->mci_errno = errno; 760 } 761 } 762 else 763 #endif 764 { 765 nmx = 1; 766 mxhosts[0] = CurHostName; 767 } 768 769 if (!clever) 770 syserr("non-clever IPC"); 771 if (pvp[2] != NULL) 772 port = atoi(pvp[2]); 773 else 774 port = 0; 775 for (j = 0; j < nmx; j++) 776 { 777 /* see if we already know that this host is fried */ 778 CurHostName = mxhosts[j]; 779 mci = mci_get(CurHostName, m); 780 if (mci->mci_state != MCIS_CLOSED) 781 return mci; 782 mci->mci_mailer = m; 783 if (mci->mci_exitstat != EX_OK) 784 continue; 785 786 /* try the connection */ 787 setproctitle("%s %s: %s", e->e_id, mxhosts[1], "user open"); 788 message(Arpa_Info, "Connecting to %s (%s)...", 789 mxhosts[j], m->m_name); 790 i = makeconnection(mxhosts[j], port, mci, 791 bitnset(M_SECURE_PORT, m->m_flags)); 792 mci->mci_exitstat = i; 793 mci->mci_errno = errno; 794 if (i == EX_OK) 795 { 796 mci->mci_state = MCIS_OPENING; 797 mci_cache(mci); 798 break; 799 } 800 else if (tTd(11, 1)) 801 printf("openmailer: makeconnection => stat=%d, errno=%d\n", 802 i, errno); 803 804 805 /* enter status of this host */ 806 setstat(i); 807 } 808 mci->mci_pid = 0; 809 #else /* no DAEMON */ 810 syserr("openmailer: no IPC"); 811 return NULL; 812 #endif /* DAEMON */ 813 } 814 else 815 { 816 /* create a pipe to shove the mail through */ 817 if (pipe(mpvect) < 0) 818 { 819 syserr("openmailer: pipe (to mailer)"); 820 return NULL; 821 } 822 823 /* if this mailer speaks smtp, create a return pipe */ 824 if (clever && pipe(rpvect) < 0) 825 { 826 syserr("openmailer: pipe (from mailer)"); 827 (void) close(mpvect[0]); 828 (void) close(mpvect[1]); 829 return NULL; 830 } 831 832 /* 833 ** Actually fork the mailer process. 834 ** DOFORK is clever about retrying. 835 ** 836 ** Dispose of SIGCHLD signal catchers that may be laying 837 ** around so that endmail will get it. 838 */ 839 840 if (e->e_xfp != NULL) 841 (void) fflush(e->e_xfp); /* for debugging */ 842 (void) fflush(stdout); 843 # ifdef SIGCHLD 844 (void) signal(SIGCHLD, SIG_DFL); 845 # endif SIGCHLD 846 DOFORK(FORK); 847 /* pid is set by DOFORK */ 848 if (pid < 0) 849 { 850 /* failure */ 851 syserr("openmailer: cannot fork"); 852 (void) close(mpvect[0]); 853 (void) close(mpvect[1]); 854 if (clever) 855 { 856 (void) close(rpvect[0]); 857 (void) close(rpvect[1]); 858 } 859 return NULL; 860 } 861 else if (pid == 0) 862 { 863 int i; 864 extern int DtableSize; 865 866 /* child -- set up input & exec mailer */ 867 /* make diagnostic output be standard output */ 868 (void) signal(SIGINT, SIG_IGN); 869 (void) signal(SIGHUP, SIG_IGN); 870 (void) signal(SIGTERM, SIG_DFL); 871 872 /* arrange to filter std & diag output of command */ 873 if (clever) 874 { 875 (void) close(rpvect[0]); 876 (void) close(1); 877 (void) dup(rpvect[1]); 878 (void) close(rpvect[1]); 879 } 880 else if (OpMode == MD_SMTP || HoldErrs) 881 { 882 /* put mailer output in transcript */ 883 (void) close(1); 884 (void) dup(fileno(e->e_xfp)); 885 } 886 (void) close(2); 887 (void) dup(1); 888 889 /* arrange to get standard input */ 890 (void) close(mpvect[1]); 891 (void) close(0); 892 if (dup(mpvect[0]) < 0) 893 { 894 syserr("Cannot dup to zero!"); 895 _exit(EX_OSERR); 896 } 897 (void) close(mpvect[0]); 898 if (!bitnset(M_RESTR, m->m_flags)) 899 { 900 if (ctladdr == NULL || ctladdr->q_uid == 0) 901 { 902 (void) setgid(DefGid); 903 (void) initgroups(DefUser, DefGid); 904 (void) setuid(DefUid); 905 } 906 else 907 { 908 (void) setgid(ctladdr->q_gid); 909 (void) initgroups(ctladdr->q_ruser? 910 ctladdr->q_ruser: ctladdr->q_user, 911 ctladdr->q_gid); 912 (void) setuid(ctladdr->q_uid); 913 } 914 } 915 916 /* arrange for all the files to be closed */ 917 for (i = 3; i < DtableSize; i++) 918 { 919 register int j; 920 if ((j = fcntl(i, F_GETFD, 0)) != -1) 921 (void)fcntl(i, F_SETFD, j|1); 922 } 923 924 /* try to execute the mailer */ 925 execve(m->m_mailer, pvp, UserEnviron); 926 syserr("Cannot exec %s", m->m_mailer); 927 if (m == LocalMailer) 928 _exit(EX_TEMPFAIL); 929 switch (errno) 930 { 931 case EIO: 932 case EAGAIN: 933 case ENOMEM: 934 # ifdef EPROCLIM 935 case EPROCLIM: 936 # endif 937 _exit(EX_TEMPFAIL); 938 } 939 _exit(EX_UNAVAILABLE); 940 } 941 942 /* 943 ** Set up return value. 944 */ 945 946 mci = (MCI *) xalloc(sizeof *mci); 947 bzero((char *) mci, sizeof *mci); 948 mci->mci_mailer = m; 949 mci->mci_state = clever ? MCIS_OPENING : MCIS_OPEN; 950 mci->mci_pid = pid; 951 (void) close(mpvect[0]); 952 mci->mci_out = fdopen(mpvect[1], "w"); 953 if (clever) 954 { 955 (void) close(rpvect[1]); 956 mci->mci_in = fdopen(rpvect[0], "r"); 957 } 958 else 959 { 960 mci->mci_flags |= MCIF_TEMP; 961 mci->mci_in = NULL; 962 } 963 } 964 965 /* 966 ** If we are in SMTP opening state, send initial protocol. 967 */ 968 969 if (clever && mci->mci_state != MCIS_CLOSED) 970 { 971 smtpinit(m, mci, e); 972 } 973 974 return mci; 975 } 976 /* 977 ** GIVERESPONSE -- Interpret an error response from a mailer 978 ** 979 ** Parameters: 980 ** stat -- the status code from the mailer (high byte 981 ** only; core dumps must have been taken care of 982 ** already). 983 ** m -- the mailer descriptor for this mailer. 984 ** 985 ** Returns: 986 ** none. 987 ** 988 ** Side Effects: 989 ** Errors may be incremented. 990 ** ExitStat may be set. 991 */ 992 993 giveresponse(stat, m, e) 994 int stat; 995 register MAILER *m; 996 ENVELOPE *e; 997 { 998 register char *statmsg; 999 extern char *SysExMsg[]; 1000 register int i; 1001 extern int N_SysEx; 1002 #ifdef NAMED_BIND 1003 extern int h_errno; 1004 #endif 1005 char buf[MAXLINE]; 1006 1007 #ifdef lint 1008 if (m == NULL) 1009 return; 1010 #endif lint 1011 1012 /* 1013 ** Compute status message from code. 1014 */ 1015 1016 i = stat - EX__BASE; 1017 if (stat == 0) 1018 statmsg = "250 Sent"; 1019 else if (i < 0 || i > N_SysEx) 1020 { 1021 (void) sprintf(buf, "554 unknown mailer error %d", stat); 1022 stat = EX_UNAVAILABLE; 1023 statmsg = buf; 1024 } 1025 else if (stat == EX_TEMPFAIL) 1026 { 1027 (void) strcpy(buf, SysExMsg[i]); 1028 #ifdef NAMED_BIND 1029 if (h_errno == TRY_AGAIN) 1030 { 1031 extern char *errstring(); 1032 1033 statmsg = errstring(h_errno+MAX_ERRNO); 1034 } 1035 else 1036 #endif 1037 { 1038 if (errno != 0) 1039 { 1040 extern char *errstring(); 1041 1042 statmsg = errstring(errno); 1043 } 1044 else 1045 { 1046 #ifdef SMTP 1047 extern char SmtpError[]; 1048 1049 statmsg = SmtpError; 1050 #else SMTP 1051 statmsg = NULL; 1052 #endif SMTP 1053 } 1054 } 1055 if (statmsg != NULL && statmsg[0] != '\0') 1056 { 1057 (void) strcat(buf, ": "); 1058 (void) strcat(buf, statmsg); 1059 } 1060 statmsg = buf; 1061 } 1062 else 1063 { 1064 statmsg = SysExMsg[i]; 1065 } 1066 1067 /* 1068 ** Print the message as appropriate 1069 */ 1070 1071 if (stat == EX_OK || stat == EX_TEMPFAIL) 1072 message(Arpa_Info, &statmsg[4]); 1073 else 1074 { 1075 Errors++; 1076 usrerr(statmsg); 1077 } 1078 1079 /* 1080 ** Final cleanup. 1081 ** Log a record of the transaction. Compute the new 1082 ** ExitStat -- if we already had an error, stick with 1083 ** that. 1084 */ 1085 1086 if (LogLevel > ((stat == 0 || stat == EX_TEMPFAIL) ? 3 : 2)) 1087 logdelivery(&statmsg[4], e); 1088 1089 if (stat != EX_TEMPFAIL) 1090 setstat(stat); 1091 if (stat != EX_OK) 1092 { 1093 if (e->e_message != NULL) 1094 free(e->e_message); 1095 e->e_message = newstr(&statmsg[4]); 1096 } 1097 errno = 0; 1098 #ifdef NAMED_BIND 1099 h_errno = 0; 1100 #endif 1101 } 1102 /* 1103 ** LOGDELIVERY -- log the delivery in the system log 1104 ** 1105 ** Parameters: 1106 ** stat -- the message to print for the status 1107 ** 1108 ** Returns: 1109 ** none 1110 ** 1111 ** Side Effects: 1112 ** none 1113 */ 1114 1115 logdelivery(stat, e) 1116 char *stat; 1117 register ENVELOPE *e; 1118 { 1119 extern char *pintvl(); 1120 1121 # ifdef LOG 1122 syslog(LOG_INFO, "%s: to=%s, delay=%s, stat=%s", e->e_id, 1123 e->e_to, pintvl(curtime() - e->e_ctime, TRUE), stat); 1124 # endif LOG 1125 } 1126 /* 1127 ** PUTFROMLINE -- output a UNIX-style from line (or whatever) 1128 ** 1129 ** This can be made an arbitrary message separator by changing $l 1130 ** 1131 ** One of the ugliest hacks seen by human eyes is contained herein: 1132 ** UUCP wants those stupid "remote from <host>" lines. Why oh why 1133 ** does a well-meaning programmer such as myself have to deal with 1134 ** this kind of antique garbage???? 1135 ** 1136 ** Parameters: 1137 ** fp -- the file to output to. 1138 ** m -- the mailer describing this entry. 1139 ** 1140 ** Returns: 1141 ** none 1142 ** 1143 ** Side Effects: 1144 ** outputs some text to fp. 1145 */ 1146 1147 putfromline(fp, m, e) 1148 register FILE *fp; 1149 register MAILER *m; 1150 ENVELOPE *e; 1151 { 1152 char *template = "\001l\n"; 1153 char buf[MAXLINE]; 1154 1155 if (bitnset(M_NHDR, m->m_flags)) 1156 return; 1157 1158 # ifdef UGLYUUCP 1159 if (bitnset(M_UGLYUUCP, m->m_flags)) 1160 { 1161 char *bang; 1162 char xbuf[MAXLINE]; 1163 1164 expand("\001<", buf, &buf[sizeof buf - 1], e); 1165 bang = index(buf, '!'); 1166 if (bang == NULL) 1167 syserr("No ! in UUCP! (%s)", buf); 1168 else 1169 { 1170 *bang++ = '\0'; 1171 (void) sprintf(xbuf, "From %s \001d remote from %s\n", bang, buf); 1172 template = xbuf; 1173 } 1174 } 1175 # endif UGLYUUCP 1176 expand(template, buf, &buf[sizeof buf - 1], e); 1177 putline(buf, fp, m); 1178 } 1179 /* 1180 ** PUTBODY -- put the body of a message. 1181 ** 1182 ** Parameters: 1183 ** fp -- file to output onto. 1184 ** m -- a mailer descriptor to control output format. 1185 ** e -- the envelope to put out. 1186 ** 1187 ** Returns: 1188 ** none. 1189 ** 1190 ** Side Effects: 1191 ** The message is written onto fp. 1192 */ 1193 1194 putbody(fp, m, e) 1195 FILE *fp; 1196 MAILER *m; 1197 register ENVELOPE *e; 1198 { 1199 char buf[MAXLINE]; 1200 1201 /* 1202 ** Output the body of the message 1203 */ 1204 1205 if (e->e_dfp == NULL) 1206 { 1207 if (e->e_df != NULL) 1208 { 1209 e->e_dfp = fopen(e->e_df, "r"); 1210 if (e->e_dfp == NULL) 1211 syserr("putbody: Cannot open %s for %s from %s", 1212 e->e_df, e->e_to, e->e_from); 1213 } 1214 else 1215 putline("<<< No Message Collected >>>", fp, m); 1216 } 1217 if (e->e_dfp != NULL) 1218 { 1219 rewind(e->e_dfp); 1220 while (!ferror(fp) && fgets(buf, sizeof buf, e->e_dfp) != NULL) 1221 { 1222 if (buf[0] == 'F' && bitnset(M_ESCFROM, m->m_flags) && 1223 strncmp(buf, "From ", 5) == 0) 1224 (void) putc('>', fp); 1225 putline(buf, fp, m); 1226 } 1227 1228 if (ferror(e->e_dfp)) 1229 { 1230 syserr("putbody: read error"); 1231 ExitStat = EX_IOERR; 1232 } 1233 } 1234 1235 (void) fflush(fp); 1236 if (ferror(fp) && errno != EPIPE) 1237 { 1238 syserr("putbody: write error"); 1239 ExitStat = EX_IOERR; 1240 } 1241 errno = 0; 1242 } 1243 /* 1244 ** MAILFILE -- Send a message to a file. 1245 ** 1246 ** If the file has the setuid/setgid bits set, but NO execute 1247 ** bits, sendmail will try to become the owner of that file 1248 ** rather than the real user. Obviously, this only works if 1249 ** sendmail runs as root. 1250 ** 1251 ** This could be done as a subordinate mailer, except that it 1252 ** is used implicitly to save messages in ~/dead.letter. We 1253 ** view this as being sufficiently important as to include it 1254 ** here. For example, if the system is dying, we shouldn't have 1255 ** to create another process plus some pipes to save the message. 1256 ** 1257 ** Parameters: 1258 ** filename -- the name of the file to send to. 1259 ** ctladdr -- the controlling address header -- includes 1260 ** the userid/groupid to be when sending. 1261 ** 1262 ** Returns: 1263 ** The exit code associated with the operation. 1264 ** 1265 ** Side Effects: 1266 ** none. 1267 */ 1268 1269 mailfile(filename, ctladdr, e) 1270 char *filename; 1271 ADDRESS *ctladdr; 1272 register ENVELOPE *e; 1273 { 1274 register FILE *f; 1275 register int pid; 1276 int mode; 1277 1278 /* 1279 ** Fork so we can change permissions here. 1280 ** Note that we MUST use fork, not vfork, because of 1281 ** the complications of calling subroutines, etc. 1282 */ 1283 1284 DOFORK(fork); 1285 1286 if (pid < 0) 1287 return (EX_OSERR); 1288 else if (pid == 0) 1289 { 1290 /* child -- actually write to file */ 1291 struct stat stb; 1292 1293 (void) signal(SIGINT, SIG_DFL); 1294 (void) signal(SIGHUP, SIG_DFL); 1295 (void) signal(SIGTERM, SIG_DFL); 1296 (void) umask(OldUmask); 1297 1298 if (stat(filename, &stb) < 0) 1299 stb.st_mode = 0666; 1300 mode = stb.st_mode; 1301 1302 /* limit the errors to those actually caused in the child */ 1303 errno = 0; 1304 ExitStat = EX_OK; 1305 1306 if (bitset(0111, stb.st_mode)) 1307 exit(EX_CANTCREAT); 1308 if (ctladdr == NULL) 1309 ctladdr = &e->e_from; 1310 else 1311 { 1312 /* ignore setuid and setgid bits */ 1313 mode &= ~(S_ISGID|S_ISUID); 1314 } 1315 1316 /* we have to open the dfile BEFORE setuid */ 1317 if (e->e_dfp == NULL && e->e_df != NULL) 1318 { 1319 e->e_dfp = fopen(e->e_df, "r"); 1320 if (e->e_dfp == NULL) 1321 { 1322 syserr("mailfile: Cannot open %s for %s from %s", 1323 e->e_df, e->e_to, e->e_from); 1324 } 1325 } 1326 1327 if (!bitset(S_ISGID, mode) || setgid(stb.st_gid) < 0) 1328 { 1329 if (ctladdr->q_uid == 0) 1330 { 1331 (void) setgid(DefGid); 1332 (void) initgroups(DefUser, DefGid); 1333 } 1334 else 1335 { 1336 (void) setgid(ctladdr->q_gid); 1337 (void) initgroups(ctladdr->q_ruser ? 1338 ctladdr->q_ruser : ctladdr->q_user, 1339 ctladdr->q_gid); 1340 } 1341 } 1342 if (!bitset(S_ISUID, mode) || setuid(stb.st_uid) < 0) 1343 { 1344 if (ctladdr->q_uid == 0) 1345 (void) setuid(DefUid); 1346 else 1347 (void) setuid(ctladdr->q_uid); 1348 } 1349 FileName = filename; 1350 LineNumber = 0; 1351 f = dfopen(filename, "a"); 1352 if (f == NULL) 1353 { 1354 message("cannot open"); 1355 exit(EX_CANTCREAT); 1356 } 1357 1358 putfromline(f, ProgMailer, e); 1359 (*e->e_puthdr)(f, ProgMailer, e); 1360 putline("\n", f, ProgMailer); 1361 (*e->e_putbody)(f, ProgMailer, e); 1362 putline("\n", f, ProgMailer); 1363 if (ferror(f)) 1364 { 1365 message("I/O error"); 1366 setstat(EX_IOERR); 1367 } 1368 (void) fclose(f); 1369 (void) fflush(stdout); 1370 1371 /* reset ISUID & ISGID bits for paranoid systems */ 1372 (void) chmod(filename, (int) stb.st_mode); 1373 exit(ExitStat); 1374 /*NOTREACHED*/ 1375 } 1376 else 1377 { 1378 /* parent -- wait for exit status */ 1379 int st; 1380 1381 st = waitfor(pid); 1382 if ((st & 0377) != 0) 1383 return (EX_UNAVAILABLE); 1384 else 1385 return ((st >> 8) & 0377); 1386 /*NOTREACHED*/ 1387 } 1388 } 1389 /* 1390 ** SENDALL -- actually send all the messages. 1391 ** 1392 ** Parameters: 1393 ** e -- the envelope to send. 1394 ** mode -- the delivery mode to use. If SM_DEFAULT, use 1395 ** the current SendMode. 1396 ** 1397 ** Returns: 1398 ** none. 1399 ** 1400 ** Side Effects: 1401 ** Scans the send lists and sends everything it finds. 1402 ** Delivers any appropriate error messages. 1403 ** If we are running in a non-interactive mode, takes the 1404 ** appropriate action. 1405 */ 1406 1407 sendall(e, mode) 1408 ENVELOPE *e; 1409 char mode; 1410 { 1411 register ADDRESS *q; 1412 bool oldverbose; 1413 int pid; 1414 int nsent; 1415 # ifdef LOCKF 1416 struct flock lfd; 1417 # endif 1418 1419 /* determine actual delivery mode */ 1420 if (mode == SM_DEFAULT) 1421 { 1422 extern bool shouldqueue(); 1423 1424 if (shouldqueue(e->e_msgpriority)) 1425 mode = SM_QUEUE; 1426 else 1427 mode = SendMode; 1428 } 1429 1430 if (tTd(13, 1)) 1431 { 1432 printf("\nSENDALL: mode %c, sendqueue:\n", mode); 1433 printaddr(e->e_sendqueue, TRUE); 1434 } 1435 1436 /* 1437 ** Do any preprocessing necessary for the mode we are running. 1438 ** Check to make sure the hop count is reasonable. 1439 ** Delete sends to the sender in mailing lists. 1440 */ 1441 1442 CurEnv = e; 1443 1444 if (e->e_hopcount > MaxHopCount) 1445 { 1446 errno = 0; 1447 syserr("sendall: too many hops %d (%d max): from %s, to %s", 1448 e->e_hopcount, MaxHopCount, e->e_from, e->e_to); 1449 return; 1450 } 1451 1452 if (!MeToo) 1453 { 1454 extern ADDRESS *recipient(); 1455 1456 e->e_from.q_flags |= QDONTSEND; 1457 (void) recipient(&e->e_from, &e->e_sendqueue, e); 1458 } 1459 1460 # ifdef QUEUE 1461 if ((mode == SM_QUEUE || mode == SM_FORK || 1462 (mode != SM_VERIFY && SuperSafe)) && 1463 !bitset(EF_INQUEUE, e->e_flags)) 1464 queueup(e, TRUE, mode == SM_QUEUE); 1465 #endif QUEUE 1466 1467 oldverbose = Verbose; 1468 switch (mode) 1469 { 1470 case SM_VERIFY: 1471 Verbose = TRUE; 1472 break; 1473 1474 case SM_QUEUE: 1475 queueonly: 1476 e->e_flags |= EF_INQUEUE|EF_KEEPQUEUE; 1477 return; 1478 1479 case SM_FORK: 1480 if (e->e_xfp != NULL) 1481 (void) fflush(e->e_xfp); 1482 1483 # ifdef LOCKF 1484 /* 1485 ** Since lockf has the interesting semantic that the 1486 ** lock is lost when we fork, we have to risk losing 1487 ** the lock here by closing before the fork, and then 1488 ** trying to get it back in the child. 1489 */ 1490 1491 if (e->e_lockfp != NULL) 1492 { 1493 (void) fclose(e->e_lockfp); 1494 e->e_lockfp = NULL; 1495 } 1496 # endif /* LOCKF */ 1497 1498 pid = fork(); 1499 if (pid < 0) 1500 { 1501 goto queueonly; 1502 } 1503 else if (pid > 0) 1504 { 1505 /* be sure we leave the temp files to our child */ 1506 e->e_id = e->e_df = NULL; 1507 # ifndef LOCKF 1508 if (e->e_lockfp != NULL) 1509 (void) fclose(e->e_lockfp); 1510 # endif 1511 return; 1512 } 1513 1514 /* double fork to avoid zombies */ 1515 if (fork() > 0) 1516 exit(EX_OK); 1517 1518 /* be sure we are immune from the terminal */ 1519 disconnect(FALSE); 1520 1521 # ifdef LOCKF 1522 /* 1523 ** Now try to get our lock back. 1524 */ 1525 1526 lfd.l_type = F_WRLCK; 1527 lfd.l_whence = lfd.l_start = lfd.l_len = 0; 1528 e->e_lockfp = fopen(queuename(e, 'q'), "r+"); 1529 if (e->e_lockfp == NULL || 1530 fcntl(fileno(e->e_lockfp), F_SETLK, &lfd) < 0) 1531 { 1532 /* oops.... lost it */ 1533 # ifdef LOG 1534 if (LogLevel > 5) 1535 syslog(LOG_NOTICE, "%s: lost lock: %m", 1536 e->e_id); 1537 # endif /* LOG */ 1538 exit(EX_OK); 1539 } 1540 # endif /* LOCKF */ 1541 1542 break; 1543 } 1544 1545 /* 1546 ** Run through the list and send everything. 1547 */ 1548 1549 nsent = 0; 1550 for (q = e->e_sendqueue; q != NULL; q = q->q_next) 1551 { 1552 if (mode == SM_VERIFY) 1553 { 1554 e->e_to = q->q_paddr; 1555 if (!bitset(QDONTSEND|QBADADDR, q->q_flags)) 1556 message(Arpa_Info, "deliverable"); 1557 } 1558 else if (!bitset(QDONTSEND, q->q_flags)) 1559 { 1560 # ifdef QUEUE 1561 /* 1562 ** Checkpoint the send list every few addresses 1563 */ 1564 1565 if (nsent >= CheckpointInterval) 1566 { 1567 queueup(e, TRUE, FALSE); 1568 nsent = 0; 1569 } 1570 # endif /* QUEUE */ 1571 if (deliver(e, q) == EX_OK) 1572 nsent++; 1573 } 1574 } 1575 Verbose = oldverbose; 1576 1577 /* 1578 ** Now run through and check for errors. 1579 */ 1580 1581 if (mode == SM_VERIFY) 1582 return; 1583 1584 for (q = e->e_sendqueue; q != NULL; q = q->q_next) 1585 { 1586 register ADDRESS *qq; 1587 1588 if (tTd(13, 3)) 1589 { 1590 printf("Checking "); 1591 printaddr(q, FALSE); 1592 } 1593 1594 /* only send errors if the message failed */ 1595 if (!bitset(QBADADDR, q->q_flags)) 1596 continue; 1597 1598 /* we have an address that failed -- find the parent */ 1599 for (qq = q; qq != NULL; qq = qq->q_alias) 1600 { 1601 char obuf[MAXNAME + 6]; 1602 extern char *aliaslookup(); 1603 1604 /* we can only have owners for local addresses */ 1605 if (!bitnset(M_LOCAL, qq->q_mailer->m_flags)) 1606 continue; 1607 1608 /* see if the owner list exists */ 1609 (void) strcpy(obuf, "owner-"); 1610 if (strncmp(qq->q_user, "owner-", 6) == 0) 1611 (void) strcat(obuf, "owner"); 1612 else 1613 (void) strcat(obuf, qq->q_user); 1614 makelower(obuf); 1615 if (aliaslookup(obuf) == NULL) 1616 continue; 1617 1618 if (tTd(13, 4)) 1619 printf("Errors to %s\n", obuf); 1620 1621 /* owner list exists -- add it to the error queue */ 1622 sendtolist(obuf, (ADDRESS *) NULL, &e->e_errorqueue, e); 1623 ErrorMode = EM_MAIL; 1624 break; 1625 } 1626 1627 /* if we did not find an owner, send to the sender */ 1628 if (qq == NULL && bitset(QBADADDR, q->q_flags)) 1629 sendtolist(e->e_from.q_paddr, qq, &e->e_errorqueue, e); 1630 } 1631 1632 if (mode == SM_FORK) 1633 finis(); 1634 } 1635