1 Index: ssmtp-2.61/ssmtp.conf
2 ===================================================================
3 --- ssmtp-2.61.orig/ssmtp.conf 2007-08-30 20:56:56.000000000 +0200
4 +++ ssmtp-2.61/ssmtp.conf 2007-08-30 20:56:56.000000000 +0200
7 # Use this RSA certificate.
8 #TLSCert=/etc/ssl/certs/ssmtp.pem
10 +# Get enhanced (*really* enhanced) debugging information in the logs
11 +# If you want to have debugging of the config file parsing, move this option
12 +# to the top of the config file and uncomment
14 Index: ssmtp-2.61/ssmtp.c
15 ===================================================================
16 --- ssmtp-2.61.orig/ssmtp.c 2007-08-30 20:56:56.000000000 +0200
17 +++ ssmtp-2.61/ssmtp.c 2007-08-30 20:56:56.000000000 +0200
19 static char hextab[]="0123456789abcdef";
25 log_event() -- Write event to syslog (or log file if defined)
30 -void smtp_write(int fd, char *format, ...);
31 +ssize_t smtp_write(int fd, char *format, ...);
32 int smtp_read(int fd, char *response);
33 int smtp_read_all(int fd, char *response);
34 int smtp_okay(int fd, char *response);
36 if(isatty(fileno(stdin))) {
39 - "stdin is a TTY - not saving to %s/dead.letter, pw->pw_dir");
40 + "stdin is a TTY - not saving to %s/dead.letter", pw->pw_dir);
45 log_event(LOG_INFO, "Set AuthMethod=\"%s\"\n", auth_method);
48 + else if (strcasecmp(p, "Debug") == 0)
50 + if (strcasecmp(q, "YES") == 0)
60 log_event(LOG_INFO, "Unable to set %s=\"%s\"\n", p, q);
62 @@ -1232,10 +1244,11 @@
64 smtp_write() -- A printf to an fd and append <CR/LF>
66 -void smtp_write(int fd, char *format, ...)
67 +ssize_t smtp_write(int fd, char *format, ...)
69 char buf[(BUF_SZ + 1)];
71 + ssize_t outbytes = 0;
74 if(vsnprintf(buf, (BUF_SZ - 2), format, ap) == -1) {
77 (void)strcat(buf, "\r\n");
79 - (void)fd_puts(fd, buf, strlen(buf));
80 + outbytes = fd_puts(fd, buf, strlen(buf));
82 + return (outbytes >= 0) ? outbytes : 0;
93 if((pw = getpwuid(uid)) == (struct passwd *)NULL) {
94 die("Could not find password entry for UID %d", uid);
95 @@ -1335,10 +1352,10 @@
97 /* If user supplied username and password, then try ELHO */
99 - smtp_write(sock, "EHLO %s", hostname);
100 + outbytes += smtp_write(sock, "EHLO %s", hostname);
103 - smtp_write(sock, "HELO %s", hostname);
104 + outbytes += smtp_write(sock, "HELO %s", hostname);
106 (void)alarm((unsigned) MEDWAIT);
108 @@ -1354,7 +1371,7 @@
111 if(strcasecmp(auth_method, "cram-md5") == 0) {
112 - smtp_write(sock, "AUTH CRAM-MD5");
113 + outbytes += smtp_write(sock, "AUTH CRAM-MD5");
114 (void)alarm((unsigned) MEDWAIT);
116 if(smtp_read(sock, buf) != 3) {
117 @@ -1369,7 +1386,7 @@
119 memset(buf, 0, sizeof(buf));
120 to64frombits(buf, auth_user, strlen(auth_user));
121 - smtp_write(sock, "AUTH LOGIN %s", buf);
122 + outbytes += smtp_write(sock, "AUTH LOGIN %s", buf);
124 (void)alarm((unsigned) MEDWAIT);
125 if(smtp_read(sock, buf) != 3) {
126 @@ -1381,7 +1398,7 @@
130 - smtp_write(sock, "%s", buf);
131 + outbytes += smtp_write(sock, "%s", buf);
132 (void)alarm((unsigned) MEDWAIT);
134 if(smtp_okay(sock, buf) == False) {
135 @@ -1390,7 +1407,7 @@
138 /* Send "MAIL FROM:" line */
139 - smtp_write(sock, "MAIL FROM:<%s>", uad);
140 + outbytes += smtp_write(sock, "MAIL FROM:<%s>", uad);
142 (void)alarm((unsigned) MEDWAIT);
144 @@ -1408,7 +1425,7 @@
147 p = rcpt_remap(rt->string);
148 - smtp_write(sock, "RCPT TO:<%s>", p);
149 + outbytes += smtp_write(sock, "RCPT TO:<%s>", p);
151 (void)alarm((unsigned)MEDWAIT);
153 @@ -1425,7 +1442,7 @@
155 /* RFC822 Address -> "foo@bar" */
156 q = rcpt_remap(addr_parse(p));
157 - smtp_write(sock, "RCPT TO:<%s>", q);
158 + outbytes += smtp_write(sock, "RCPT TO:<%s>", q);
160 (void)alarm((unsigned) MEDWAIT);
162 @@ -1439,7 +1456,7 @@
166 - smtp_write(sock, "DATA");
167 + outbytes += smtp_write(sock, "DATA");
168 (void)alarm((unsigned) MEDWAIT);
170 if(smtp_read(sock, buf) != 3) {
171 @@ -1447,45 +1464,45 @@
176 + outbytes += smtp_write(sock,
177 "Received: by %s (sSMTP sendmail emulation); %s", hostname, arpadate);
179 if(have_from == False) {
180 - smtp_write(sock, "From: %s", from);
181 + outbytes += smtp_write(sock, "From: %s", from);
184 if(have_date == False) {
185 - smtp_write(sock, "Date: %s", arpadate);
186 + outbytes += smtp_write(sock, "Date: %s", arpadate);
190 if(have_to == False) {
191 - smtp_write(sock, "To: postmaster");
192 + outbytes += smtp_write(sock, "To: postmaster");
198 - smtp_write(sock, "%s", ht->string);
199 + outbytes += smtp_write(sock, "%s", ht->string);
203 (void)alarm((unsigned) MEDWAIT);
205 /* End of headers, start body */
206 - smtp_write(sock, "");
207 + outbytes += smtp_write(sock, "");
209 while(fgets(buf, sizeof(buf), stdin)) {
210 /* Trim off \n, double leading .'s */
213 - smtp_write(sock, "%s", buf);
214 + outbytes += smtp_write(sock, "%s", buf);
216 (void)alarm((unsigned) MEDWAIT);
220 - smtp_write(sock, ".");
221 + outbytes += smtp_write(sock, ".");
222 (void)alarm((unsigned) MAXWAIT);
224 if(smtp_okay(sock, buf) == 0) {
225 @@ -1495,11 +1512,12 @@
226 /* Close conection */
227 (void)signal(SIGALRM, SIG_IGN);
229 - smtp_write(sock, "QUIT");
230 + outbytes += smtp_write(sock, "QUIT");
231 (void)smtp_okay(sock, buf);
234 - log_event(LOG_INFO, "Sent mail for %s (%s)", from_strip(uad), buf);
235 + log_event(LOG_INFO, "Sent mail for %s (%s) uid=%d username=%s outbytes=%d",
236 + from_strip(uad), buf, uid, pw->pw_name, outbytes);
240 Index: ssmtp-2.61/configure.in
241 ===================================================================
242 --- ssmtp-2.61.orig/configure.in 2007-08-30 20:56:56.000000000 +0200
243 +++ ssmtp-2.61/configure.in 2007-08-30 20:56:56.000000000 +0200
247 dnl Checks for libraries.
248 -AC_CHECK_LIB(nsl, gethostname)
249 -AC_CHECK_LIB(socket, socket)
250 +AC_SEARCH_LIBS(gethostname, nsl)
251 +AC_SEARCH_LIBS(socket, socket)
253 dnl Checks for library functions.