| [475ad56] | 1 | --- ssmtp-2.61.orig/ssmtp.conf
|
|---|
| 2 | +++ ssmtp-2.61/ssmtp.conf
|
|---|
| 3 | @@ -36,3 +36,8 @@
|
|---|
| 4 |
|
|---|
| 5 | # Use this RSA certificate.
|
|---|
| 6 | #TLSCert=/etc/ssl/certs/ssmtp.pem
|
|---|
| 7 | +
|
|---|
| 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
|
|---|
| 11 | +#Debug=YES
|
|---|
| 12 | --- ssmtp-2.61.orig/ssmtp.c
|
|---|
| 13 | +++ ssmtp-2.61/ssmtp.c
|
|---|
| 14 | @@ -93,6 +93,7 @@
|
|---|
| 15 | static char hextab[]="0123456789abcdef";
|
|---|
| 16 | #endif
|
|---|
| 17 |
|
|---|
| 18 | +ssize_t outbytes;
|
|---|
| 19 |
|
|---|
| 20 | /*
|
|---|
| 21 | log_event() -- Write event to syslog (or log file if defined)
|
|---|
| 22 | @@ -129,7 +130,7 @@
|
|---|
| 23 | #endif
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 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);
|
|---|
| 31 | @@ -150,7 +151,7 @@
|
|---|
| 32 | if(isatty(fileno(stdin))) {
|
|---|
| 33 | if(log_level > 0) {
|
|---|
| 34 | log_event(LOG_ERR,
|
|---|
| 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);
|
|---|
| 37 | }
|
|---|
| 38 | return;
|
|---|
| 39 | }
|
|---|
| 40 | @@ -964,6 +965,17 @@
|
|---|
| 41 | log_event(LOG_INFO, "Set AuthMethod=\"%s\"\n", auth_method);
|
|---|
| 42 | }
|
|---|
| 43 | }
|
|---|
| 44 | + else if (strcasecmp(p, "Debug") == 0)
|
|---|
| 45 | + {
|
|---|
| 46 | + if (strcasecmp(q, "YES") == 0)
|
|---|
| 47 | + {
|
|---|
| 48 | + log_level = 1;
|
|---|
| 49 | + }
|
|---|
| 50 | + else
|
|---|
| 51 | + {
|
|---|
| 52 | + log_level = 0;
|
|---|
| 53 | + }
|
|---|
| 54 | + }
|
|---|
| 55 | else {
|
|---|
| 56 | log_event(LOG_INFO, "Unable to set %s=\"%s\"\n", p, q);
|
|---|
| 57 | }
|
|---|
| 58 | @@ -1232,10 +1244,11 @@
|
|---|
| 59 | /*
|
|---|
| 60 | smtp_write() -- A printf to an fd and append <CR/LF>
|
|---|
| 61 | */
|
|---|
| 62 | -void smtp_write(int fd, char *format, ...)
|
|---|
| 63 | +ssize_t smtp_write(int fd, char *format, ...)
|
|---|
| 64 | {
|
|---|
| 65 | char buf[(BUF_SZ + 1)];
|
|---|
| 66 | va_list ap;
|
|---|
| 67 | + ssize_t outbytes = 0;
|
|---|
| 68 |
|
|---|
| 69 | va_start(ap, format);
|
|---|
| 70 | if(vsnprintf(buf, (BUF_SZ - 2), format, ap) == -1) {
|
|---|
| 71 | @@ -1252,7 +1265,9 @@
|
|---|
| 72 | }
|
|---|
| 73 | (void)strcat(buf, "\r\n");
|
|---|
| 74 |
|
|---|
| 75 | - (void)fd_puts(fd, buf, strlen(buf));
|
|---|
| 76 | + outbytes = fd_puts(fd, buf, strlen(buf));
|
|---|
| 77 | +
|
|---|
| 78 | + return (outbytes >= 0) ? outbytes : 0;
|
|---|
| 79 | }
|
|---|
| 80 |
|
|---|
| 81 | /*
|
|---|
| 82 | @@ -1282,6 +1297,8 @@
|
|---|
| 83 | int i, sock;
|
|---|
| 84 | uid_t uid;
|
|---|
| 85 |
|
|---|
| 86 | + outbytes = 0;
|
|---|
| 87 | +
|
|---|
| 88 | uid = getuid();
|
|---|
| 89 | if((pw = getpwuid(uid)) == (struct passwd *)NULL) {
|
|---|
| 90 | die("Could not find password entry for UID %d", uid);
|
|---|
| 91 | @@ -1335,10 +1352,10 @@
|
|---|
| 92 |
|
|---|
| 93 | /* If user supplied username and password, then try ELHO */
|
|---|
| 94 | if(auth_user) {
|
|---|
| 95 | - smtp_write(sock, "EHLO %s", hostname);
|
|---|
| 96 | + outbytes += smtp_write(sock, "EHLO %s", hostname);
|
|---|
| 97 | }
|
|---|
| 98 | else {
|
|---|
| 99 | - smtp_write(sock, "HELO %s", hostname);
|
|---|
| 100 | + outbytes += smtp_write(sock, "HELO %s", hostname);
|
|---|
| 101 | }
|
|---|
| 102 | (void)alarm((unsigned) MEDWAIT);
|
|---|
| 103 |
|
|---|
| 104 | @@ -1354,7 +1371,7 @@
|
|---|
| 105 | }
|
|---|
| 106 |
|
|---|
| 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);
|
|---|
| 111 |
|
|---|
| 112 | if(smtp_read(sock, buf) != 3) {
|
|---|
| 113 | @@ -1369,7 +1386,7 @@
|
|---|
| 114 | #endif
|
|---|
| 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);
|
|---|
| 119 |
|
|---|
| 120 | (void)alarm((unsigned) MEDWAIT);
|
|---|
| 121 | if(smtp_read(sock, buf) != 3) {
|
|---|
| 122 | @@ -1381,7 +1398,7 @@
|
|---|
| 123 | #ifdef MD5AUTH
|
|---|
| 124 | }
|
|---|
| 125 | #endif
|
|---|
| 126 | - smtp_write(sock, "%s", buf);
|
|---|
| 127 | + outbytes += smtp_write(sock, "%s", buf);
|
|---|
| 128 | (void)alarm((unsigned) MEDWAIT);
|
|---|
| 129 |
|
|---|
| 130 | if(smtp_okay(sock, buf) == False) {
|
|---|
| 131 | @@ -1390,7 +1407,7 @@
|
|---|
| 132 | }
|
|---|
| 133 |
|
|---|
| 134 | /* Send "MAIL FROM:" line */
|
|---|
| 135 | - smtp_write(sock, "MAIL FROM:<%s>", uad);
|
|---|
| 136 | + outbytes += smtp_write(sock, "MAIL FROM:<%s>", uad);
|
|---|
| 137 |
|
|---|
| 138 | (void)alarm((unsigned) MEDWAIT);
|
|---|
| 139 |
|
|---|
| 140 | @@ -1408,7 +1425,7 @@
|
|---|
| 141 |
|
|---|
| 142 | while(rt->next) {
|
|---|
| 143 | p = rcpt_remap(rt->string);
|
|---|
| 144 | - smtp_write(sock, "RCPT TO:<%s>", p);
|
|---|
| 145 | + outbytes += smtp_write(sock, "RCPT TO:<%s>", p);
|
|---|
| 146 |
|
|---|
| 147 | (void)alarm((unsigned)MEDWAIT);
|
|---|
| 148 |
|
|---|
| 149 | @@ -1425,7 +1442,7 @@
|
|---|
| 150 | while(p) {
|
|---|
| 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);
|
|---|
| 155 |
|
|---|
| 156 | (void)alarm((unsigned) MEDWAIT);
|
|---|
| 157 |
|
|---|
| 158 | @@ -1439,7 +1456,7 @@
|
|---|
| 159 | }
|
|---|
| 160 |
|
|---|
| 161 | /* Send DATA */
|
|---|
| 162 | - smtp_write(sock, "DATA");
|
|---|
| 163 | + outbytes += smtp_write(sock, "DATA");
|
|---|
| 164 | (void)alarm((unsigned) MEDWAIT);
|
|---|
| 165 |
|
|---|
| 166 | if(smtp_read(sock, buf) != 3) {
|
|---|
| 167 | @@ -1447,45 +1464,45 @@
|
|---|
| 168 | die("%s", buf);
|
|---|
| 169 | }
|
|---|
| 170 |
|
|---|
| 171 | - smtp_write(sock,
|
|---|
| 172 | + outbytes += smtp_write(sock,
|
|---|
| 173 | "Received: by %s (sSMTP sendmail emulation); %s", hostname, arpadate);
|
|---|
| 174 |
|
|---|
| 175 | if(have_from == False) {
|
|---|
| 176 | - smtp_write(sock, "From: %s", from);
|
|---|
| 177 | + outbytes += smtp_write(sock, "From: %s", from);
|
|---|
| 178 | }
|
|---|
| 179 |
|
|---|
| 180 | if(have_date == False) {
|
|---|
| 181 | - smtp_write(sock, "Date: %s", arpadate);
|
|---|
| 182 | + outbytes += smtp_write(sock, "Date: %s", arpadate);
|
|---|
| 183 | }
|
|---|
| 184 |
|
|---|
| 185 | #ifdef HASTO_OPTION
|
|---|
| 186 | if(have_to == False) {
|
|---|
| 187 | - smtp_write(sock, "To: postmaster");
|
|---|
| 188 | + outbytes += smtp_write(sock, "To: postmaster");
|
|---|
| 189 | }
|
|---|
| 190 | #endif
|
|---|
| 191 |
|
|---|
| 192 | ht = &headers;
|
|---|
| 193 | while(ht->next) {
|
|---|
| 194 | - smtp_write(sock, "%s", ht->string);
|
|---|
| 195 | + outbytes += smtp_write(sock, "%s", ht->string);
|
|---|
| 196 | ht = ht->next;
|
|---|
| 197 | }
|
|---|
| 198 |
|
|---|
| 199 | (void)alarm((unsigned) MEDWAIT);
|
|---|
| 200 |
|
|---|
| 201 | /* End of headers, start body */
|
|---|
| 202 | - smtp_write(sock, "");
|
|---|
| 203 | + outbytes += smtp_write(sock, "");
|
|---|
| 204 |
|
|---|
| 205 | while(fgets(buf, sizeof(buf), stdin)) {
|
|---|
| 206 | /* Trim off \n, double leading .'s */
|
|---|
| 207 | standardise(buf);
|
|---|
| 208 |
|
|---|
| 209 | - smtp_write(sock, "%s", buf);
|
|---|
| 210 | + outbytes += smtp_write(sock, "%s", buf);
|
|---|
| 211 |
|
|---|
| 212 | (void)alarm((unsigned) MEDWAIT);
|
|---|
| 213 | }
|
|---|
| 214 | /* End of body */
|
|---|
| 215 |
|
|---|
| 216 | - smtp_write(sock, ".");
|
|---|
| 217 | + outbytes += smtp_write(sock, ".");
|
|---|
| 218 | (void)alarm((unsigned) MAXWAIT);
|
|---|
| 219 |
|
|---|
| 220 | if(smtp_okay(sock, buf) == 0) {
|
|---|
| 221 | @@ -1495,11 +1512,12 @@
|
|---|
| 222 | /* Close conection */
|
|---|
| 223 | (void)signal(SIGALRM, SIG_IGN);
|
|---|
| 224 |
|
|---|
| 225 | - smtp_write(sock, "QUIT");
|
|---|
| 226 | + outbytes += smtp_write(sock, "QUIT");
|
|---|
| 227 | (void)smtp_okay(sock, buf);
|
|---|
| 228 | (void)close(sock);
|
|---|
| 229 |
|
|---|
| 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);
|
|---|
| 233 |
|
|---|
| 234 | return(0);
|
|---|
| 235 | }
|
|---|
| 236 | --- ssmtp-2.61.orig/configure.in
|
|---|
| 237 | +++ ssmtp-2.61/configure.in
|
|---|
| 238 | @@ -24,8 +24,8 @@
|
|---|
| 239 | AC_STRUCT_TM
|
|---|
| 240 |
|
|---|
| 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)
|
|---|
| 246 |
|
|---|
| 247 | dnl Checks for library functions.
|
|---|
| 248 | AC_TYPE_SIGNAL
|
|---|