You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
2.3 KiB

  1. --- a/ssmtp.c
  2. +++ b/ssmtp.c
  3. @@ -138,71 +138,7 @@ int smtp_read_all(int fd, char *response
  4. int smtp_okay(int fd, char *response);
  5. /*
  6. -dead_letter() -- Save stdin to ~/dead.letter if possible
  7. -*/
  8. -void dead_letter(void)
  9. -{
  10. - char *path;
  11. - char buf[(BUF_SZ + 1)];
  12. - struct passwd *pw;
  13. - uid_t uid;
  14. - FILE *fp;
  15. -
  16. - uid = getuid();
  17. - pw = getpwuid(uid);
  18. -
  19. - if(isatty(fileno(stdin))) {
  20. - if(log_level > 0) {
  21. - log_event(LOG_ERR,
  22. - "stdin is a TTY - not saving to %s/dead.letter", pw->pw_dir);
  23. - }
  24. - return;
  25. - }
  26. -
  27. - if(pw == (struct passwd *)NULL) {
  28. - /* Far to early to save things */
  29. - if(log_level > 0) {
  30. - log_event(LOG_ERR, "No sender failing horribly!");
  31. - }
  32. - return;
  33. - }
  34. -
  35. -#define DEAD_LETTER "/dead.letter"
  36. - path = malloc (strlen (pw->pw_dir) + sizeof (DEAD_LETTER));
  37. - if (!path) {
  38. - /* Can't use die() here since dead_letter() is called from die() */
  39. - exit(1);
  40. - }
  41. - memcpy (path, pw->pw_dir, strlen (pw->pw_dir));
  42. - memcpy (path + strlen (pw->pw_dir), DEAD_LETTER, sizeof (DEAD_LETTER));
  43. -
  44. - if((fp = fopen(path, "a")) == (FILE *)NULL) {
  45. - /* Perhaps the person doesn't have a homedir... */
  46. - if(log_level > 0) {
  47. - log_event(LOG_ERR, "Can't open %s failing horribly!", path);
  48. - }
  49. - free(path);
  50. - return;
  51. - }
  52. -
  53. - /* We start on a new line with a blank line separating messages */
  54. - (void)fprintf(fp, "\n\n");
  55. -
  56. - while(fgets(buf, sizeof(buf), stdin)) {
  57. - (void)fputs(buf, fp);
  58. - }
  59. -
  60. - if(fclose(fp) == -1) {
  61. - if(log_level > 0) {
  62. - log_event(LOG_ERR,
  63. - "Can't close %s/dead.letter, possibly truncated", pw->pw_dir);
  64. - }
  65. - }
  66. - free(path);
  67. -}
  68. -
  69. -/*
  70. -die() -- Write error message, dead.letter and exit
  71. +die() -- Write error message and exit
  72. */
  73. void die(char *format, ...)
  74. {
  75. @@ -216,9 +152,6 @@ void die(char *format, ...)
  76. (void)fprintf(stderr, "%s: %s\n", prog, buf);
  77. log_event(LOG_ERR, "%s", buf);
  78. - /* Send message to dead.letter */
  79. - (void)dead_letter();
  80. -
  81. exit(1);
  82. }
  83. @@ -1640,7 +1573,7 @@ int ssmtp(char *argv[])
  84. sleep(1);
  85. /* don't hang forever when reading from stdin */
  86. if (++timeout >= MEDWAIT) {
  87. - log_event(LOG_ERR, "killed: timeout on stdin while reading body -- message saved to dead.letter.");
  88. + log_event(LOG_ERR, "killed: timeout on stdin while reading body.");
  89. die("Timeout on stdin while reading body");
  90. }
  91. continue;