1 --- ssmtp-2.61.orig/ssmtp.conf
2 +++ ssmtp-2.61/ssmtp.conf
5 # Use this RSA certificate.
6 #TLSCert=/etc/ssl/certs/ssmtp.pem
8 +# Get enhanced (*really* enhanced) debugging information in the logs
9 +# If you want to have debugging of the config file parsing, move this option
10 +# to the top of the config file and uncomment
12 --- ssmtp-2.61.orig/ssmtp.c
13 +++ ssmtp-2.61/ssmtp.c
15 static char hextab[]="0123456789abcdef";
21 log_event() -- Write event to syslog (or log file if defined)
26 -void smtp_write(int fd, char *format, ...);
27 +ssize_t smtp_write(int fd, char *format, ...);
28 int smtp_read(int fd, char *response);
29 int smtp_read_all(int fd, char *response);
30 int smtp_okay(int fd, char *response);
32 if(isatty(fileno(stdin))) {
35 - "stdin is a TTY - not saving to %s/dead.letter, pw->pw_dir");
36 + "stdin is a TTY - not saving to %s/dead.letter", pw->pw_dir);
41 log_event(LOG_INFO, "Set AuthMethod=\"%s\"\n", auth_method);
44 + else if (strcasecmp(p, "Debug") == 0)
46 + if (strcasecmp(q, "YES") == 0)
56 log_event(LOG_INFO, "Unable to set %s=\"%s\"\n", p, q);
58 @@ -1232,10 +1244,11 @@
60 smtp_write() -- A printf to an fd and append <CR/LF>
62 -void smtp_write(int fd, char *format, ...)
63 +ssize_t smtp_write(int fd, char *format, ...)
65 char buf[(BUF_SZ + 1)];
67 + ssize_t outbytes = 0;
70 if(vsnprintf(buf, (BUF_SZ - 2), format, ap) == -1) {
73 (void)strcat(buf, "\r\n");
75 - (void)fd_puts(fd, buf, strlen(buf));
76 + outbytes = fd_puts(fd, buf, strlen(buf));
78 + return (outbytes >= 0) ? outbytes : 0;
89 if((pw = getpwuid(uid)) == (struct passwd *)NULL) {
90 die("Could not find password entry for UID %d", uid);
91 @@ -1335,10 +1352,10 @@
93 /* If user supplied username and password, then try ELHO */
95 - smtp_write(sock, "EHLO %s", hostname);
96 + outbytes += smtp_write(sock, "EHLO %s", hostname);
99 - smtp_write(sock, "HELO %s", hostname);
100 + outbytes += smtp_write(sock, "HELO %s", hostname);
102 (void)alarm((unsigned) MEDWAIT);
104 @@ -1354,7 +1371,7 @@
107 if(strcasecmp(auth_method, "cram-md5") == 0) {
108 - smtp_write(sock, "AUTH CRAM-MD5");
109 + outbytes += smtp_write(sock, "AUTH CRAM-MD5");
110 (void)alarm((unsigned) MEDWAIT);
112 if(smtp_read(sock, buf) != 3) {
113 @@ -1369,7 +1386,7 @@
115 memset(buf, 0, sizeof(buf));
116 to64frombits(buf, auth_user, strlen(auth_user));
117 - smtp_write(sock, "AUTH LOGIN %s", buf);
118 + outbytes += smtp_write(sock, "AUTH LOGIN %s", buf);
120 (void)alarm((unsigned) MEDWAIT);
121 if(smtp_read(sock, buf) != 3) {
122 @@ -1381,7 +1398,7 @@
126 - smtp_write(sock, "%s", buf);
127 + outbytes += smtp_write(sock, "%s", buf);
128 (void)alarm((unsigned) MEDWAIT);
130 if(smtp_okay(sock, buf) == False) {
131 @@ -1390,7 +1407,7 @@
134 /* Send "MAIL FROM:" line */
135 - smtp_write(sock, "MAIL FROM:<%s>", uad);
136 + outbytes += smtp_write(sock, "MAIL FROM:<%s>", uad);
138 (void)alarm((unsigned) MEDWAIT);
140 @@ -1408,7 +1425,7 @@
143 p = rcpt_remap(rt->string);
144 - smtp_write(sock, "RCPT TO:<%s>", p);
145 + outbytes += smtp_write(sock, "RCPT TO:<%s>", p);
147 (void)alarm((unsigned)MEDWAIT);
149 @@ -1425,7 +1442,7 @@
151 /* RFC822 Address -> "foo@bar" */
152 q = rcpt_remap(addr_parse(p));
153 - smtp_write(sock, "RCPT TO:<%s>", q);
154 + outbytes += smtp_write(sock, "RCPT TO:<%s>", q);
156 (void)alarm((unsigned) MEDWAIT);
158 @@ -1439,7 +1456,7 @@
162 - smtp_write(sock, "DATA");
163 + outbytes += smtp_write(sock, "DATA");
164 (void)alarm((unsigned) MEDWAIT);
166 if(smtp_read(sock, buf) != 3) {
167 @@ -1447,45 +1464,45 @@
172 + outbytes += smtp_write(sock,
173 "Received: by %s (sSMTP sendmail emulation); %s", hostname, arpadate);
175 if(have_from == False) {
176 - smtp_write(sock, "From: %s", from);
177 + outbytes += smtp_write(sock, "From: %s", from);
180 if(have_date == False) {
181 - smtp_write(sock, "Date: %s", arpadate);
182 + outbytes += smtp_write(sock, "Date: %s", arpadate);
186 if(have_to == False) {
187 - smtp_write(sock, "To: postmaster");
188 + outbytes += smtp_write(sock, "To: postmaster");
194 - smtp_write(sock, "%s", ht->string);
195 + outbytes += smtp_write(sock, "%s", ht->string);
199 (void)alarm((unsigned) MEDWAIT);
201 /* End of headers, start body */
202 - smtp_write(sock, "");
203 + outbytes += smtp_write(sock, "");
205 while(fgets(buf, sizeof(buf), stdin)) {
206 /* Trim off \n, double leading .'s */
209 - smtp_write(sock, "%s", buf);
210 + outbytes += smtp_write(sock, "%s", buf);
212 (void)alarm((unsigned) MEDWAIT);
216 - smtp_write(sock, ".");
217 + outbytes += smtp_write(sock, ".");
218 (void)alarm((unsigned) MAXWAIT);
220 if(smtp_okay(sock, buf) == 0) {
221 @@ -1495,11 +1512,12 @@
222 /* Close conection */
223 (void)signal(SIGALRM, SIG_IGN);
225 - smtp_write(sock, "QUIT");
226 + outbytes += smtp_write(sock, "QUIT");
227 (void)smtp_okay(sock, buf);
230 - log_event(LOG_INFO, "Sent mail for %s (%s)", from_strip(uad), buf);
231 + log_event(LOG_INFO, "Sent mail for %s (%s) uid=%d username=%s outbytes=%d",
232 + from_strip(uad), buf, uid, pw->pw_name, outbytes);
236 --- ssmtp-2.61.orig/configure.in
237 +++ ssmtp-2.61/configure.in
241 dnl Checks for libraries.
242 -AC_CHECK_LIB(nsl, gethostname)
243 -AC_CHECK_LIB(socket, socket)
244 +AC_SEARCH_LIBS(gethostname, nsl)
245 +AC_SEARCH_LIBS(socket, socket)
247 dnl Checks for library functions.