"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/mlmmj-send.c" between
mlmmj-1.2.19.0.tar.gz and mlmmj-1.3.0.tar.bz2

About: mlmmj is a mailing list manager similar to ezmlm, but with a decent license and mail server independency.

mlmmj-send.c  (mlmmj-1.2.19.0):mlmmj-send.c  (mlmmj-1.3.0.tar.bz2)
skipping to change at line 379 skipping to change at line 379
myfree(reply); myfree(reply);
write_rset(sockfd); write_rset(sockfd);
reply2 = checkwait_smtpreply(sockfd, MLMMJ_RSET); reply2 = checkwait_smtpreply(sockfd, MLMMJ_RSET);
if (reply2 != NULL) myfree(reply2); if (reply2 != NULL) myfree(reply2);
return MLMMJ_DOT; return MLMMJ_DOT;
} }
return 0; return 0;
} }
int initsmtp(int *sockfd, const char *relayhost, unsigned short port) int initsmtp(int *sockfd, const char *relayhost, unsigned short port, const char *heloname)
{ {
int retval = 0; int retval = 0;
int try_ehlo = 1; int try_ehlo = 1;
char *reply = NULL; char *reply = NULL;
char *myhostname = hostnamestr();
do { do {
init_sockfd(sockfd, relayhost, port); init_sockfd(sockfd, relayhost, port);
if(*sockfd == -1) { if(*sockfd == -1) {
retval = EBADF; retval = EBADF;
break; break;
} }
if((reply = checkwait_smtpreply(*sockfd, MLMMJ_CONNECT)) != NULL) { if((reply = checkwait_smtpreply(*sockfd, MLMMJ_CONNECT)) != NULL) {
log_error(LOG_ARGS, "No proper greeting to our connect" log_error(LOG_ARGS, "No proper greeting to our connect"
"Reply: [%s]", reply); "Reply: [%s]", reply);
myfree(reply); myfree(reply);
retval = MLMMJ_CONNECT; retval = MLMMJ_CONNECT;
/* FIXME: Queue etc. */ /* FIXME: Queue etc. */
break; break;
} }
if (try_ehlo) { if (try_ehlo) {
write_ehlo(*sockfd, myhostname); write_ehlo(*sockfd, heloname);
if((reply = checkwait_smtpreply(*sockfd, MLMMJ_EHLO)) if((reply = checkwait_smtpreply(*sockfd, MLMMJ_EHLO))
== NULL) { == NULL) {
/* EHLO successful don't try more */ /* EHLO successful don't try more */
break; break;
} }
/* RFC 1869 - 4.5. - In the case of any error response, /* RFC 1869 - 4.5. - In the case of any error response,
* the client SMTP should issue either the HELO or QUIT * the client SMTP should issue either the HELO or QUIT
* command. * command.
* RFC 1869 - 4.5. - If the server SMTP recognizes the * RFC 1869 - 4.5. - If the server SMTP recognizes the
skipping to change at line 471 skipping to change at line 470
* aware that many implementations will return a failure * aware that many implementations will return a failure
* code (e.g., 503 Bad sequence of commands) in response * code (e.g., 503 Bad sequence of commands) in response
* to the RSET. This code can be safely ignored. * to the RSET. This code can be safely ignored.
*/ */
myfree(reply); myfree(reply);
/* Try HELO on the same connection /* Try HELO on the same connection
*/ */
} }
write_helo(*sockfd, myhostname); write_helo(*sockfd, heloname);
if((reply = checkwait_smtpreply(*sockfd, MLMMJ_HELO)) if((reply = checkwait_smtpreply(*sockfd, MLMMJ_HELO))
== NULL) { == NULL) {
/* EHLO successful don't try more */ /* EHLO successful don't try more */
break; break;
} }
if (try_ehlo) { if (try_ehlo) {
myfree(reply); myfree(reply);
/* We reused a connection we tried EHLO on. Maybe /* We reused a connection we tried EHLO on. Maybe
* that's why it failed. Try with new connection. * that's why it failed. Try with new connection.
*/ */
skipping to change at line 497 skipping to change at line 496
log_error(LOG_ARGS, "Error with HELO. Reply: " log_error(LOG_ARGS, "Error with HELO. Reply: "
"[%s]", reply); "[%s]", reply);
myfree(reply); myfree(reply);
/* FIXME: quit and tell admin to configure /* FIXME: quit and tell admin to configure
* correctly */ * correctly */
retval = MLMMJ_HELO; retval = MLMMJ_HELO;
break; break;
} while (1); } while (1);
myfree(myhostname);
return retval; return retval;
} }
int endsmtp(int *sockfd) int endsmtp(int *sockfd)
{ {
int retval = 0; int retval = 0;
char *reply = NULL; char *reply = NULL;
if(*sockfd == -1) if(*sockfd == -1)
return retval; return retval;
skipping to change at line 823 skipping to change at line 821
int deletewhensent = 1, sendres = 0, archive = 1, digest = 0; int deletewhensent = 1, sendres = 0, archive = 1, digest = 0;
int ctrlarchive, res; int ctrlarchive, res;
char *listaddr = NULL, *listdelim = NULL; char *listaddr = NULL, *listdelim = NULL;
char *mailfilename = NULL, *subfilename = NULL, *omit = NULL; char *mailfilename = NULL, *subfilename = NULL, *omit = NULL;
char *replyto = NULL, *bounceaddr = NULL, *to_addr = NULL; char *replyto = NULL, *bounceaddr = NULL, *to_addr = NULL;
char *relayhost = NULL, *archivefilename = NULL, *tmpstr; char *relayhost = NULL, *archivefilename = NULL, *tmpstr;
char *listctrl = NULL, *subddirname = NULL, *listdir = NULL; char *listctrl = NULL, *subddirname = NULL, *listdir = NULL;
char *mlmmjbounce = NULL, *bindir, *mailmap, *probefile, *a; char *mlmmjbounce = NULL, *bindir, *mailmap, *probefile, *a;
char *body = NULL, *hdrs = NULL, *memmailsizestr = NULL, *verp = NULL; char *body = NULL, *hdrs = NULL, *memmailsizestr = NULL, *verp = NULL;
char relay[16], *listname, *listfqdn, *verpfrom, *maxverprecipsstr; char relay[16], *listname, *listfqdn, *verpfrom, *maxverprecipsstr;
char strindex[32], *reply, *strport, *requeuefilename; char strindex[32], *reply, *strport, *smtphelo, *requeuefilename;
ssize_t memmailsize = 0; ssize_t memmailsize = 0;
DIR *subddir; DIR *subddir;
struct dirent *dp; struct dirent *dp;
struct stat st; struct stat st;
struct hostent *relayent; struct hostent *relayent;
uid_t uid; uid_t uid;
struct strlist stl; struct strlist stl;
unsigned short smtpport = 25; unsigned short smtpport = 25;
struct sigaction sigact; struct sigaction sigact;
skipping to change at line 1104 skipping to change at line 1102
if(inet_ntop(relayent->h_addrtype, if(inet_ntop(relayent->h_addrtype,
relayent->h_addr_list[0], relayent->h_addr_list[0],
relay, sizeof(relay)) == NULL) relay, sizeof(relay)) == NULL)
strncpy(relay, RELAYHOST, sizeof(relay)); strncpy(relay, RELAYHOST, sizeof(relay));
} }
} }
strport = ctrlvalue(listdir, "smtpport"); strport = ctrlvalue(listdir, "smtpport");
if(strport) if(strport)
smtpport = (unsigned short)atol(strport); smtpport = (unsigned short)atol(strport);
if ((smtphelo = ctrlvalue(listdir, "smtphelo")) == NULL) {
smtphelo = hostnamestr();
}
switch(listctrl[0]) { switch(listctrl[0]) {
case '1': /* A single mail is to be sent */ case '1': /* A single mail is to be sent */
case '6': case '6':
initsmtp(&sockfd, relay, smtpport); initsmtp(&sockfd, relay, smtpport, smtphelo);
if(send_mail(sockfd, bounceaddr, to_addr, replyto, if(send_mail(sockfd, bounceaddr, to_addr, replyto,
mailmap, st.st_size, listdir, NULL, mailmap, st.st_size, listdir, NULL,
hdrs, hdrslen, body, bodylen)) { hdrs, hdrslen, body, bodylen)) {
close(sockfd); close(sockfd);
sockfd = -1; sockfd = -1;
/* error, so keep it in the queue */ /* error, so keep it in the queue */
deletewhensent = 0; deletewhensent = 0;
/* dump data we want when resending first check /* dump data we want when resending first check
* if it already exists. In that case continue */ * if it already exists. In that case continue */
tmpstr = concatstr(2, mailfilename, ".mailfrom"); tmpstr = concatstr(2, mailfilename, ".mailfrom");
skipping to change at line 1165 skipping to change at line 1167
strlen(replyto)); strlen(replyto));
fsync(tmpfd); fsync(tmpfd);
} }
close(tmpfd); close(tmpfd);
} }
} else { } else {
endsmtp(&sockfd); endsmtp(&sockfd);
} }
break; break;
case '2': /* Moderators */ case '2': /* Moderators */
initsmtp(&sockfd, relay, smtpport); initsmtp(&sockfd, relay, smtpport, smtphelo);
if(send_mail_many_fd(sockfd, bounceaddr, NULL, mailmap, if(send_mail_many_fd(sockfd, bounceaddr, NULL, mailmap,
st.st_size, subfd, NULL, NULL, NULL, st.st_size, subfd, NULL, NULL, NULL,
listdir, NULL, hdrs, hdrslen, listdir, NULL, hdrs, hdrslen,
body, bodylen)) { body, bodylen)) {
close(sockfd); close(sockfd);
sockfd = -1; sockfd = -1;
} else { } else {
endsmtp(&sockfd); endsmtp(&sockfd);
} }
break; break;
case '3': /* resending earlier failed mails */ case '3': /* resending earlier failed mails */
initsmtp(&sockfd, relay, smtpport); initsmtp(&sockfd, relay, smtpport, smtphelo);
if(send_mail_many_fd(sockfd, NULL, NULL, mailmap, st.st_size, if(send_mail_many_fd(sockfd, NULL, NULL, mailmap, st.st_size,
subfd, listaddr, listdelim, mailfilename, subfd, listaddr, listdelim, mailfilename,
listdir, mlmmjbounce, hdrs, hdrslen, listdir, mlmmjbounce, hdrs, hdrslen,
body, bodylen)) { body, bodylen)) {
close(sockfd); close(sockfd);
sockfd = -1; sockfd = -1;
} else { } else {
endsmtp(&sockfd); endsmtp(&sockfd);
} }
unlink(subfilename); unlink(subfilename);
break; break;
case '4': /* send mails to owner */ case '4': /* send mails to owner */
initsmtp(&sockfd, relay, smtpport); initsmtp(&sockfd, relay, smtpport, smtphelo);
if(send_mail_many_fd(sockfd, bounceaddr, NULL, mailmap, if(send_mail_many_fd(sockfd, bounceaddr, NULL, mailmap,
st.st_size, subfd, listaddr, listdelim, st.st_size, subfd, listaddr, listdelim,
mailfilename, listdir, mlmmjbounce, mailfilename, listdir, mlmmjbounce,
hdrs, hdrslen, body, bodylen)) { hdrs, hdrslen, body, bodylen)) {
close(sockfd); close(sockfd);
sockfd = -1; sockfd = -1;
} else { } else {
endsmtp(&sockfd); endsmtp(&sockfd);
} }
break; break;
case '5': /* bounceprobe - handle relayhost local users bouncing*/ case '5': /* bounceprobe - handle relayhost local users bouncing*/
initsmtp(&sockfd, relay, smtpport); initsmtp(&sockfd, relay, smtpport, smtphelo);
if(send_mail(sockfd, bounceaddr, to_addr, replyto, if(send_mail(sockfd, bounceaddr, to_addr, replyto,
mailmap, st.st_size, listdir, NULL, mailmap, st.st_size, listdir, NULL,
hdrs, hdrslen, body, bodylen)) { hdrs, hdrslen, body, bodylen)) {
close(sockfd); close(sockfd);
sockfd = -1; sockfd = -1;
/* error, so remove the probefile */ /* error, so remove the probefile */
tmpstr = mystrdup(to_addr); tmpstr = mystrdup(to_addr);
a = strchr(tmpstr, '@'); a = strchr(tmpstr, '@');
MY_ASSERT(a); MY_ASSERT(a);
*a = '='; *a = '=';
skipping to change at line 1267 skipping to change at line 1269
} }
if(addtohdr && verp) { if(addtohdr && verp) {
log_error(LOG_ARGS, "Cannot use VERP and add " log_error(LOG_ARGS, "Cannot use VERP and add "
"To: header. Not sending with " "To: header. Not sending with "
"VERP."); "VERP.");
verp = NULL; verp = NULL;
} }
if(verp) { if(verp) {
initsmtp(&sockfd, relay, smtpport); initsmtp(&sockfd, relay, smtpport, smtphelo);
if(sockfd > -1) { if(sockfd > -1) {
if(write_mail_from(sockfd, verpfrom, verp)) { if(write_mail_from(sockfd, verpfrom, verp)) {
log_error(LOG_ARGS, log_error(LOG_ARGS,
"Could not write VERP MAIL FROM. " "Could not write VERP MAIL FROM. "
"Not sending with VERP."); "Not sending with VERP.");
verp = NULL; verp = NULL;
} else { } else {
reply = checkwait_smtpreply(sockfd, MLMMJ_FROM); reply = checkwait_smtpreply(sockfd, MLMMJ_FROM);
if(reply) { if(reply) {
log_error(LOG_ARGS, log_error(LOG_ARGS,
skipping to change at line 1331 skipping to change at line 1333
stl.strs[i+1]; stl.strs[i+1];
i++; i++;
} }
stl.strs[stl.count] = NULL; stl.strs[stl.count] = NULL;
break; break;
} }
i++; i++;
} }
} }
if(stl.count == maxverprecips) { if(stl.count == maxverprecips) {
initsmtp(&sockfd, relay, smtpport); initsmtp(&sockfd, relay, smtpport, smtphe lo);
if(verp) { if(verp) {
sendres = send_mail_verp( sendres = send_mail_verp(
sockfd, &stl, sockfd, &stl,
mailmap, mailmap,
st.st_size, st.st_size,
verpfrom, verpfrom,
listdir, hdrs, listdir, hdrs,
hdrslen, body, hdrslen, body,
bodylen, verp); bodylen, verp);
if(sendres) if(sendres)
skipping to change at line 1375 skipping to change at line 1377
for(i = 0; i < stl.count; i++) for(i = 0; i < stl.count; i++)
myfree(stl.strs[i]); myfree(stl.strs[i]);
stl.count = 0; stl.count = 0;
} }
} while(res > 0); } while(res > 0);
myfree(subfilename); myfree(subfilename);
close(subfd); close(subfd);
} }
if(stl.count) { if(stl.count) {
initsmtp(&sockfd, relay, smtpport); initsmtp(&sockfd, relay, smtpport, smtphelo);
if(verp) { if(verp) {
sendres = send_mail_verp(sockfd, &stl, mailmap, sendres = send_mail_verp(sockfd, &stl, mailmap,
st.st_size, verpfrom, listdir, st.st_size, verpfrom, listdir,
hdrs, hdrslen, body, bodylen, hdrs, hdrslen, body, bodylen,
verp); verp);
if(sendres) if(sendres)
requeuemail(listdir, strindex, &stl, requeuemail(listdir, strindex, &stl,
0); 0);
} else { } else {
sendres = send_mail_many_list(sockfd, NULL, sendres = send_mail_many_list(sockfd, NULL,
skipping to change at line 1416 skipping to change at line 1418
break; break;
} }
myfree(listdelim); myfree(listdelim);
myfree(hdrs); myfree(hdrs);
myfree(body); myfree(body);
myfree(mlmmjbounce); myfree(mlmmjbounce);
munmap(mailmap, st.st_size); munmap(mailmap, st.st_size);
close(mailfd); close(mailfd);
myfree(verp); myfree(verp);
myfree(smtphelo);
if(archive) { if(archive) {
if(!ctrlarchive) { if(!ctrlarchive) {
if(rename(mailfilename, archivefilename) < 0) { if(rename(mailfilename, archivefilename) < 0) {
log_error(LOG_ARGS, log_error(LOG_ARGS,
"Could not rename(%s,%s);", "Could not rename(%s,%s);",
mailfilename, mailfilename,
archivefilename); archivefilename);
} }
} else { } else {
 End of changes. 16 change blocks. 
14 lines changed or deleted 17 lines changed or added

Home  |  About  |  All  |  Newest  |  Fossies Dox  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTPS