diff options
author | Jannis Hoffmann <jannis@fehcom.de> | 2024-07-18 15:15:18 +0200 |
---|---|---|
committer | Jannis Hoffmann <jannis@fehcom.de> | 2024-07-18 15:15:18 +0200 |
commit | 7b4d3ab22988d021d5f12b81aec746f7e486fa52 (patch) | |
tree | 651e78e316411a39baadadb1cfaca450e1351c7f /src | |
parent | 25f74781424d5e13f0211c08cce8c2a1d60b9aec (diff) |
update to 4.3.09
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile | 71 | ||||
-rw-r--r-- | src/constmap.c | 2 | ||||
-rw-r--r-- | src/hier.c | 33 | ||||
-rw-r--r-- | src/include/auto_queue.h | 6 | ||||
-rw-r--r-- | src/include/hier.h | 2 | ||||
-rw-r--r-- | src/install.c | 24 | ||||
-rw-r--r-- | src/instcheck.c | 2 | ||||
-rw-r--r-- | src/qmail-clean.c | 4 | ||||
-rw-r--r-- | src/qmail-dksign.c | 17 | ||||
-rw-r--r-- | src/qmail-dkverify.c | 19 | ||||
-rw-r--r-- | src/qmail-getpw.c | 2 | ||||
-rw-r--r-- | src/qmail-ldapam.c | 6 | ||||
-rw-r--r-- | src/qmail-lspawn.c | 12 | ||||
-rw-r--r-- | src/qmail-qmaint.c | 28 | ||||
-rw-r--r-- | src/qmail-qmtpd.c | 4 | ||||
-rw-r--r-- | src/qmail-qread.c | 4 | ||||
-rw-r--r-- | src/qmail-queue.c | 3 | ||||
-rw-r--r-- | src/qmail-remote.c | 59 | ||||
-rw-r--r-- | src/qmail-rspawn.c | 16 | ||||
-rw-r--r-- | src/qmail-send.c | 101 | ||||
-rw-r--r-- | src/qmail-smtpam.c | 11 | ||||
-rw-r--r-- | src/qmail-smtpd.c | 15 | ||||
-rw-r--r-- | src/qmail-start.c | 10 | ||||
-rw-r--r-- | src/qmail-tcpok.c | 20 | ||||
-rw-r--r-- | src/qmail-tcpto.c | 4 | ||||
-rw-r--r-- | src/qmail-todo.c | 60 | ||||
-rw-r--r-- | src/recipients.c | 12 | ||||
-rw-r--r-- | src/spawn.c | 5 | ||||
-rw-r--r-- | src/tcpto.c | 14 | ||||
-rw-r--r-- | src/token822.c | 2 |
30 files changed, 319 insertions, 249 deletions
diff --git a/src/Makefile b/src/Makefile index d560613..2dc256e 100644 --- a/src/Makefile +++ b/src/Makefile @@ -80,8 +80,8 @@ compile auto_qmail.c ./compile auto_qmail.c auto_queue.c: \ -auto-str ../conf-home - ./auto-str auto_queue `head -1 ../conf-home` > auto_queue.c +auto-str ../conf-queue + ./auto-str auto_queue `head -1 ../conf-queue` > auto_queue.c auto_queue.o: \ compile auto_queue.c @@ -509,8 +509,8 @@ tryidn2.c compile load rm -f tryind2.o tryidn2 install: \ -load install.o hier.o auto_qmail.o auto_split.o auto_uids.o fifo.o qlibs.lib - ./load install hier.o auto_qmail.o auto_split.o auto_uids.o fifo.o \ +load install.o hier.o auto_qmail.o auto_queue.o auto_split.o auto_uids.o fifo.o qlibs.lib + ./load install hier.o auto_qmail.o auto_queue.o auto_split.o auto_uids.o fifo.o \ `cat qlibs.lib` install.o: \ @@ -518,8 +518,8 @@ compile install.c ./compile install.c instcheck: \ -load instcheck.o hier.o auto_qmail.o auto_split.o auto_uids.o qlibs.lib - ./load instcheck hier.o auto_qmail.o auto_split.o auto_uids.o \ +load instcheck.o hier.o auto_qmail.o auto_queue.o auto_split.o auto_uids.o qlibs.lib + ./load instcheck hier.o auto_qmail.o auto_split.o auto_uids.o auto_queue.o \ `cat qlibs.lib` instcheck.o: \ @@ -785,8 +785,9 @@ compile qmail-authuser.c hasspnam.h hasuserpw.h ./compile qmail-authuser.c qmail-clean: \ -load qmail-clean.o fmtqfn.o now.o auto_qmail.o auto_split.o qlibs.lib - ./load qmail-clean fmtqfn.o now.o auto_qmail.o auto_split.o `cat qlibs.lib` +load qmail-clean.o fmtqfn.o now.o auto_qmail.o auto_queue.o auto_split.o qlibs.lib + ./load qmail-clean fmtqfn.o now.o auto_qmail.o auto_queue.o auto_split.o \ + `cat qlibs.lib` qmail-clean.o: \ compile qmail-clean.c @@ -804,9 +805,9 @@ compile qmail-dkim.cpp dkim.cpp dkimbase.cpp dkimsign.cpp dkimverify.cpp qmail-dksign: \ load qmail-dksign.o control.o constmap.o fmtqfn.o rcpthosts.o qmail-dkim \ -auto_qmail.o auto_split.o qlibs.lib +auto_qmail.o auto_queue.o auto_split.o qlibs.lib ./load qmail-dksign control.o constmap.o fmtqfn.o rcpthosts.o \ - auto_qmail.o auto_split.o `cat qlibs.lib` + auto_qmail.o auto_queue.o auto_split.o `cat qlibs.lib` qmail-dksign.o: \ compile qmail-dksign.c @@ -814,9 +815,9 @@ compile qmail-dksign.c qmail-dkverify: \ load qmail-dkverify.o control.o fmtqfn.o qmail-dkim \ -auto_qmail.o auto_split.o qmail.o qlibs.lib +auto_qmail.o auto_queue.o auto_split.o qmail.o qlibs.lib ./load qmail-dkverify qmail.o control.o fmtqfn.o \ - auto_qmail.o auto_split.o `cat qlibs.lib` + auto_qmail.o auto_queue.o auto_split.o `cat qlibs.lib` qmail-dkverify.o: \ compile qmail-dkverify.c @@ -868,9 +869,9 @@ compile qmail-local.c qmail-lspawn: \ load qmail-lspawn.o spawn.o \ -auto_qmail.o auto_uids.o auto_spawn.o qlibs.lib +auto_qmail.o auto_queue.o auto_uids.o auto_spawn.o qlibs.lib ./load qmail-lspawn spawn.o \ - auto_qmail.o auto_uids.o auto_spawn.o `cat qlibs.lib` + auto_qmail.o auto_queue.o auto_uids.o auto_spawn.o `cat qlibs.lib` qmail-lspawn.o: \ compile qmail-lspawn.c @@ -927,12 +928,12 @@ compile qmail-vmailuser.c qmail-smtpam: \ load qmail-smtpam.o control.o now.o dns.o constmap.o \ -ipalloc.o ipme.o quote.o auto_qmail.o tcpto.o \ +ipalloc.o ipme.o quote.o auto_qmail.o auto_queue.o tcpto.o \ tls_timeoutio.o tls_errors.o tls_remote.o dns_tlsa.o \ ssl.lib dns.lib socket.lib qlibs.lib ucspissl.a ./load qmail-smtpam constmap.o control.o dns_tlsa.o \ tcpto.o now.o dns.o ipalloc.o ipme.o quote.o auto_qmail.o \ - tls_errors.o tls_remote.o tls_timeoutio.o ucspissl.a \ + auto_queue.o tls_errors.o tls_remote.o tls_timeoutio.o ucspissl.a \ `cat ssl.lib` `cat dns.lib` `cat socket.lib` `cat qlibs.lib` qmail-smtpam.o: \ @@ -1036,9 +1037,9 @@ compile qmail-qmtpd.c qmail-qread: \ load qmail-qread.o fmtqfn.o readsubdir.o date822fmt.o datetime.a \ -auto_qmail.o auto_split.o qlibs.lib +auto_queue.o auto_split.o qlibs.lib ./load qmail-qread fmtqfn.o readsubdir.o date822fmt.o \ - datetime.a auto_qmail.o auto_split.o `cat qlibs.lib` + datetime.a auto_queue.o auto_split.o `cat qlibs.lib` qmail-qread.o: \ compile qmail-qread.c @@ -1055,8 +1056,8 @@ warn-auto.sh qmail-qstat.sh ../conf-home ../conf-break ../conf-split qmail-queue: \ load qmail-queue.o triggerpull.o fmtqfn.o now.o date822fmt.o \ -datetime.a auto_qmail.o auto_split.o auto_uids.o qlibs.lib - ./load qmail-queue auto_qmail.o auto_split.o auto_uids.o \ +datetime.a auto_qmail.o auto_queue.o auto_split.o auto_uids.o qlibs.lib + ./load qmail-queue auto_qmail.o auto_queue.o auto_split.o auto_uids.o \ triggerpull.o fmtqfn.o now.o date822fmt.o datetime.a `cat qlibs.lib` qmail-queue.o: \ @@ -1064,9 +1065,9 @@ compile qmail-queue.c ./compile qmail-queue.c qmail-qmaint: \ -load qmail-qmaint.o auto_qmail.o auto_split.o auto_uids.o fifo.o \ +load qmail-qmaint.o auto_qmail.o auto_queue.o auto_split.o auto_uids.o fifo.o \ fmtqfn.o readsubdir.o date822fmt.o datetime.a qlibs.lib - ./load qmail-qmaint auto_qmail.o auto_split.o auto_uids.o fifo.o \ + ./load qmail-qmaint auto_qmail.o auto_queue.o auto_split.o auto_uids.o fifo.o \ fmtqfn.o readsubdir.o date822fmt.o datetime.a `cat qlibs.lib` qmail-qmaint.o: \ @@ -1076,11 +1077,11 @@ compile qmail-qmaint.c qmail-remote: \ load qmail-remote.o control.o tcpto.o now.o dns.o ipalloc.o ipme.o \ quote.o tls_timeoutio.o tls_errors.o tls_remote.o dns_tlsa.o \ -base64.o constmap.o md5c.o hmac_md5.o auto_qmail.o \ +base64.o constmap.o md5c.o hmac_md5.o auto_qmail.o auto_queue.o \ ssl.lib dns.lib socket.lib qlibs.lib idn2.lib ucspissl.a ./load qmail-remote control.o tcpto.o now.o \ base64.o constmap.o md5c.o hmac_md5.o ipalloc.o ipme.o \ - quote.o dns.o ucspissl.a auto_qmail.o dns_tlsa.o \ + quote.o dns.o ucspissl.a auto_qmail.o auto_queue.o dns_tlsa.o \ tls_errors.o tls_remote.o tls_timeoutio.o ucspissl.a \ `cat ssl.lib` `cat dns.lib` `cat socket.lib` `cat qlibs.lib` `cat idn2.lib` @@ -1090,9 +1091,9 @@ compile qmail-remote.c qmail-rspawn: \ load qmail-rspawn.o spawn.o tcpto_clean.o now.o \ -auto_qmail.o auto_uids.o auto_spawn.o qlibs.lib +auto_qmail.o auto_queue.o auto_uids.o auto_spawn.o qlibs.lib ./load qmail-rspawn spawn.o tcpto_clean.o now.o \ - auto_qmail.o auto_uids.o auto_spawn.o `cat qlibs.lib` + auto_qmail.o auto_queue.o auto_uids.o auto_spawn.o `cat qlibs.lib` qmail-rspawn.o: \ compile qmail-rspawn.c @@ -1101,10 +1102,10 @@ compile qmail-rspawn.c qmail-send: \ load qmail-send.o qsutil.o control.o constmap.o newfield.o prioq.o \ trigger.o fmtqfn.o quote.o now.o readsubdir.o qmail.o date822fmt.o \ -datetime.a auto_qmail.o auto_split.o qlibs.lib +datetime.a auto_qmail.o auto_queue.o auto_split.o qlibs.lib ./load qmail-send qsutil.o control.o constmap.o newfield.o \ - prioq.o trigger.o fmtqfn.o quote.o now.o readsubdir.o \ - qmail.o date822fmt.o datetime.a auto_qmail.o auto_split.o `cat qlibs.lib` + prioq.o trigger.o fmtqfn.o quote.o now.o readsubdir.o qmail.o \ + date822fmt.o datetime.a auto_qmail.o auto_queue.o auto_split.o `cat qlibs.lib` qmail-send.o: \ compile qmail-send.c @@ -1146,16 +1147,16 @@ compile qmail-start.c ./compile qmail-start.c qmail-tcpok: \ -load qmail-tcpok.o auto_qmail.o qlibs.lib - ./load qmail-tcpok auto_qmail.o `cat qlibs.lib` +load qmail-tcpok.o auto_queue.o qlibs.lib + ./load qmail-tcpok auto_queue.o `cat qlibs.lib` qmail-tcpok.o: \ compile qmail-tcpok.c ./compile qmail-tcpok.c qmail-tcpto: \ -load qmail-tcpto.o now.o auto_qmail.o qlibs.lib - ./load qmail-tcpto now.o auto_qmail.o `cat qlibs.lib` +load qmail-tcpto.o now.o auto_queue.o qlibs.lib + ./load qmail-tcpto now.o auto_queue.o `cat qlibs.lib` qmail-tcpto.o: \ compile qmail-tcpto.c @@ -1163,9 +1164,9 @@ compile qmail-tcpto.c qmail-todo: \ load qmail-todo.o control.o constmap.o trigger.o fmtqfn.o \ -now.o qsutil.o readsubdir.o auto_qmail.o auto_split.o qlibs.lib +now.o qsutil.o readsubdir.o auto_qmail.o auto_queue.o auto_split.o qlibs.lib ./load qmail-todo control.o constmap.o trigger.o fmtqfn.o now.o \ - readsubdir.o qsutil.o auto_qmail.o auto_split.o `cat qlibs.lib` + readsubdir.o qsutil.o auto_qmail.o auto_queue.o auto_split.o `cat qlibs.lib` qmail-todo.o: \ compile qmail-todo.c diff --git a/src/constmap.c b/src/constmap.c index ea153ea..469c4ea 100644 --- a/src/constmap.c +++ b/src/constmap.c @@ -145,7 +145,7 @@ int constmap_init_char(struct constmap *cm,char *s,int len,int flagcolon,char fl ++pos; i = j + 1; } - return 1; + return 1; } alloc_free(cm->hash); } @@ -1,4 +1,5 @@ #include "auto_qmail.h" +#include "auto_queue.h" #include "auto_split.h" #include "auto_uids.h" #include "fmt.h" @@ -14,7 +15,7 @@ void dsplit(char *base,int uid,int mode) /* base must be under 100 bytes */ char *x; unsigned long i; - d(auto_qmail,base,uid,auto_gidq,mode); + d(auto_queue,base,uid,auto_gidq,mode); for (i = 0; i < auto_split; ++i) { x = buf; @@ -23,22 +24,26 @@ void dsplit(char *base,int uid,int mode) /* base must be under 100 bytes */ x += fmt_ulong(x,i); *x = 0; - d(auto_qmail,buf,uid,auto_gidq,mode); + d(auto_queue,buf,uid,auto_gidq,mode); } } void hier() { - h(auto_qmail,auto_uido,auto_gidq,0755); + h(auto_qmail,auto_queue,auto_uido,auto_gidq,0755); + + /* s/qmail main directory */ d(auto_qmail,"control",auto_uido,auto_gidq,0755); d(auto_qmail,"users",auto_uido,auto_gidq,0755); d(auto_qmail,"bin",auto_uido,auto_gidq,0755); d(auto_qmail,"alias",auto_uida,auto_gidq,02755); - d(auto_qmail,"queue",auto_uidq,auto_gidq,0750); - d(auto_qmail,"queue/pid",auto_uidq,auto_gidq,0700); - d(auto_qmail,"queue/bounce",auto_uids,auto_gidq,0700); + /* s/qmail queue directory */ + + d(auto_queue,"queue",auto_uidq,auto_gidq,0750); + d(auto_queue,"queue/pid",auto_uidq,auto_gidq,0700); + d(auto_queue,"queue/bounce",auto_uids,auto_gidq,0700); dsplit("queue/dkim",auto_uidq,0750); dsplit("queue/mess",auto_uidq,0750); @@ -48,10 +53,12 @@ void hier() dsplit("queue/local",auto_uids,0700); dsplit("queue/remote",auto_uids,0700); - d(auto_qmail,"queue/lock",auto_uidq,auto_gidq,0750); - z(auto_qmail,"queue/lock/tcpto",TCPTO_BUFSIZ,auto_uidr,auto_gidq,0644); - z(auto_qmail,"queue/lock/sendmutex",0,auto_uids,auto_gidq,0600); - p(auto_qmail,"queue/lock/trigger",auto_uids,auto_gidq,0622); + d(auto_queue,"queue/lock",auto_uidq,auto_gidq,0750); + z(auto_queue,"queue/lock/tcpto",TCPTO_BUFSIZ,auto_uidr,auto_gidq,0644); + z(auto_queue,"queue/lock/sendmutex",0,auto_uids,auto_gidq,0600); + p(auto_queue,"queue/lock/trigger",auto_uids,auto_gidq,0622); + + /* s/qmail core programs */ c(auto_qmail,"bin","qmail-queue",auto_uidq,auto_gidq,04711); c(auto_qmail,"bin","qmail-qmaint",auto_uidq,auto_gidq,0711); @@ -97,6 +104,8 @@ void hier() c(auto_qmail,"bin","qmail-qmtpd",auto_uido,auto_gidq,0755); c(auto_qmail,"bin","qmail-smtpd",auto_uido,auto_gidq,0755); + /* s/qmail user programs; can be linked/moved to usr path */ + c(auto_qmail,"bin","predate",auto_uido,auto_gidq,0755); c(auto_qmail,"bin","datemail",auto_uido,auto_gidq,0755); c(auto_qmail,"bin","mailsubj",auto_uido,auto_gidq,0755); @@ -122,6 +131,8 @@ void hier() c(auto_qmail,"bin","srsforward",auto_uido,auto_gidq,0755); c(auto_qmail,"bin","srsreverse",auto_uido,auto_gidq,0755); + /* s/qmail DNS user programs; can be linked to usr path */ + c(auto_qmail,"bin","ipmeprint",auto_uido,auto_gidq,0755); c(auto_qmail,"bin","spfquery",auto_uido,auto_gidq,0755); c(auto_qmail,"bin","dnscname",auto_uido,auto_gidq,0755); @@ -133,6 +144,8 @@ void hier() c(auto_qmail,"bin","dnstxt",auto_uido,auto_gidq,0755); c(auto_qmail,"bin","hostname",auto_uido,auto_gidq,0755); + /* s/qmail qmailanalog programs */ + c(auto_qmail,"bin","columnt",auto_uido,auto_gidq,0755); c(auto_qmail,"bin","ddist",auto_uido,auto_gidq,0755); c(auto_qmail,"bin","deferrals",auto_uido,auto_gidq,0755); diff --git a/src/include/auto_queue.h b/src/include/auto_queue.h new file mode 100644 index 0000000..cc4645f --- /dev/null +++ b/src/include/auto_queue.h @@ -0,0 +1,6 @@ +#ifndef AUTO_QUEUE_H +#define AUTO_QUEUE_H + +extern char auto_queue[]; + +#endif diff --git a/src/include/hier.h b/src/include/hier.h index f040e79..8d9b0f2 100644 --- a/src/include/hier.h +++ b/src/include/hier.h @@ -2,7 +2,7 @@ #define HIER_H void c(char *,char *,char *,int,int,int); -void h(char *,int,int,int); +void h(char *,char *,int,int,int); void d(char *,char *,int,int,int); void p(char *,char *,int,int,int); void z(char *,char *,int,int,int,int); diff --git a/src/install.c b/src/install.c index c738fb7..e7d1a82 100644 --- a/src/install.c +++ b/src/install.c @@ -12,7 +12,7 @@ extern void hier(); int fdsourcedir = -1; -void h(char *home,int uid,int gid,int mode) +void h(char *home,char *queue,int uid,int gid,int mode) { if (mkdir(home,0700) == -1) if (errno != EEXIST) @@ -21,6 +21,16 @@ void h(char *home,int uid,int gid,int mode) logmsg(WHO,111,FATAL,B("unable to chown: ",home)); if (chmod(home,mode) == -1) logmsg(WHO,111,FATAL,B("unable to chmod: ",home)); + + if (mkdir(queue,0700) == -1) { + if (errno != EEXIST) + logmsg(WHO,111,FATAL,B("unable to mkdir: ",queue)); + } else { + if (chown(queue,uid,gid) == -1) + logmsg(WHO,111,FATAL,B("unable to chown: ",queue)); + if (chmod(queue,mode) == -1) + logmsg(WHO,111,FATAL,B("unable to chmod: ",queue)); + } } void d(char *home,char *subdir,int uid,int gid,int mode) @@ -36,17 +46,17 @@ void d(char *home,char *subdir,int uid,int gid,int mode) logmsg(WHO,111,FATAL,B("unable to chmod: ",home,"/",subdir)); } -void p(char *home,char *fifo,int uid,int gid,int mode) +void p(char *queue,char *fifo,int uid,int gid,int mode) { - if (chdir(home) == -1) - logmsg(WHO,110,FATAL,B("unable to switch to: ",home)); + if (chdir(queue) == -1) + logmsg(WHO,110,FATAL,B("unable to switch to: ",queue,"/queue")); if (fifo_make(fifo,0700) == -1) if (errno != EEXIST) - logmsg(WHO,111,FATAL,B("unable to mkfifo: ",home,"/",fifo)); + logmsg(WHO,111,FATAL,B("unable to mkfifo: ",queue,"/queue/",fifo)); if (chown(fifo,uid,gid) == -1) - logmsg(WHO,111,FATAL,B("unable to chown: ",home,"/",fifo)); + logmsg(WHO,111,FATAL,B("unable to chown: ",queue,"/queue/",fifo)); if (chmod(fifo,mode) == -1) - logmsg(WHO,111,FATAL,B("unable to chmod: ",home,"/",fifo)); + logmsg(WHO,111,FATAL,B("unable to chmod: ",queue,"/queue/",fifo)); } char inbuf[BUFFER_INSIZE]; diff --git a/src/instcheck.c b/src/instcheck.c index e47da87..744ce34 100644 --- a/src/instcheck.c +++ b/src/instcheck.c @@ -31,7 +31,7 @@ void perm(char *prefix1,char *prefix2,char *prefix3,char *file,int type,int uid, logmsg(WHO,0,WARN,B("file has wrong type: ",prefix1,prefix2,prefix3,file)); } -void h(char *home,int uid,int gid,int mode) +void h(char *home,char *queue,int uid,int gid,int mode) { perm("","","",home,S_IFDIR,uid,gid,mode); } diff --git a/src/qmail-clean.c b/src/qmail-clean.c index df149a5..db52b9b 100644 --- a/src/qmail-clean.c +++ b/src/qmail-clean.c @@ -14,7 +14,7 @@ #include "exit.h" #include "error.h" #include "fmtqfn.h" -#include "auto_qmail.h" +#include "auto_queue.h" #define OSSIFIED 129600 /* see qmail-send.c */ @@ -58,7 +58,7 @@ int main() int cleanuploop; unsigned long id; - if (chdir(auto_qmail) == -1) _exit(110); + if (chdir(auto_queue) == -1) _exit(110); if (chdir("queue") == -1) _exit(110); sig_pipeignore(); diff --git a/src/qmail-dksign.c b/src/qmail-dksign.c index f5d4895..8a2a2b7 100644 --- a/src/qmail-dksign.c +++ b/src/qmail-dksign.c @@ -9,6 +9,7 @@ #include "buffer.h" #include "error.h" #include "auto_qmail.h" +#include "auto_queue.h" #include "control.h" #include "str.h" #include "exit.h" @@ -28,7 +29,7 @@ #define WHO "qmail-dksign" -#define DOMAINKEYS "ssl/domainkeys/" +#define DOMAINKEYS "/ssl/domainkeys/" /** @file qmail-dksign.c -- generate signature and attach in DKIM header to outgoing message @@ -59,7 +60,7 @@ char outbuf[BUFSIZE_MESS]; buffer bo = BUFFER_INIT(write,1,outbuf,sizeof(outbuf)); void die(int e) { _exit(e); } -void die_write(char *fn) { unlink(fn); die(53); }; +void die_write(char *fn) { unlink(fn); die(62); }; void die_read() { die(54); }; void out(char *s) { if (buffer_puts(&bo,s) == -1) _exit(111); } void zero() { if (buffer_put(&bo,"\0",1) == -1) _exit(111); } @@ -121,7 +122,7 @@ void temp_nosignkey() out(rsakey.s); out(" or "); out(ecckey.s); - out(". (#4.3.0)\n"); + out(". (#4.3.0)\n"); zerodie(); } @@ -202,6 +203,8 @@ void dkim_stage() struct stat st; char tmpbuf[BUFSIZE_MESS + 2]; // intermediate write buffer + if (chdir(auto_queue) == -1) temp_chdir(); + if (!stralloc_ready(&fndkin,FMTQFN)) temp_nomem(); if (!stralloc_ready(&fndkout,FMTQFN)) temp_nomem(); @@ -430,8 +433,6 @@ void dkim_setup() } } } - - return; } int main(int argc,char **args) @@ -470,11 +471,13 @@ int main(int argc,char **args) /* Setup keys: they are composed from selector */ case_lowerb(sender.s,sender.len); // needs to be lowercase - if (!stralloc_copys(&rsakey,DOMAINKEYS)) temp_nomem(); + if (!stralloc_copys(&rsakey,auto_qmail)) temp_nomem(); + if (!stralloc_cats(&rsakey,DOMAINKEYS)) temp_nomem(); if (!stralloc_cats(&rsakey,sender.s)) temp_nomem(); if (!stralloc_cats(&rsakey,"/")) temp_nomem(); - if (!stralloc_copys(&ecckey,DOMAINKEYS)) temp_nomem(); + if (!stralloc_copys(&ecckey,auto_qmail)) temp_nomem(); + if (!stralloc_cats(&ecckey,DOMAINKEYS)) temp_nomem(); if (!stralloc_cats(&ecckey,sender.s)) temp_nomem(); if (!stralloc_cats(&ecckey,"/")) temp_nomem(); diff --git a/src/qmail-dkverify.c b/src/qmail-dkverify.c index be73a80..8e4d51e 100644 --- a/src/qmail-dkverify.c +++ b/src/qmail-dkverify.c @@ -8,6 +8,7 @@ #include "buffer.h" #include "error.h" #include "auto_qmail.h" +#include "auto_queue.h" #include "str.h" #include "exit.h" #include "uint_t.h" @@ -47,8 +48,8 @@ char outbuf[BUFSIZE_MESS]; buffer bo = BUFFER_INIT(write,1,outbuf,sizeof(outbuf)); // output message void die(int e) { _exit(e); } -void die_pipe(char *fn) { unlink(fn); die(53); }; -void die_write(char *fn) { unlink(fn); die(53); }; +void die_pipe(char *fn) { unlink(fn); die(54); }; +void die_write(char *fn) { unlink(fn); die(62); }; void die_read() { die(54); }; void out(char *s) { if (buffer_puts(&bo,s) == -1) _exit(111); } void zero() { if (buffer_put(&bo,"\0",1) == -1) _exit(111); } @@ -112,6 +113,8 @@ void dkim_stage() struct stat st; char tmpbuf[BUFSIZE_MESS + 2]; + if (chdir(auto_queue) == -1) temp_chdir(); + if (!stralloc_ready(&fndkin,FMTQFN)) temp_nomem(); if (!stralloc_ready(&fndkout,FMTQFN)) temp_nomem(); @@ -159,8 +162,8 @@ int mess_dkim() buffer_init(&bi,read,fd,inbuf,sizeof(inbuf)); if (!stralloc_copys(&senddomain,"")) temp_nomem(); - - for (;;) { + + for (;;) { if (getln(&bi,&line,&match,'\n') == -1) temp_read(); if (case_starts(line.s,"DKIM-Signature: ")) r = 1; if (r == 1) { @@ -170,7 +173,11 @@ int mess_dkim() end = str_chr(line.s,'\n'); // From: user@senddomain\n ket = str_chr(line.s,'>'); // From: User <user@senddomain> len = (ket < end) ? ket : end; - if (!stralloc_copyb(&senddomain,line.s + at + 1,len - at - 1)) temp_nomem(); + len -= at - 1; // From: User <user@> + if (len > 0) { + if (!stralloc_copyb(&senddomain,line.s + at + 1,len)) temp_nomem(); + } else + if (!stralloc_copys(&senddomain,"unknown")) temp_nomem(); r = 2; } } @@ -326,8 +333,6 @@ int qmail_queue() case 10: return 1; default: return 0; } - - return 0; } void dkim_unlink() diff --git a/src/qmail-getpw.c b/src/qmail-getpw.c index f801c3c..5cd4cfe 100644 --- a/src/qmail-getpw.c +++ b/src/qmail-getpw.c @@ -47,7 +47,7 @@ int userext() if (errno) _exit(QLX_NFS); } } - if (extension == local) return 0; + if (extension == local) return 0; --extension; } } diff --git a/src/qmail-ldapam.c b/src/qmail-ldapam.c index 624b39e..255aaee 100644 --- a/src/qmail-ldapam.c +++ b/src/qmail-ldapam.c @@ -177,13 +177,13 @@ int main (int argc, char **argv) int f, h, j, k, p, c, r, t, w; int rc; - if (!argv[1]) logmsg(WHO,100,USAGE,"qmail-ldapam [-d|-m] prog"); + if (!argv[1]) logmsg(WHO,100,USAGE," [-d|-m] prog"); if (!case_diffs(argv[1],FLAG_DIR)) { - if (!argv[2]) logmsg(WHO,100,USAGE,"qmail-ldapam [-d|-m] prog"); + if (!argv[2]) logmsg(WHO,100,USAGE," [-d|-m] prog"); flaghome = 1; } else { if (!case_diffs(argv[1],FLAG_MAIL)) { - if (!argv[2]) logmsg(WHO,100,USAGE,"qmail-ldapam [-d|-m] prog"); + if (!argv[2]) logmsg(WHO,100,USAGE," [-d|-m] prog"); flagmail = 1; } } diff --git a/src/qmail-lspawn.c b/src/qmail-lspawn.c index fed5c4c..894bb2a 100644 --- a/src/qmail-lspawn.c +++ b/src/qmail-lspawn.c @@ -41,17 +41,17 @@ void report(buffer *log,int wstat,char *s,int len) case QLX_NOALIAS: buffer_putsflush(log,"Zqmail-lspawn: Unable to find alias user!\n"); return; case QLX_ROOT: - buffer_putsflush(log,"Zqmail-spawn: Not allowed to perform deliveries as root.\n"); return; + buffer_putsflush(log,"Zqmail-lspawn: Not allowed to perform deliveries as root.\n"); return; case QLX_USAGE: - buffer_putsflush(log,"Zqmail-spawn: Internal bug.\n"); return; + buffer_putsflush(log,"Zqmail-lspawn: Internal bug.\n"); return; case QLX_NFS: - buffer_putsflush(log,"Zqmail-spawn: NFS failure in qmail-local.\n"); return; + buffer_putsflush(log,"Zqmail-lspawn: NFS failure in qmail-local.\n"); return; case QLX_EXECHARD: - buffer_putsflush(log,"Dqmail-spawn: Unable to run qmail-local.\n"); return; + buffer_putsflush(log,"Dqmail-lspawn: Unable to run qmail-local.\n"); return; case QLX_EXECSOFT: - buffer_putsflush(log,"Zqmail-spawn: Unable to run qmail-local.\n"); return; + buffer_putsflush(log,"Zqmail-lspawn: Unable to run qmail-local.\n"); return; case QLX_EXECPW: - buffer_putsflush(log,"Zqmail-spawn: Unable to run qmail-getpw.\n"); return; + buffer_putsflush(log,"Zqmail-lspawn: Unable to run qmail-getpw.\n"); return; case 111: case 71: case 74: case 75: buffer_put(log,"Z",1); break; case 0: diff --git a/src/qmail-qmaint.c b/src/qmail-qmaint.c index 02304e7..2539e78 100644 --- a/src/qmail-qmaint.c +++ b/src/qmail-qmaint.c @@ -19,7 +19,7 @@ #include "readsubdir.h" #include "logmsg.h" #include "exit.h" -#include "auto_qmail.h" +#include "auto_queue.h" #include "auto_split.h" #include "auto_uids.h" #include "datetime.h" @@ -128,9 +128,9 @@ int check_item(char *name,int uid,int gid,int perm,char type,int size) /*check for existence and proper credentials*/ - strnum[fmt_ulong(unum,uid)] = 0; - strnum[fmt_ulong(gnum,gid)] = 0; - strnum[fmt_ulong(pnum,perm)] = 0; + strnum[fmt_uint(unum,uid)] = 0; + strnum[fmt_uint(gnum,gid)] = 0; + strnum[fmt_uint(pnum,perm)] = 0; switch (type) { case 'd': /*directory*/ @@ -362,11 +362,9 @@ int cleanup_dkim() direntry *d; struct stat st; int deleted = 0; - unsigned long id; - if (chdir(auto_qmail) == -1) err_chdir(); - if (chdir("queue") == -1) err_chdir(); - if (chdir("dkim") == -1) return 0; + if (chdir(auto_queue) == -1) err_chdir(); + if (chdir("queue/dkim") == -1) return 0; if (!stralloc_copy(&dkim_dir,&queue_dir)) die_nomem(); if (!stralloc_cats(&dkim_dir,"dkim/")) die_nomem(); @@ -475,12 +473,11 @@ int fix_names() int check_dirs() { - /*check root existence*/ + /*check queue existence*/ if (!stralloc_copy(&check_dir,&queue_dir)) die_nomem(); if (!stralloc_0(&check_dir)) die_nomem(); if (check_item(check_dir.s,qmailq_uid,qmail_gid,0750,'d',0)) return -1; - /*check the bigtodo queue */ if (!stralloc_copy(&check_dir,&queue_dir)) die_nomem(); if (!stralloc_cats(&check_dir,"info")) die_nomem(); if (!stralloc_0(&check_dir)) die_nomem(); @@ -511,12 +508,14 @@ int check_dirs() if (check_item(check_dir.s,qmailq_uid,qmail_gid,0700,'d',0)) return -1; if (check_splits(check_dir.s,qmailq_uid,qmail_gid,0700,qmail_gid,0600)) return -1; + /*check the bigtodo queue */ if (!stralloc_copy(&check_dir,&queue_dir)) die_nomem(); if (!stralloc_cats(&check_dir,"todo")) die_nomem(); if (!stralloc_0(&check_dir)) die_nomem(); if (check_item(check_dir.s,qmailq_uid,qmail_gid,0750,'d',0)) return -1; if (check_splits(check_dir.s,qmailq_uid,qmail_gid,0750,-1,0644)) return -1; + /*check the dkim staging area */ if (!stralloc_copy(&check_dir,&queue_dir)) die_nomem(); if (!stralloc_cats(&check_dir,"dkim")) die_nomem(); if (!stralloc_0(&check_dir)) die_nomem(); @@ -537,7 +536,7 @@ int check_dirs() warn_files(check_dir.s); - /*lock has special files that must exist*/ + /* lock has special files that must exist */ if (!stralloc_copy(&check_dir,&queue_dir)) die_nomem(); if (!stralloc_cats(&check_dir,"lock")) die_nomem(); if (!stralloc_0(&check_dir)) die_nomem(); @@ -585,8 +584,9 @@ int delete_msg(unsigned long id) struct stat st; int bounce = 1; - if (chdir(auto_qmail) == -1) err_chdir(); + if (chdir(auto_queue) == -1) err_chdir(); if (chdir("queue") == -1) err_chdir(); + fnmake_init(); fnmake_mess(id); // regular message pre-processed @@ -641,10 +641,10 @@ int main(int argc, char **argv) logmsg(WHO,111,USAGE,"qmail-qmaint [-i] || [-d messid] || [-D]"); } - if (!stralloc_copys(&queue_dir,auto_qmail)) die_nomem(); + if (!stralloc_copys(&queue_dir,auto_queue)) die_nomem(); if (!stralloc_cats(&queue_dir,"/queue/")) die_nomem(); - logmsg(WHO,0,INFO,B("Checking s/qmail queue at: ",auto_qmail,"/queue/")); + logmsg(WHO,0,INFO,B("Checking s/qmail queue at: ",auto_queue,"/queue/")); /* get constants */ diff --git a/src/qmail-qmtpd.c b/src/qmail-qmtpd.c index f2a49cb..6478e21 100644 --- a/src/qmail-qmtpd.c +++ b/src/qmail-qmtpd.c @@ -18,7 +18,7 @@ #include "byte.h" #define PORT_QMTPS "6209" // string compare -#define QMTP_SIZE 200000000 // 23 MB transfer limit +#define QMTP_SIZE 200000000 // 190 MB transfer limit #define QMTP_TIMEOUT 3600 // 1 hour /** @file qmail-qmtpd.c -- QMTP/QMTPS server @@ -75,7 +75,7 @@ unsigned int bytestooverflow = 0; struct qmail qq; char buf[BUFSIZE_LINE]; // sender/recipient buffer -char bufd[BUFSIZE_MESS]; // temporary data buffer +char bufd[2 * BUFSIZE_MESS]; // temporary data buffer char buf2[BUFFER_SMALL]; // QMTP message buffer char *remotehost; diff --git a/src/qmail-qread.c b/src/qmail-qread.c index 664bde2..379ac67 100644 --- a/src/qmail-qread.c +++ b/src/qmail-qread.c @@ -7,7 +7,7 @@ #include "getln.h" #include "fmtqfn.h" #include "readsubdir.h" -#include "auto_qmail.h" +#include "auto_queue.h" #include "open.h" #include "datetime.h" #include "date822fmt.h" @@ -110,7 +110,7 @@ int main() buffer b; int x; - if (chdir(auto_qmail) == -1) die_chdir(); + if (chdir(auto_queue) == -1) die_chdir(); if (chdir("queue") == -1) die_chdir(); readsubdir_init(&rs,"info",die_opendir); diff --git a/src/qmail-queue.c b/src/qmail-queue.c index 250d556..57f1224 100644 --- a/src/qmail-queue.c +++ b/src/qmail-queue.c @@ -14,6 +14,7 @@ #include "triggerpull.h" #include "extra.h" #include "auto_qmail.h" +#include "auto_queue.h" #include "auto_uids.h" #include "date822fmt.h" #include "fmtqfn.h" @@ -210,7 +211,7 @@ int main() sig_blocknone(); umask(033); - if (chdir(auto_qmail) == -1) die(61); + if (chdir(auto_queue) == -1) die(62); if (chdir("queue") == -1) die(62); mypid = getpid(); diff --git a/src/qmail-remote.c b/src/qmail-remote.c index fc90cd4..a6ef155 100644 --- a/src/qmail-remote.c +++ b/src/qmail-remote.c @@ -474,14 +474,14 @@ void tls_init() temp_tlserr(); } -int starttls_peer() +int ehlo_starttls() { int i = 0; - while ((i += str_chr(smtptext.s + i,'\n') + 1) && - (i + 8 < smtptext.len) ) { - if (!str_diffn(smtptext.s + i + 4,"STARTTLS",8)) return 1; - } + do { + if (case_startb(smtptext.s + i + 4,8,"STARTTLS")) return 1; + } while ((i += str_chr(smtptext.s + i,'\n') + 1) && + (i < smtptext.len - 12)); return 0; } @@ -595,14 +595,14 @@ int utf8received() unsigned long code; int flagsize = 0; -int smtp_size() +int ehlo_size() { - int i; + int i = 0; - while ((i += str_chr(smtptext.s + i,'\n') + 1) && - (i + 8 <= smtptext.len) ) { - if (!str_diffn(smtptext.s + i + 4,"SIZE",4)) return 1; - } + do { + if (case_startb(smtptext.s + i + 4,4,"SIZE")) return 1; + } while ((i += str_chr(smtptext.s + i,'\n') + 1) && + (i < smtptext.len - 8)); return 0;; } @@ -625,7 +625,7 @@ void smtp_greeting() if (code >= 500) quit("DConnected to "," but my name was rejected"); if (code != 250) quit("ZConnected to "," but my name was rejected"); } - flagsize = smtp_size(); + flagsize = ehlo_size(); } void smtp_starttls() @@ -813,21 +813,22 @@ int mailfrom_cram() return 0; } -void smtp_auth() +void ehlo_auth() { - int i; + int i = 0; - while ((i += str_chr(smtptext.s + i,'\n') + 1) && - (i + 8 < smtptext.len) ) { - if (!case_diffb(smtptext.s + i + 4,"AUTH",4)) { - if (case_starts(smtptext.s + i + 9,"CRAM")) - if (mailfrom_cram() >= 0) return; - if (case_starts(smtptext.s + i + 9,"LOGIN")) - if (mailfrom_login() >= 0) return; - if (case_starts(smtptext.s + i + 9,"PLAIN")) - if (mailfrom_plain() >= 0) return; - } - } + do { + if (case_startb(smtptext.s + i + 4,4,"AUTH")) + for (i = 4; i < smtptext.len - 5; ++i) { + if (case_startb(smtptext.s + i,4,"CRAM")) + if (mailfrom_cram() >= 0) return; + if (case_startb(smtptext.s + i,5,"LOGIN")) + if (mailfrom_login() >= 0) return; + if (case_startb(smtptext.s + i,5,"PLAIN")) + if (mailfrom_plain() >= 0) return; + } + } while ((i += str_chr(smtptext.s + i,'\n') + 1) && + (i < smtptext.len - 12)); err_authprot(); mailfrom(); @@ -854,7 +855,7 @@ void smtp() smtp_greeting(); if (flagtls > 0 && flagtls < 10) { /* STARTTLS */ - if (starttls_peer()) + if (ehlo_starttls()) smtp_starttls(); else if (flagtls > 3 && flagtls != 9) { if (!stralloc_0(&host)) temp_nomem(); @@ -862,7 +863,7 @@ void smtp() } } if (user.len && pass.len) /* AUTH */ - smtp_auth(); + ehlo_auth(); else mailfrom(); /* Mail From */ @@ -1226,8 +1227,8 @@ int main(int argc,char **argv) qmtpsend = 1; port = PORT_QMTP; break; } /* default smtproutes */ - if ((relayhost = constmap(&mapsmtproutes,host.s + i,host.len - i))) - break; + if ((relayhost = constmap(&mapsmtproutes,host.s + i,host.len - i))) + break; } } if (relayhost && !*relayhost) relayhost = 0; diff --git a/src/qmail-rspawn.c b/src/qmail-rspawn.c index a9b0a1a..b0e5bf0 100644 --- a/src/qmail-rspawn.c +++ b/src/qmail-rspawn.c @@ -8,6 +8,7 @@ #include "ipalloc.h" #include "tcpto.h" #include "auto_qmail.h" +#include "auto_queue.h" #include "open.h" #include "pathexec.h" @@ -27,7 +28,7 @@ void report(buffer *log,int wstat,char *s,int len) switch (wait_exitcode(wstat)) { case 0: break; case 111: buffer_putsflush(log,"Zqmail-rspawn: Unable to run qmail-remote.\n"); break; - default: buffer_putsflush(log,"Dqmail-rspawn: Unable to run qmail-remote. \n"); return; + default: buffer_putsflush(log,"Dqmail-rspawn: Unable to run qmail-remote.\n"); return; } if (!len) { buffer_putsflush(log,"Zqmail-rspawn: qmail-remote produced no output.\n"); return; } @@ -75,8 +76,8 @@ int spawn(int fdmess,int fdout,const char *s,char *r,const int at) char *(args[5]); struct stat st; - if (chdir(auto_qmail) == -1) _exit(110); - if (stat("control/dkimdomains",&st) !=1) + if (chdir(auto_qmail) == -1) _exit(61); + if (!stat("control/dkimdomains",&st)) args[0] = "qmail-dksign"; else args[0] = "qmail-remote"; @@ -85,12 +86,13 @@ int spawn(int fdmess,int fdout,const char *s,char *r,const int at) args[3] = r; args[4] = 0; - if (chdir("queue/mess") == -1) _exit(110); + if (chdir(auto_queue) == -1) _exit(62); + if (chdir("queue/mess") == -1) _exit(62); if (!(f = vfork())) { - if (fd_move(0,fdmess) == -1) _exit(111); - if (fd_move(1,fdout) == -1) _exit(111); - if (fd_copy(2,1) == -1) _exit(111); + if (fd_move(0,fdmess) == -1) _exit(63); + if (fd_move(1,fdout) == -1) _exit(63); + if (fd_copy(2,1) == -1) _exit(63); pathexec(args); if (errno) _exit(111); _exit(100); diff --git a/src/qmail-send.c b/src/qmail-send.c index 026161f..e8b9de6 100644 --- a/src/qmail-send.c +++ b/src/qmail-send.c @@ -26,6 +26,7 @@ #include "scan.h" #include "case.h" #include "auto_qmail.h" +#include "auto_queue.h" #include "trigger.h" #include "newfield.h" #include "quote.h" @@ -40,6 +41,8 @@ int lifetime = 604800; int bouncemaxbytes = 0; +stralloc queuedir = {0}; + stralloc percenthack = {0}; struct constmap mappercenthack; stralloc locals = {0}; @@ -69,7 +72,7 @@ int flagreadasap = 0; void sighup() { flagreadasap = 1; } void cleandied() { - log1s("alert: lost connection to qmail-clean ... exiting\n"); + log1s("alert: qmail-send lost connection to qmail-clean ... exiting\n"); flagexitasap = 1; } @@ -77,7 +80,7 @@ int flagspawnalive[CHANNELS]; void spawndied(int c) { - log1s("alert: oh no! lost spawn connection! dying...\n"); + log1s("alert: oh no! qmail-send lost spawn connection! dying...\n"); flagspawnalive[c] = 0; flagexitasap = 1; } @@ -302,7 +305,7 @@ void cleanup_do() if (buffer_putflush(&toqc,fn.s,fn.len) == -1) { cleandied(); return; } if (buffer_get(&fromqc,&ch,1) != 1) { cleandied(); return; } if (ch != '+') - log3s("warning: qmail-clean unable to clean up ",fn.s,"\n"); + log3s("warning: qmail-clean is unable to clean up ",fn.s,"\n"); } @@ -355,7 +358,7 @@ void pqadd(unsigned long id) return; FAIL: - log3s("warning: unable to stat ",fn.s,"; will try again later\n"); + log3s("warning: qmail-send send is unable to stat ",fn.s,"; will try again later\n"); pe.id = id; pe.dt = now() + SLEEP_SYSFAIL; while (!prioq_insert(&pqfail,&pe)) nomem(); } @@ -384,7 +387,7 @@ void pqfinish() fnmake_chanaddr(pe.id,c); ut[0] = ut[1] = pe.dt; if (utime(fn.s,ut) == -1) - log3s("warning: unable to utime ",fn.s,"; message will be retried too soon\n"); + log3s("warning: qmail-send is unable to utime ",fn.s,"; message will be retried too soon\n"); } } @@ -467,16 +470,16 @@ void job_close(int j) if (jo[j].flaghiteof && !jo[j].numtodo) { fnmake_chanaddr(jo[j].id,jo[j].channel); if (unlink(fn.s) == -1) { - log3s("warning: unable to unlink ",fn.s,"; will try again later\n"); + log3s("warning: qmail-send is unable to unlink ",fn.s,"; will try again later\n"); pe.dt = now() + SLEEP_SYSFAIL; } else { for (c = 0; c < CHANNELS; ++c) if (c != jo[j].channel) { fnmake_chanaddr(jo[j].id,c); if (stat(fn.s,&st) == 0) return; /* more channels going */ if (errno != ENOENT) { - log3s("warning: unable to stat ",fn.s,"\n"); - break; /* this is the only reason for HOPEFULLY */ - } + log3s("warning: qmail-send is unable to stat ",fn.s,"\n"); + break; /* this is the only reason for HOPEFULLY */ + } } pe.dt = now(); while (!prioq_insert(&pqdone,&pe)) nomem(); @@ -548,7 +551,7 @@ void addbounce(unsigned long id,char *recip,char *report) for (;;) { fd = open_append(fn2.s); if (fd != -1) break; - log1s("alert: unable to append to bounce message; HELP! sleeping...\n"); + log1s("alert: qmail-send is unable to append to bounce message; HELP! sleeping...\n"); sleep(10); } @@ -557,7 +560,7 @@ void addbounce(unsigned long id,char *recip,char *report) while (pos < bouncetext.len) { w = write(fd,bouncetext.s + pos,bouncetext.len - pos); if (w <= 0) { - log1s("alert: unable to append to bounce message; HELP! sleeping...\n"); + log1s("alert: qmail-send is unable to append to bounce message; HELP! sleeping...\n"); sleep(10); } else @@ -598,7 +601,7 @@ int injectbounce(unsigned long id) if (stat(fn2.s,&st) == -1) { if (errno == ENOENT) return 1; - log3s("warning: unable to stat ",fn2.s,"\n"); + log3s("warning: qmail-send is unable to stat ",fn2.s,"\n"); return 0; } @@ -608,7 +611,7 @@ int injectbounce(unsigned long id) log3s("double bounce: discarding ",fn2.s,"\n"); else { if (qmail_open(&qqt) == -1) - { log1s("warning: unable to start qmail-queue, will try later\n"); return 0; } + { log1s("warning: qmail-send is unable to start qmail-queue, will try later\n"); return 0; } qp = qmail_qp(&qqt); if (*sender.s) { bouncesender = ""; bouncerecip = sender.s; } @@ -673,21 +676,21 @@ I tried to deliver a bounce message to this address, but the bounce bounced!\n\ } if (r > 0) qmail_puts(&qqt,"\n\n--- Rest of message truncated.\n"); - } else { /* preserve default behavior */ + } else { /* preserve default behavior */ buffer_init(&bi,read,fd,inbuf,sizeof(inbuf)); while ((r = buffer_get(&bi,buf,sizeof(buf))) > 0) qmail_put(&qqt,buf,r); - } - close(fd); - if (r == -1) qmail_fail(&qqt); + } + close(fd); + if (r == -1) qmail_fail(&qqt); } qmail_from(&qqt,bouncesender); qmail_to(&qqt,bouncerecip); if (*qmail_close(&qqt)) { - log1s("warning: trouble injecting bounce message, will try later\n"); + log1s("warning: qmail-send has trouble injecting bounce message, will try later\n"); return 0; } @@ -698,7 +701,7 @@ I tried to deliver a bounce message to this address, but the bounce bounced!\n\ } if (unlink(fn2.s) != 0) { - log3s("warning: unable to unlink ",fn2.s,"\n"); + log3s("warning: qmail-send is unable to unlink ",fn2.s,"\n"); return 0; } @@ -819,7 +822,7 @@ void markdone(int c,unsigned long id,seek_pos pos) close(fd); return; } - log3s("warning: trouble marking ",fn.s,"; message will be delivered twice!\n"); + log3s("warning: qmail-send has trouble marking ",fn.s,"; message will be delivered twice!\n"); } void del_dochan(int c) @@ -845,7 +848,7 @@ void del_dochan(int c) if (!ch && (dline[c].len > 1)) { delnum = (unsigned int) (unsigned char) dline[c].s[0]; if ((delnum < 0) || (delnum >= concurrency[c]) || !d[c][delnum].used) - log1s("warning: internal error: delivery report out of range\n"); + log1s("warning: qmail-send's internal error: delivery report out of range\n"); else { strnum3[fmt_ulong(strnum3,d[c][delnum].delid)] = 0; if (dline[c].s[1] == 'Z') @@ -1017,7 +1020,7 @@ void pass_dochan(int c) if (getln(&pass[c].b,&line,&match,'\0') == -1) { fnmake_chanaddr(pass[c].id,c); - log3s("warning: trouble reading ",fn.s,"; will try again later\n"); + log3s("warning: qmail-send has trouble reading ",fn.s,"; will try again later\n"); close(pass[c].fd); job_close(pass[c].j); pass[c].id = 0; @@ -1041,7 +1044,7 @@ void pass_dochan(int c) break; default: fnmake_chanaddr(pass[c].id,c); - log3s("warning: unknown record type in ",fn.s,"!\n"); + log3s("warning: qmail-send recognizes unknown record type in ",fn.s,"!\n"); close(pass[c].fd); job_close(pass[c].j); pass[c].id = 0; @@ -1052,7 +1055,7 @@ void pass_dochan(int c) return; trouble: - log3s("warning: trouble opening ",fn.s,"; will try again later\n"); + log3s("warning: qmail-send has trouble opening ",fn.s,"; will try again later\n"); pe.dt = recent + SLEEP_SYSFAIL; while (!prioq_insert(&pqchan[c],&pe)) nomem(); } @@ -1068,7 +1071,7 @@ void messdone(unsigned long id) fnmake_chanaddr(id,c); if (stat(fn.s,&st) == 0) return; /* false alarm; consequence of HOPEFULLY */ if (errno != ENOENT) { - log3s("warning: unable to stat ",fn.s,"; will try again later\n"); + log3s("warning: qmail-send is unable to stat ",fn.s,"; will try again later\n"); goto FAIL; } } @@ -1076,14 +1079,14 @@ void messdone(unsigned long id) fnmake_todo(id); if (stat(fn.s,&st) == 0) return; if (errno != ENOENT) { - log3s("warning: unable to stat ",fn.s,"; will try again later\n"); + log3s("warning: qmail-send is unable to stat ",fn.s,"; will try again later\n"); goto FAIL; } fnmake_info(id); if (stat(fn.s,&st) == -1) { if (errno == ENOENT) return; - log3s("warning: unable to stat ",fn.s,"; will try again later\n"); + log3s("warning: qmail-send is unable to stat ",fn.s,"; will try again later\n"); goto FAIL; } @@ -1097,7 +1100,7 @@ void messdone(unsigned long id) /* -todo +info -local -remote -bounce */ fnmake_info(id); if (unlink(fn.s) == -1) { - log3s("warning: unable to unlink ",fn.s,"; will try again later\n"); + log3s("warning: qmail-send is unable to unlink ",fn.s,"; will try again later\n"); goto FAIL; } @@ -1145,7 +1148,7 @@ int todofdout; int flagtodoalive; void tododied() { - log1s("alert: lost connection to qmail-todo ... exiting\n"); + log1s("alert: qmail-send lost connection to qmail-todo ... exiting\n"); flagexitasap = 1; flagtodoalive = 0; } @@ -1200,13 +1203,13 @@ void todo_del(char* s) case 'X': break; default: - log1s("warning: qmail-send unable to understand qmail-todo\n"); + log1s("warning: qmail-send is unable to understand qmail-todo\n"); return; } len = scan_ulong(s,&id); if (!len || s[len]) { - log1s("warning: qmail-send unable to understand qmail-todo\n"); + log1s("warning: qmail-send is unable to understand qmail-todo\n"); return; } @@ -1265,7 +1268,7 @@ void todo_do(fd_set *rfds) tododied(); break; default: - log1s("warning: qmail-send unable to understand qmail-todo: report mangled\n"); + log1s("warning: qmail-send is unable to understand qmail-todo: report mangled\n"); break; } todoline.len = 0; @@ -1312,13 +1315,13 @@ void regetcontrols() { int r; - if (control_readfile(&newlocals,"control/locals",1) != 1) { log1s("alert: unable to reread control/locals\n"); return; } - if (control_readint(&concurrency[0],"control/concurrencylocal") == -1) { log1s("alert: unable to reread control/concurrencylocal\n"); return; } - if (control_readint(&concurrency[1],"control/concurrencyremote") == -1) { log1s("alert: unable to reread control/concurrencyremote\n"); return; } - if (control_readint(&lifetime,"control/queuelifetime") == -1) { log1s("alert: unable to reread control/queuelifetime\n"); return; } + if (control_readfile(&newlocals,"control/locals",1) != 1) { log1s("alert: qmail-send is unable to reread control/locals\n"); return; } + if (control_readint(&concurrency[0],"control/concurrencylocal") == -1) { log1s("alert: qmail-send is unable to reread control/concurrencylocal\n"); return; } + if (control_readint(&concurrency[1],"control/concurrencyremote") == -1) { log1s("alert: qmail-send is unable to reread control/concurrencyremote\n"); return; } + if (control_readint(&lifetime,"control/queuelifetime") == -1) { log1s("alert: qmail-send is unable to reread control/queuelifetime\n"); return; } r = control_readfile(&newvdoms,"control/virtualdomains",0); - if (r == -1) { log1s("alert: unable to reread control/virtualdomains\n"); return; } + if (r == -1) { log1s("alert: qmail-send is unable to reread control/virtualdomains\n"); return; } constmap_free(&maplocals); constmap_free(&mapvdoms); @@ -1336,14 +1339,14 @@ void regetcontrols() void reread() { if (chdir(auto_qmail) == -1) { - log1s("alert: unable to reread controls: unable to switch to home directory\n"); + log1s("alert: qmail-send is unable to reread controls: unable to switch to home directory\n"); return; } write(todofdout,"H",1); regetcontrols(); - while (chdir("queue") == -1) { - log1s("alert: unable to switch back to queue directory; HELP! sleeping...\n"); + while (chdir(queuedir.s) == -1) { + log1s("alert: qmail-send is unable to switch back to queue directory; HELP! sleeping...\n"); sleep(10); } } @@ -1360,10 +1363,14 @@ int main() int u; int r; char ch; + + if (!stralloc_copys(&queuedir,auto_queue)) _exit(110); + if (!stralloc_cats(&queuedir,"/queue")) _exit(110); + if (!stralloc_0(&queuedir)) _exit(110); - if (chdir(auto_qmail) == -1) { log1s("alert: cannot start: unable to switch to home directory\n"); _exit(110); } - if (!getcontrols()) { log1s("alert: cannot start: unable to read controls\n"); _exit(111); } - if (chdir("queue") == -1) { log1s("alert: cannot start: unable to switch to queue directory\n"); _exit(110); } + if (chdir(auto_qmail) == -1) { log3s("alert: qmail-send is unable to switch to home directory ",auto_qmail,"\n"); _exit(110); } + if (!getcontrols()) { log1s("alert: qmail-send is unable to read controls\n"); _exit(111); } + if (chdir(queuedir.s) == -1) { log3s("alert: qmail-send cannot start and is unable to switch to queue directory ",queuedir.s,"\n"); _exit(110); } sig_pipeignore(); sig_termcatch(sigterm); sig_alarmcatch(sigalrm); @@ -1372,8 +1379,8 @@ int main() umask(077); fd = open_write("lock/sendmutex"); - if (fd == -1) { log1s("alert: cannot start: unable to open mutex\n"); _exit(111); } - if (lock_exnb(fd) == -1) { log1s("alert: cannot start: qmail-send is already running\n"); _exit(111); } + if (fd == -1) { log1s("alert: qmail-send is unable to open mutex\n"); _exit(111); } + if (lock_exnb(fd) == -1) { log1s("alert: qmail-send is already running\n"); _exit(111); } numjobs = 0; for (c = 0;c < CHANNELS;++c) { @@ -1424,7 +1431,7 @@ int main() if (errno == EINTR) ; else - log1s("warning: trouble in select\n"); + log1s("warning: qmail-send has trouble in select\n"); else { recent = now(); @@ -1437,6 +1444,6 @@ int main() } pqfinish(); - log1s("status: exiting\n"); + log1s("status: qmail-send exiting\n"); _exit(0); } diff --git a/src/qmail-smtpam.c b/src/qmail-smtpam.c index f5247dc..0cb8b3b 100644 --- a/src/qmail-smtpam.c +++ b/src/qmail-smtpam.c @@ -325,13 +325,14 @@ void tls_init() temp_tlserr(); } -int starttls_peer() +int ehlo_starttls() { int i = 0; - while ( (i += str_chr(smtptext.s + i,'\n') + 1) && - (i < smtptext.len - 8) ) { - if (!str_diffn(smtptext.s + i + 4,"STARTTLS",8)) return 1; } + do { + if (case_starts(smtptext.s + i + 4,"STARTTLS")) return 1; + } while ((i += str_chr(smtptext.s + i,'\n') + 1) && + (i - 12 < smtptext.len)); return 0; } @@ -430,7 +431,7 @@ void smtp() if (flagutf8mail) buffer_puts(&bo," SMTPUTF8"); if (flagtls > 0 && flagtls < 10) /* STARTTLS */ - if (starttls_peer()) { + if (ehlo_starttls()) { smtp_starttls(); } else if (flagtls > 2) { temp_tlshost(); diff --git a/src/qmail-smtpd.c b/src/qmail-smtpd.c index 3ca302c..f01cbee 100644 --- a/src/qmail-smtpd.c +++ b/src/qmail-smtpd.c @@ -677,7 +677,7 @@ int bmfcheck() if (!stralloc_append(&eddr,"=")) die_nomem(); if (!stralloc_0(&eddr)) die_nomem(); case_lowerb(eddr.s,eddr.len); - if (case_diffb(remotehost + rlen - dlen,eddr.s + at + 1,dlen)) + if (case_diffb(remotehost + rlen - dlen,dlen,eddr.s + at + 1)) if (constmap(&mapbmf,eddr.s + at,eddr.len - at - 1)) return -3; /* '~' extended address for MISMATCHED Domains */ @@ -795,10 +795,9 @@ int localaddr(char *mf) return mfrules(fdmav,remoteip,remotehost,remoteinfo,mf); else { if (str_len(localmfcheck) > 1) { - case_lowerb(localmfcheck,str_len(localmfcheck)); at = byte_rchr(mf,mflen,'@'); if (at < mflen) - if (!case_diffb(localmfcheck,mf + at + 1,mflen - at - 1)) return 2; + if (!case_diffb(localmfcheck,mflen - at - 1,mf + at + 1)) return 2; } if (addrallowed(mf)) return 3; return -2; @@ -992,11 +991,11 @@ void smtp_mail(char *arg) if (!stralloc_0(&protocol)) die_nomem(); if ((starttls > 1) && !seentls) { - err_tlsreq("Reject::TLS::missing",protocol.s,remoteip,remotehost,helohost.s); + err_tlsreq("Reject::TLS::Missing",protocol.s,remoteip,remotehost,helohost.s); return; } if (smtpauth > 10 && !seenauth) { - err_authreq("Reject::AUTH::missing",protocol.s,remoteip,remotehost,helohost.s); + err_authreq("Reject::AUTH::Missing",protocol.s,remoteip,remotehost,helohost.s); return; } if (!addrparse(arg)) { err_syntax(); return; } @@ -1626,20 +1625,20 @@ void smtp_auth(char *arg) if ((starttls > 1) && !seentls) { if (!stralloc_append(&protocol,"A")) die_nomem(); if (!stralloc_0(&protocol)) die_nomem(); - err_authsetup("Reject::TLS::required",protocol.s,remoteip,remotehost,helohost.s); + err_authsetup("Reject::TLS::Required",protocol.s,remoteip,remotehost,helohost.s); return; } if ((starttls > 1) && !seenhelo) { if (!stralloc_append(&protocol,"A")) die_nomem(); if (!stralloc_0(&protocol)) die_nomem(); - err_tlsreq("Reject::AUTH::invalid",protocol.s,remoteip,remotehost,helohost.s); + err_tlsreq("Reject::AUTH::Invalid",protocol.s,remoteip,remotehost,helohost.s); return; } if (!smtpauth) { out("503 auth not available (#5.3.3)\r\n"); flush(); _exit(0); } if (smtpauth && !*childargs) { - err_authsetup("Reject::AUTH::setup",protocol.s,remoteip,remotehost,helohost.s); + err_authsetup("Reject::AUTH::Setup",protocol.s,remoteip,remotehost,helohost.s); flush(); _exit(1); } if (seenauth) { err_authd(); return; } diff --git a/src/qmail-start.c b/src/qmail-start.c index 4ff0f23..d1aae7a 100644 --- a/src/qmail-start.c +++ b/src/qmail-start.c @@ -55,7 +55,7 @@ int main(int argc,char **argv) if (fd_copy(8,0) == -1) die(); if (argv[1]) { - qlargs[1] = argv[1]; // Mailbox or Maildir + qlargs[1] = argv[1]; // defaultdelivery ++argv; } @@ -107,7 +107,7 @@ int main(int argc,char **argv) if (fd_copy(1,pi4[1]) == -1) die(); closefds(); closepipes(); - execvp(*qrargs,qrargs); // qmail-respawn + execvp(*qrargs,qrargs); // qmail-rspawn die(); } @@ -133,7 +133,7 @@ int main(int argc,char **argv) if (fd_copy(2,pi9[1]) == -1) die(); if (fd_copy(3,pi10[0]) == -1) die(); closepipes(); - execvp(*qtargs,qtargs); // qmail-todo + execvp(*qtargs,qtargs); // qmail-todo die(); } @@ -145,7 +145,7 @@ int main(int argc,char **argv) if (fd_copy(1,pi10[1]) == -1) die(); closefds(); closepipes(); - execvp(*qcargs,qcargs); // qmail-clean + execvp(*qcargs,qcargs); // qmail-clean die(); } @@ -160,6 +160,6 @@ int main(int argc,char **argv) if (fd_copy(7,pi7[1]) == -1) die(); if (fd_copy(8,pi8[0]) == -1) die(); closepipes(); - execvp(*qsargs,qsargs); // qmail-send + execvp(*qsargs,qsargs); // qmail-send die(); } diff --git a/src/qmail-tcpok.c b/src/qmail-tcpok.c index 9447844..0e79591 100644 --- a/src/qmail-tcpok.c +++ b/src/qmail-tcpok.c @@ -1,9 +1,9 @@ +#include <unistd.h> #include "logmsg.h" #include "buffer.h" #include "lock.h" #include "open.h" -#include <unistd.h> -#include "auto_qmail.h" +#include "auto_queue.h" #include "exit.h" #include "qmail.h" @@ -17,21 +17,23 @@ int main() int fd; int i; - if (chdir(auto_qmail) == -1) - logmsg(WHO,111,FATAL,B("unable to chdir to: ",auto_qmail)); - if (chdir("queue/lock") == -1) - logmsg(WHO,111,FATAL,B("unable to chdir to ",auto_qmail,"/queue/lock: ")); + if (chdir(auto_queue) == -1) + logmsg(WHO,111,FATAL,B("unable to chdir to: ",auto_queue)); + if (chdir("queue") == -1) + logmsg(WHO,111,FATAL,B("unable to chdir to: ",auto_queue,"/queue")); + if (chdir("lock") == -1) + logmsg(WHO,111,FATAL,B("unable to chdir to ",auto_queue,"/queue/lock")); fd = open_write("tcpto"); if (fd == -1) - logmsg(WHO,111,FATAL,B("unable to write ",auto_qmail,"/queue/lock/tcpto: ")); + logmsg(WHO,111,FATAL,B("unable to write ",auto_queue,"/queue/lock/tcpto")); if (lock_ex(fd) == -1) - logmsg(WHO,111,FATAL,B("unable to lock ",auto_qmail,"/queue/lock/tcpto: ")); + logmsg(WHO,111,FATAL,B("unable to lock ",auto_queue,"/queue/lock/tcpto")); buffer_init(&bo,write,fd,buf,sizeof(buf)); for (i = 0; i < sizeof(buf); ++i) buffer_put(&bo,"",1); if (buffer_flush(&bo) == -1) - logmsg(WHO,111,FATAL,B("unable to clear ",auto_qmail,"/queue/lock/tcpto: ")); + logmsg(WHO,111,FATAL,B("unable to clear ",auto_queue,"/queue/lock/tcpto")); _exit(0); } diff --git a/src/qmail-tcpto.c b/src/qmail-tcpto.c index c735479..67f66c0 100644 --- a/src/qmail-tcpto.c +++ b/src/qmail-tcpto.c @@ -3,7 +3,7 @@ #include <sys/socket.h> #include <unistd.h> #include "buffer.h" -#include "auto_qmail.h" +#include "auto_queue.h" #include "fmt.h" #include "ip.h" #include "lock.h" @@ -51,7 +51,7 @@ int main(void) datetime_sec when; datetime_sec start; - if (chdir(auto_qmail) == -1) die_chdir(); + if (chdir(auto_queue) == -1) die_chdir(); if (chdir("queue/lock") == -1) die_chdir(); fdlock = open_write("tcpto"); diff --git a/src/qmail-todo.c b/src/qmail-todo.c index 0abb10e..09a5006 100644 --- a/src/qmail-todo.c +++ b/src/qmail-todo.c @@ -3,6 +3,7 @@ #include <unistd.h> #include "alloc.h" #include "auto_qmail.h" +#include "auto_queue.h" #include "byte.h" #include "constmap.h" #include "control.h" @@ -27,6 +28,8 @@ #include "sendtodo.h" #include "qmail.h" +stralloc queuedir = {0}; + stralloc percenthack = {0}; struct constmap mappercenthack; stralloc locals = {0}; @@ -202,7 +205,7 @@ int comm_canwrite(void) return 0; } -void comm_write(unsigned long id, int local, int remote) +void comm_write(unsigned long id,int local,int remote) { int pos; char *s; @@ -225,7 +228,7 @@ void comm_write(unsigned long id, int local, int remote) comm_buf.len = pos; } -void comm_info(unsigned long id, unsigned long size, char* from, unsigned long pid, unsigned long uid) +void comm_info(unsigned long id,unsigned long size,char* from,unsigned long pid,unsigned long uid) { int pos; int i; @@ -400,26 +403,26 @@ void todo_do(fd_set *rfds) fnmake_todo(id); fd = open_read(fn.s); - if (fd == -1) { sendlog3("warning: qmail-todo: unable to open ",fn.s,"\n"); return; } + if (fd == -1) { sendlog3("warning: qmail-todo is unable to open ",fn.s,"\n"); return; } fnmake_mess(id); /* just for the statistics */ if (stat(fn.s,&st) == -1) - { sendlog3("warning: qmail-todo: unable to stat ",fn.s," for mess\n"); goto FAIL; } + { sendlog3("warning: qmail-todo is unable to stat ",fn.s," for mess\n"); goto FAIL; } for (c = 0; c < CHANNELS; ++c) { fnmake_chanaddr(id,c); if (unlink(fn.s) == -1) if (errno != ENOENT) - { sendlog3("warning: qmail-todo: unable to unlink ",fn.s," for mess\n"); goto FAIL; } + { sendlog3("warning: qmail-todo is unable to unlink ",fn.s," for mess\n"); goto FAIL; } } fnmake_info(id); if (unlink(fn.s) == -1) if (errno != ENOENT) - { sendlog3("warning: qmail-todo: unable to unlink ",fn.s," for info\n"); goto FAIL; } + { sendlog3("warning: qmail-todo is unable to unlink ",fn.s," for info\n"); goto FAIL; } fdnumber = open_excl(fn.s); if (fdnumber == -1) - { sendlog3("warning: qmail-todo: unable to create ",fn.s," for info\n"); goto FAIL; } + { sendlog3("warning: qmail-todo unable to create ",fn.s," for info\n"); goto FAIL; } strnum[fmt_ulong(strnum,id)] = 0; sendlog3("new msg ",strnum,"\n"); @@ -437,7 +440,7 @@ void todo_do(fd_set *rfds) if (getln(&bi,&todoline,&match,'\0') == -1) { /* perhaps we're out of memory, perhaps an I/O error */ fnmake_todo(id); - sendlog3("warning: qmail-todo: trouble reading ",fn.s,"\n"); goto FAIL; + sendlog3("warning: qmail-todo has trouble reading ",fn.s,"\n"); goto FAIL; } if (!match) break; @@ -449,7 +452,7 @@ void todo_do(fd_set *rfds) case 'F': if (buffer_putflush(&bo,todoline.s,todoline.len) == -1) { fnmake_info(id); - sendlog3("warning: qmail-todo: trouble writing to ",fn.s," for todo\n"); goto FAIL; + sendlog3("warning: qmail-todo has trouble writing to ",fn.s," for todo\n"); goto FAIL; } comm_info(id,(unsigned long) st.st_size,todoline.s + 1,pid,uid); break; @@ -463,18 +466,18 @@ void todo_do(fd_set *rfds) fnmake_chanaddr(id,c); fdchan[c] = open_excl(fn.s); if (fdchan[c] == -1) - { sendlog3("warning: qmail-todo: unable to create ",fn.s," for delivery\n"); goto FAIL; } + { sendlog3("warning: qmail-todo is unable to create ",fn.s," for delivery\n"); goto FAIL; } buffer_init(&bchan[c],write,fdchan[c],todobufchan[c],sizeof(todobufchan[c])); flagchan[c] = 1; } if (buffer_put(&bchan[c],rwline.s,rwline.len) == -1) { fnmake_chanaddr(id,c); - sendlog3("warning: qmail-todo: trouble writing to ",fn.s," for delivery\n"); goto FAIL; + sendlog3("warning: qmail-todo has trouble writing to ",fn.s," for delivery\n"); goto FAIL; } break; default: fnmake_todo(id); - sendlog3("warning: qmail-todo: unknown record type in ",fn.s,"\n"); goto FAIL; + sendlog3("warning: qmail-todo recognizes unknown record type in ",fn.s,"\n"); goto FAIL; } } @@ -482,16 +485,16 @@ void todo_do(fd_set *rfds) fnmake_info(id); if (buffer_flush(&bo) == -1) - { sendlog3("warning: qmail-todo: trouble writing to ",fn.s," for info\n"); goto FAIL; } + { sendlog3("warning: qmail-todo has trouble writing to ",fn.s," for info\n"); goto FAIL; } if (fsync(fdnumber) == -1) - { sendlog3("warning: qmail-todo: trouble fsyncing ",fn.s," for info\n"); goto FAIL; } + { sendlog3("warning: qmail-todo has trouble fsyncing ",fn.s," for info\n"); goto FAIL; } close(fdnumber); fdnumber = -1; for (c = 0; c < CHANNELS; ++c) if (fdchan[c] != -1) { fnmake_chanaddr(id,c); - if (buffer_flush(&bchan[c]) == -1) { sendlog3("warning: qmail-todo: trouble writing to ",fn.s," in channel\n"); goto FAIL; } - if (fsync(fdchan[c]) == -1) { sendlog3("warning: qmail-todo: trouble fsyncing ",fn.s," in channel\n"); goto FAIL; } + if (buffer_flush(&bchan[c]) == -1) { sendlog3("warning: qmail-todo has trouble writing to ",fn.s," in channel\n"); goto FAIL; } + if (fsync(fdchan[c]) == -1) { sendlog3("warning: qmail-todo has trouble fsyncing ",fn.s," in channel\n"); goto FAIL; } close(fdchan[c]); fdchan[c] = -1; } @@ -543,10 +546,10 @@ void regetcontrols(void) int r; if (control_readfile(&newlocals,"control/locals",1) != 1) - { sendlog1("alert: qmail-todo: unable to reread control/locals\n"); return; } + { sendlog1("alert: qmail-todo is unable to reread control/locals\n"); return; } r = control_readfile(&newvdoms,"control/virtualdomains",0); if (r == -1) - { sendlog1("alert: qmail-todo: unable to reread control/virtualdomains\n"); return; } + { sendlog1("alert: qmail-todo is unable to reread control/virtualdomains\n"); return; } constmap_free(&maplocals); constmap_free(&mapvdoms); @@ -565,13 +568,14 @@ void regetcontrols(void) void reread(void) { if (chdir(auto_qmail) == -1) { - sendlog1("alert: qmail-todo: unable to reread controls: unable to switch to home directory\n"); + sendlog1("alert: qmail-todo is unable to reread controls: unable to switch to home directory\n"); return; } regetcontrols(); - while (chdir("queue") == -1) { - sendlog1("alert: qmail-todo: unable to switch back to queue directory; HELP! sleeping...\n"); + + while (chdir(queuedir.s) == -1) { + sendlog1("alert: qmail-todo is unable to switch back to queue directory; HELP! sleeping...\n"); sleep(10); } } @@ -586,12 +590,16 @@ int main() int r; char c; + if (!stralloc_copys(&queuedir,auto_queue)) _exit(110); + if (!stralloc_cats(&queuedir,"/queue")) _exit(110); + if (!stralloc_0(&queuedir)) _exit(110); + if (chdir(auto_qmail) == -1) - { sendlog1("alert: qmail-todo: cannot start: unable to switch to home directory\n"); _exit(110); } + { sendlog1("alert: qmail-todo cannot start and switch to home directory\n"); _exit(110); } if (!getcontrols()) - { sendlog1("alert: qmail-todo: cannot start: unable to read controls\n"); _exit(112); } - if (chdir("queue") == -1) - { sendlog1("alert: qmail-todo: cannot start: unable to switch to queue directory\n"); _exit(110); } + { sendlog1("alert: qmail-todo cannot start and read controls\n"); _exit(112); } + if (chdir(queuedir.s) == -1) + { sendlog1("alert: qmail-todo cannot start and switch to queue directory\n"); _exit(110); } sig_pipeignore(); umask(077); @@ -631,7 +639,7 @@ int main() if (errno == EINTR) ; else - sendlog1("warning: qmail-todo: trouble in select\n"); + sendlog1("warning: qmail-todo has trouble in select\n"); else { recent = now(); diff --git a/src/recipients.c b/src/recipients.c index 40d7ffe..ad222ee 100644 --- a/src/recipients.c +++ b/src/recipients.c @@ -176,7 +176,7 @@ int recipients_parse(char *rhost,int rlen,char *addr,char *rkey,int klen,char *v if (k && rlen >= k) if (!str_diffn(line.s,rhost + rlen - k - 1,k - 1)) seenhost = 3; if (u && rlen >= u) - if (!str_diffn(line.s,rhost + rlen - u - 2,u - 2)) seenhost = 4; + if (!str_diffn(line.s,rhost + rlen - u - 1,u - 1)) seenhost = 4; } if (!seenhost) /* pass-thru */ if (!str_diffn(line.s,"!*",2)) return 5; @@ -190,19 +190,19 @@ int recipients_parse(char *rhost,int rlen,char *addr,char *rkey,int klen,char *v if (r == 111) return r; } - if (u && u < line.len) /* qmail-users */ + if (u && u < line.len) /* qmail-users */ if (seenhost || !str_diffn(line.s,"*",1)) { fdrcps = open_read("users/assign.cdb"); if (fdrcps != -1) { cdb_init(&cdb,fdrcps); - r = cdb_find(&cdb,ukey,ulen - 2); + r = cdb_find(&cdb,ukey,ulen - 1); cdb_free(&cdb); close(fdrcps); if (r) return 3; } } - if (j && j < line.len) /* cdb */ + if (j && j < line.len) /* cdb */ if (seenhost || !str_diffn(line.s,"*",1)) { fdrcps = open_read(line.s + j + 1); if (fdrcps != -1) { @@ -265,9 +265,9 @@ int recipients(char *buf,int len) case_lowerb(key.s,key.len); case_lowerb(domain.s,domain.len); - if (!stralloc_copys(&ukey,"!=")) return -2; + if (!stralloc_copys(&ukey,"!")) return -2; if (!stralloc_cat(&ukey,&user)) return -2; - if (!stralloc_0(&ukey)) return -2; /* \0\0 terminated */ + if (!stralloc_0(&ukey)) return -2; /* \0 terminated */ case_lowerb(ukey.s,ukey.len); diff --git a/src/spawn.c b/src/spawn.c index f7f6f93..f987ac6 100644 --- a/src/spawn.c +++ b/src/spawn.c @@ -13,12 +13,13 @@ #include "fd.h" #include "open.h" #include "error.h" -#include "auto_qmail.h" +#include "auto_queue.h" #include "auto_uids.h" #include "auto_spawn.h" #include "qmail.h" #define BUF_COMMANDS 1024 +#define BUFSIZE_MINI 128 extern int truncreport; extern int spawn(); @@ -201,7 +202,7 @@ int main(int argc,char **argv) fd_set rfds; int nfds; - if (chdir(auto_qmail) == -1) _exit(110); + if (chdir(auto_queue) == -1) _exit(110); if (chdir("queue/mess") == -1) _exit(110); if (!stralloc_copys(&messid,"")) _exit(111); if (!stralloc_copys(&sender,"")) _exit(111); diff --git a/src/tcpto.c b/src/tcpto.c index 82b102f..a600e59 100644 --- a/src/tcpto.c +++ b/src/tcpto.c @@ -10,20 +10,25 @@ #include "byte.h" #include "datetime.h" #include "qmail.h" +#include "auto_qmail.h" +#include "auto_queue.h" char tcpto_buf[BUFSIZE_LINE]; static int flagwasthere; static int fdlock; +void die_home() { _exit(61); } +void die_queue() { _exit(62); } + static int getbuf() { int r; int fd; - fdlock = open_write("queue/lock/tcpto"); + fdlock = open_write("lock/tcpto"); if (fdlock == -1) return 0; - fd = open_read("queue/lock/tcpto"); + fd = open_read("lock/tcpto"); if (fd == -1) { close(fdlock); return 0; } if (lock_ex(fdlock) == -1) { close(fdlock); close(fd); return 0; } r = read(fd,tcpto_buf,sizeof(tcpto_buf)); @@ -43,6 +48,8 @@ int tcpto(struct ip_mx *ix) char *record; datetime_sec when; + if (chdir(auto_queue) == -1) die_queue(); + if (chdir("queue") == -1) die_queue(); flagwasthere = 0; n = getbuf(); @@ -66,6 +73,9 @@ int tcpto(struct ip_mx *ix) } record += 32; } + + if (chdir(auto_qmail) == -1) die_home(); + return 0; } diff --git a/src/token822.c b/src/token822.c index 239887c..663311f 100644 --- a/src/token822.c +++ b/src/token822.c @@ -105,7 +105,7 @@ int token822_unparse(stralloc *sa,token822_alloc *ta,unsigned int linelen) case '\\': case '\r': case '\n': ++len; default: ++len; } - break; + break; } } len += 2; |