usersmtp.c (42575) | usersmtp.c (43730) |
---|---|
1/* 2 * Copyright (c) 1998 Sendmail, Inc. All rights reserved. 3 * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. 4 * Copyright (c) 1988, 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * By using this file, you agree to the terms and conditions set 8 * forth in the LICENSE file which can be found at the top level of 9 * the sendmail distribution. 10 * 11 */ 12 13# include "sendmail.h" 14 15#ifndef lint 16#if SMTP | 1/* 2 * Copyright (c) 1998 Sendmail, Inc. All rights reserved. 3 * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. 4 * Copyright (c) 1988, 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * By using this file, you agree to the terms and conditions set 8 * forth in the LICENSE file which can be found at the top level of 9 * the sendmail distribution. 10 * 11 */ 12 13# include "sendmail.h" 14 15#ifndef lint 16#if SMTP |
17static char sccsid[] = "@(#)usersmtp.c 8.108 (Berkeley) 10/6/1998 (with SMTP)"; | 17static char sccsid[] = "@(#)usersmtp.c 8.111 (Berkeley) 2/3/1999 (with SMTP)"; |
18#else | 18#else |
19static char sccsid[] = "@(#)usersmtp.c 8.108 (Berkeley) 10/6/1998 (without SMTP)"; | 19static char sccsid[] = "@(#)usersmtp.c 8.111 (Berkeley) 2/3/1999 (without SMTP)"; |
20#endif 21#endif /* not lint */ 22 23# include <sysexits.h> 24# include <errno.h> 25 26# if SMTP 27 --- 294 unchanged lines hidden (view full) --- 322 323int 324smtpmailfrom(m, mci, e) 325 MAILER *m; 326 MCI *mci; 327 ENVELOPE *e; 328{ 329 int r; | 20#endif 21#endif /* not lint */ 22 23# include <sysexits.h> 24# include <errno.h> 25 26# if SMTP 27 --- 294 unchanged lines hidden (view full) --- 322 323int 324smtpmailfrom(m, mci, e) 325 MAILER *m; 326 MCI *mci; 327 ENVELOPE *e; 328{ 329 int r; |
330 int l; | |
331 char *bufp; 332 char *bodytype; 333 char buf[MAXNAME + 1]; 334 char optbuf[MAXLINE]; 335 336 if (tTd(18, 2)) 337 printf("smtpmailfrom: CurHost=%s\n", CurHostName); 338 339 /* set up appropriate options to include */ | 330 char *bufp; 331 char *bodytype; 332 char buf[MAXNAME + 1]; 333 char optbuf[MAXLINE]; 334 335 if (tTd(18, 2)) 336 printf("smtpmailfrom: CurHost=%s\n", CurHostName); 337 338 /* set up appropriate options to include */ |
339 bufp = optbuf; |
|
340 if (bitset(MCIF_SIZE, mci->mci_flags) && e->e_msgsize > 0) 341 snprintf(optbuf, sizeof optbuf, " SIZE=%ld", e->e_msgsize); 342 else 343 strcpy(optbuf, ""); | 340 if (bitset(MCIF_SIZE, mci->mci_flags) && e->e_msgsize > 0) 341 snprintf(optbuf, sizeof optbuf, " SIZE=%ld", e->e_msgsize); 342 else 343 strcpy(optbuf, ""); |
344 l = sizeof optbuf - strlen(optbuf) - 1; | 344 bufp = &optbuf[strlen(optbuf)]; |
345 346 bodytype = e->e_bodytype; 347 if (bitset(MCIF_8BITMIME, mci->mci_flags)) 348 { 349 if (bodytype == NULL && 350 bitset(MM_MIME8BIT, MimeMode) && 351 bitset(EF_HAS8BIT, e->e_flags) && 352 !bitset(EF_DONT_MIME, e->e_flags) && 353 !bitnset(M_8BITS, m->m_flags)) 354 bodytype = "8BITMIME"; | 345 346 bodytype = e->e_bodytype; 347 if (bitset(MCIF_8BITMIME, mci->mci_flags)) 348 { 349 if (bodytype == NULL && 350 bitset(MM_MIME8BIT, MimeMode) && 351 bitset(EF_HAS8BIT, e->e_flags) && 352 !bitset(EF_DONT_MIME, e->e_flags) && 353 !bitnset(M_8BITS, m->m_flags)) 354 bodytype = "8BITMIME"; |
355 if (bodytype != NULL && strlen(bodytype) + 7 < l) | 355 if (bodytype != NULL && 356 SPACELEFT(optbuf, bufp) > strlen(bodytype) + 7) |
356 { | 357 { |
357 strcat(optbuf, " BODY="); 358 strcat(optbuf, bodytype); 359 l -= strlen(optbuf); | 358 snprintf(bufp, SPACELEFT(optbuf, bufp), 359 " BODY=%s", bodytype); 360 bufp += strlen(bufp); |
360 } 361 } 362 else if (bitnset(M_8BITS, m->m_flags) || 363 !bitset(EF_HAS8BIT, e->e_flags) || 364 bitset(MCIF_8BITOK, mci->mci_flags)) 365 { 366 /* just pass it through */ 367 } --- 14 unchanged lines hidden (view full) --- 382 383 usrerr("%s does not support 8BITMIME", CurHostName); 384 mci_setstat(mci, EX_NOTSTICKY, "5.6.3", MsgBuf); 385 return EX_DATAERR; 386 } 387 388 if (bitset(MCIF_DSN, mci->mci_flags)) 389 { | 361 } 362 } 363 else if (bitnset(M_8BITS, m->m_flags) || 364 !bitset(EF_HAS8BIT, e->e_flags) || 365 bitset(MCIF_8BITOK, mci->mci_flags)) 366 { 367 /* just pass it through */ 368 } --- 14 unchanged lines hidden (view full) --- 383 384 usrerr("%s does not support 8BITMIME", CurHostName); 385 mci_setstat(mci, EX_NOTSTICKY, "5.6.3", MsgBuf); 386 return EX_DATAERR; 387 } 388 389 if (bitset(MCIF_DSN, mci->mci_flags)) 390 { |
390 if (e->e_envid != NULL && strlen(e->e_envid) < (SIZE_T) (l - 7)) | 391 if (e->e_envid != NULL && 392 SPACELEFT(optbuf, bufp) > strlen(e->e_envid) + 7) |
391 { | 393 { |
392 strcat(optbuf, " ENVID="); 393 strcat(optbuf, e->e_envid); 394 l -= strlen(optbuf); | 394 snprintf(bufp, SPACELEFT(optbuf, bufp), 395 " ENVID=%s", e->e_envid); 396 bufp += strlen(bufp); |
395 } 396 397 /* RET= parameter */ | 397 } 398 399 /* RET= parameter */ |
398 if (bitset(EF_RET_PARAM, e->e_flags) && l >= 9) | 400 if (bitset(EF_RET_PARAM, e->e_flags) && 401 SPACELEFT(optbuf, bufp) > 9) |
399 { | 402 { |
400 strcat(optbuf, " RET="); 401 if (bitset(EF_NO_BODY_RETN, e->e_flags)) 402 strcat(optbuf, "HDRS"); 403 else 404 strcat(optbuf, "FULL"); 405 l -= 9; | 403 snprintf(bufp, SPACELEFT(optbuf, bufp), 404 " RET=%s", 405 bitset(EF_NO_BODY_RETN, e->e_flags) ? 406 "HDRS" : "FULL"); 407 bufp += strlen(bufp); |
406 } 407 } 408 409 /* 410 ** Send the MAIL command. 411 ** Designates the sender. 412 */ 413 --- 110 unchanged lines hidden (view full) --- 524int 525smtprcpt(to, m, mci, e) 526 ADDRESS *to; 527 register MAILER *m; 528 MCI *mci; 529 ENVELOPE *e; 530{ 531 register int r; | 408 } 409 } 410 411 /* 412 ** Send the MAIL command. 413 ** Designates the sender. 414 */ 415 --- 110 unchanged lines hidden (view full) --- 526int 527smtprcpt(to, m, mci, e) 528 ADDRESS *to; 529 register MAILER *m; 530 MCI *mci; 531 ENVELOPE *e; 532{ 533 register int r; |
532 int l; | 534 char *bufp; |
533 char optbuf[MAXLINE]; 534 535 strcpy(optbuf, ""); | 535 char optbuf[MAXLINE]; 536 537 strcpy(optbuf, ""); |
536 l = sizeof optbuf - 1; | 538 bufp = &optbuf[strlen(optbuf)]; |
537 if (bitset(MCIF_DSN, mci->mci_flags)) 538 { 539 /* NOTIFY= parameter */ 540 if (bitset(QHASNOTIFY, to->q_flags) && 541 bitset(QPRIMARY, to->q_flags) && 542 !bitnset(M_LOCALMAILER, m->m_flags)) 543 { 544 bool firstone = TRUE; 545 | 539 if (bitset(MCIF_DSN, mci->mci_flags)) 540 { 541 /* NOTIFY= parameter */ 542 if (bitset(QHASNOTIFY, to->q_flags) && 543 bitset(QPRIMARY, to->q_flags) && 544 !bitnset(M_LOCALMAILER, m->m_flags)) 545 { 546 bool firstone = TRUE; 547 |
546 strcat(optbuf, " NOTIFY="); | 548 strcat(bufp, " NOTIFY="); |
547 if (bitset(QPINGONSUCCESS, to->q_flags)) 548 { | 549 if (bitset(QPINGONSUCCESS, to->q_flags)) 550 { |
549 strcat(optbuf, "SUCCESS"); | 551 strcat(bufp, "SUCCESS"); |
550 firstone = FALSE; 551 } 552 if (bitset(QPINGONFAILURE, to->q_flags)) 553 { 554 if (!firstone) | 552 firstone = FALSE; 553 } 554 if (bitset(QPINGONFAILURE, to->q_flags)) 555 { 556 if (!firstone) |
555 strcat(optbuf, ","); 556 strcat(optbuf, "FAILURE"); | 557 strcat(bufp, ","); 558 strcat(bufp, "FAILURE"); |
557 firstone = FALSE; 558 } 559 if (bitset(QPINGONDELAY, to->q_flags)) 560 { 561 if (!firstone) | 559 firstone = FALSE; 560 } 561 if (bitset(QPINGONDELAY, to->q_flags)) 562 { 563 if (!firstone) |
562 strcat(optbuf, ","); 563 strcat(optbuf, "DELAY"); | 564 strcat(bufp, ","); 565 strcat(bufp, "DELAY"); |
564 firstone = FALSE; 565 } 566 if (firstone) | 566 firstone = FALSE; 567 } 568 if (firstone) |
567 strcat(optbuf, "NEVER"); 568 l -= strlen(optbuf); | 569 strcat(bufp, "NEVER"); 570 bufp += strlen(bufp); |
569 } 570 571 /* ORCPT= parameter */ | 571 } 572 573 /* ORCPT= parameter */ |
572 if (to->q_orcpt != NULL && strlen(to->q_orcpt) + 7 < l) | 574 if (to->q_orcpt != NULL && 575 SPACELEFT(optbuf, bufp) > strlen(to->q_orcpt) + 7) |
573 { | 576 { |
574 strcat(optbuf, " ORCPT="); 575 strcat(optbuf, to->q_orcpt); 576 l -= strlen(optbuf); | 577 snprintf(bufp, SPACELEFT(optbuf, bufp), 578 " ORCPT=%s", to->q_orcpt); 579 bufp += strlen(bufp); |
577 } 578 } 579 580 smtpmessage("RCPT To:<%s>%s", m, mci, to->q_user, optbuf); 581 582 SmtpPhase = mci->mci_phase = "client RCPT"; 583 sm_setproctitle(TRUE, "%s %s: %s", e->e_id, CurHostName, mci->mci_phase); 584 r = reply(m, mci, e, TimeOuts.to_rcpt, NULL); --- 83 unchanged lines hidden (view full) --- 668 smtpquit(m, mci, e); 669 return EX_TEMPFAIL; 670 } 671 else if (REPLYTYPE(r) == 5) 672 { 673 smtprset(m, mci, e); 674 return EX_UNAVAILABLE; 675 } | 580 } 581 } 582 583 smtpmessage("RCPT To:<%s>%s", m, mci, to->q_user, optbuf); 584 585 SmtpPhase = mci->mci_phase = "client RCPT"; 586 sm_setproctitle(TRUE, "%s %s: %s", e->e_id, CurHostName, mci->mci_phase); 587 r = reply(m, mci, e, TimeOuts.to_rcpt, NULL); --- 83 unchanged lines hidden (view full) --- 671 smtpquit(m, mci, e); 672 return EX_TEMPFAIL; 673 } 674 else if (REPLYTYPE(r) == 5) 675 { 676 smtprset(m, mci, e); 677 return EX_UNAVAILABLE; 678 } |
676 else if (r != 354) | 679 else if (REPLYTYPE(r) != 3) |
677 { 678 if (LogLevel > 1) 679 { 680 sm_syslog(LOG_CRIT, e->e_id, 681 "%.100s: SMTP DATA-1 protocol error: %s", 682 CurHostName, 683 shortenstring(SmtpReplyBuffer, 403)); 684 } --- 23 unchanged lines hidden (view full) --- 708 timeout = (time_t) 600; 709 timeout += e->e_nrcpts * 300; 710 ev = setevent(timeout, datatimeout, 0); 711 712 /* 713 ** Output the actual message. 714 */ 715 | 680 { 681 if (LogLevel > 1) 682 { 683 sm_syslog(LOG_CRIT, e->e_id, 684 "%.100s: SMTP DATA-1 protocol error: %s", 685 CurHostName, 686 shortenstring(SmtpReplyBuffer, 403)); 687 } --- 23 unchanged lines hidden (view full) --- 711 timeout = (time_t) 600; 712 timeout += e->e_nrcpts * 300; 713 ev = setevent(timeout, datatimeout, 0); 714 715 /* 716 ** Output the actual message. 717 */ 718 |
716 (*e->e_puthdr)(mci, e->e_header, e); | 719 (*e->e_puthdr)(mci, e->e_header, e, M87F_OUTER); |
717 (*e->e_putbody)(mci, e, NULL); 718 719 /* 720 ** Cleanup after sending message. 721 */ 722 723 clrevent(ev); 724 --- 445 unchanged lines hidden --- | 720 (*e->e_putbody)(mci, e, NULL); 721 722 /* 723 ** Cleanup after sending message. 724 */ 725 726 clrevent(ev); 727 --- 445 unchanged lines hidden --- |