500-debian-subset-2.61-2.patch 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. --- ssmtp-2.61.orig/ssmtp.conf
  2. +++ ssmtp-2.61/ssmtp.conf
  3. @@ -36,3 +36,8 @@
  4. # Use this RSA certificate.
  5. #TLSCert=/etc/ssl/certs/ssmtp.pem
  6. +
  7. +# Get enhanced (*really* enhanced) debugging information in the logs
  8. +# If you want to have debugging of the config file parsing, move this option
  9. +# to the top of the config file and uncomment
  10. +#Debug=YES
  11. --- ssmtp-2.61.orig/ssmtp.c
  12. +++ ssmtp-2.61/ssmtp.c
  13. @@ -93,6 +93,7 @@
  14. static char hextab[]="0123456789abcdef";
  15. #endif
  16. +ssize_t outbytes;
  17. /*
  18. log_event() -- Write event to syslog (or log file if defined)
  19. @@ -129,7 +130,7 @@
  20. #endif
  21. }
  22. -void smtp_write(int fd, char *format, ...);
  23. +ssize_t smtp_write(int fd, char *format, ...);
  24. int smtp_read(int fd, char *response);
  25. int smtp_read_all(int fd, char *response);
  26. int smtp_okay(int fd, char *response);
  27. @@ -150,7 +151,7 @@
  28. if(isatty(fileno(stdin))) {
  29. if(log_level > 0) {
  30. log_event(LOG_ERR,
  31. - "stdin is a TTY - not saving to %s/dead.letter, pw->pw_dir");
  32. + "stdin is a TTY - not saving to %s/dead.letter", pw->pw_dir);
  33. }
  34. return;
  35. }
  36. @@ -964,6 +965,17 @@
  37. log_event(LOG_INFO, "Set AuthMethod=\"%s\"\n", auth_method);
  38. }
  39. }
  40. + else if (strcasecmp(p, "Debug") == 0)
  41. + {
  42. + if (strcasecmp(q, "YES") == 0)
  43. + {
  44. + log_level = 1;
  45. + }
  46. + else
  47. + {
  48. + log_level = 0;
  49. + }
  50. + }
  51. else {
  52. log_event(LOG_INFO, "Unable to set %s=\"%s\"\n", p, q);
  53. }
  54. @@ -1232,10 +1244,11 @@
  55. /*
  56. smtp_write() -- A printf to an fd and append <CR/LF>
  57. */
  58. -void smtp_write(int fd, char *format, ...)
  59. +ssize_t smtp_write(int fd, char *format, ...)
  60. {
  61. char buf[(BUF_SZ + 1)];
  62. va_list ap;
  63. + ssize_t outbytes = 0;
  64. va_start(ap, format);
  65. if(vsnprintf(buf, (BUF_SZ - 2), format, ap) == -1) {
  66. @@ -1252,7 +1265,9 @@
  67. }
  68. (void)strcat(buf, "\r\n");
  69. - (void)fd_puts(fd, buf, strlen(buf));
  70. + outbytes = fd_puts(fd, buf, strlen(buf));
  71. +
  72. + return (outbytes >= 0) ? outbytes : 0;
  73. }
  74. /*
  75. @@ -1282,6 +1297,8 @@
  76. int i, sock;
  77. uid_t uid;
  78. + outbytes = 0;
  79. +
  80. uid = getuid();
  81. if((pw = getpwuid(uid)) == (struct passwd *)NULL) {
  82. die("Could not find password entry for UID %d", uid);
  83. @@ -1335,10 +1352,10 @@
  84. /* If user supplied username and password, then try ELHO */
  85. if(auth_user) {
  86. - smtp_write(sock, "EHLO %s", hostname);
  87. + outbytes += smtp_write(sock, "EHLO %s", hostname);
  88. }
  89. else {
  90. - smtp_write(sock, "HELO %s", hostname);
  91. + outbytes += smtp_write(sock, "HELO %s", hostname);
  92. }
  93. (void)alarm((unsigned) MEDWAIT);
  94. @@ -1354,7 +1371,7 @@
  95. }
  96. if(strcasecmp(auth_method, "cram-md5") == 0) {
  97. - smtp_write(sock, "AUTH CRAM-MD5");
  98. + outbytes += smtp_write(sock, "AUTH CRAM-MD5");
  99. (void)alarm((unsigned) MEDWAIT);
  100. if(smtp_read(sock, buf) != 3) {
  101. @@ -1369,7 +1386,7 @@
  102. #endif
  103. memset(buf, 0, sizeof(buf));
  104. to64frombits(buf, auth_user, strlen(auth_user));
  105. - smtp_write(sock, "AUTH LOGIN %s", buf);
  106. + outbytes += smtp_write(sock, "AUTH LOGIN %s", buf);
  107. (void)alarm((unsigned) MEDWAIT);
  108. if(smtp_read(sock, buf) != 3) {
  109. @@ -1381,7 +1398,7 @@
  110. #ifdef MD5AUTH
  111. }
  112. #endif
  113. - smtp_write(sock, "%s", buf);
  114. + outbytes += smtp_write(sock, "%s", buf);
  115. (void)alarm((unsigned) MEDWAIT);
  116. if(smtp_okay(sock, buf) == False) {
  117. @@ -1390,7 +1407,7 @@
  118. }
  119. /* Send "MAIL FROM:" line */
  120. - smtp_write(sock, "MAIL FROM:<%s>", uad);
  121. + outbytes += smtp_write(sock, "MAIL FROM:<%s>", uad);
  122. (void)alarm((unsigned) MEDWAIT);
  123. @@ -1408,7 +1425,7 @@
  124. while(rt->next) {
  125. p = rcpt_remap(rt->string);
  126. - smtp_write(sock, "RCPT TO:<%s>", p);
  127. + outbytes += smtp_write(sock, "RCPT TO:<%s>", p);
  128. (void)alarm((unsigned)MEDWAIT);
  129. @@ -1425,7 +1442,7 @@
  130. while(p) {
  131. /* RFC822 Address -> "foo@bar" */
  132. q = rcpt_remap(addr_parse(p));
  133. - smtp_write(sock, "RCPT TO:<%s>", q);
  134. + outbytes += smtp_write(sock, "RCPT TO:<%s>", q);
  135. (void)alarm((unsigned) MEDWAIT);
  136. @@ -1439,7 +1456,7 @@
  137. }
  138. /* Send DATA */
  139. - smtp_write(sock, "DATA");
  140. + outbytes += smtp_write(sock, "DATA");
  141. (void)alarm((unsigned) MEDWAIT);
  142. if(smtp_read(sock, buf) != 3) {
  143. @@ -1447,45 +1464,45 @@
  144. die("%s", buf);
  145. }
  146. - smtp_write(sock,
  147. + outbytes += smtp_write(sock,
  148. "Received: by %s (sSMTP sendmail emulation); %s", hostname, arpadate);
  149. if(have_from == False) {
  150. - smtp_write(sock, "From: %s", from);
  151. + outbytes += smtp_write(sock, "From: %s", from);
  152. }
  153. if(have_date == False) {
  154. - smtp_write(sock, "Date: %s", arpadate);
  155. + outbytes += smtp_write(sock, "Date: %s", arpadate);
  156. }
  157. #ifdef HASTO_OPTION
  158. if(have_to == False) {
  159. - smtp_write(sock, "To: postmaster");
  160. + outbytes += smtp_write(sock, "To: postmaster");
  161. }
  162. #endif
  163. ht = &headers;
  164. while(ht->next) {
  165. - smtp_write(sock, "%s", ht->string);
  166. + outbytes += smtp_write(sock, "%s", ht->string);
  167. ht = ht->next;
  168. }
  169. (void)alarm((unsigned) MEDWAIT);
  170. /* End of headers, start body */
  171. - smtp_write(sock, "");
  172. + outbytes += smtp_write(sock, "");
  173. while(fgets(buf, sizeof(buf), stdin)) {
  174. /* Trim off \n, double leading .'s */
  175. standardise(buf);
  176. - smtp_write(sock, "%s", buf);
  177. + outbytes += smtp_write(sock, "%s", buf);
  178. (void)alarm((unsigned) MEDWAIT);
  179. }
  180. /* End of body */
  181. - smtp_write(sock, ".");
  182. + outbytes += smtp_write(sock, ".");
  183. (void)alarm((unsigned) MAXWAIT);
  184. if(smtp_okay(sock, buf) == 0) {
  185. @@ -1495,11 +1512,12 @@
  186. /* Close conection */
  187. (void)signal(SIGALRM, SIG_IGN);
  188. - smtp_write(sock, "QUIT");
  189. + outbytes += smtp_write(sock, "QUIT");
  190. (void)smtp_okay(sock, buf);
  191. (void)close(sock);
  192. - log_event(LOG_INFO, "Sent mail for %s (%s)", from_strip(uad), buf);
  193. + log_event(LOG_INFO, "Sent mail for %s (%s) uid=%d username=%s outbytes=%d",
  194. + from_strip(uad), buf, uid, pw->pw_name, outbytes);
  195. return(0);
  196. }
  197. --- ssmtp-2.61.orig/configure.in
  198. +++ ssmtp-2.61/configure.in
  199. @@ -24,8 +24,8 @@
  200. AC_STRUCT_TM
  201. dnl Checks for libraries.
  202. -AC_CHECK_LIB(nsl, gethostname)
  203. -AC_CHECK_LIB(socket, socket)
  204. +AC_SEARCH_LIBS(gethostname, nsl)
  205. +AC_SEARCH_LIBS(socket, socket)
  206. dnl Checks for library functions.
  207. AC_TYPE_SIGNAL