52 sendlog1(
"status: qmail-todo stop processing asap\n");
61 sendlog1(
"alert: qmail-todo lost connection to qmail-clean ... exiting\n");
93 static stralloc
addr = {0};
101 if (!stralloc_cats(&
addr,
"@"))
return 0;
106 j = byte_rchr(
addr.s,i,
'%');
113 at = byte_rchr(
addr.s,
addr.len,
'@');
117 if (!stralloc_0(&
rwline))
return 0;
121 for (i = 0; i <=
addr.len; ++i)
122 if (!i || (i == at + 1) || (i ==
addr.len) || ((i > at) && (
addr.s[i] ==
'.')))
125 if (!stralloc_cats(&
rwline,x))
return 0;
126 if (!stralloc_cats(&
rwline,
"-"))
return 0;
128 if (!stralloc_0(&
rwline))
return 0;
133 if (!stralloc_0(&
rwline))
return 0;
151 if (!stralloc_cats(&
comm_buf,
"L"))
goto FAIL;
152 if (!stralloc_cats(&
comm_buf,x))
goto FAIL;
153 if (!stralloc_0(&
comm_buf))
goto FAIL;
166 if (!stralloc_cats(&
comm_buf,
"L"))
goto FAIL;
167 if (!stralloc_cats(&
comm_buf,x))
goto FAIL;
168 if (!stralloc_cats(&
comm_buf,y))
goto FAIL;
169 if (!stralloc_cats(&
comm_buf,
z))
goto FAIL;
170 if (!stralloc_0(&
comm_buf))
goto FAIL;
185 if (ndelay_on(
fdout) == -1)
207 else if (
local) s=
"L";
213 if (!stralloc_cats(&
comm_buf,
"D"))
goto FAIL;
214 if (!stralloc_cats(&
comm_buf,s))
goto FAIL;
216 if (!stralloc_0(&
comm_buf))
goto FAIL;
224void comm_info(
unsigned long id,
unsigned long size,
char* from,
unsigned long pid,
unsigned long uid)
230 if (!stralloc_cats(&
comm_buf,
"Linfo msg "))
goto FAIL;
233 if (!stralloc_cats(&
comm_buf,
": bytes "))
goto FAIL;
236 if (!stralloc_cats(&
comm_buf,
" from <"))
goto FAIL;
238 if (!stralloc_cats(&
comm_buf,from))
goto FAIL;
247 if (!stralloc_cats(&
comm_buf,
"> qp "))
goto FAIL;
250 if (!stralloc_cats(&
comm_buf,
" uid "))
goto FAIL;
253 if (!stralloc_cats(&
comm_buf,
"\n"))
goto FAIL;
254 if (!stralloc_0(&
comm_buf))
goto FAIL;
290 if (FD_ISSET(
fdout,wfds)) {
296 if ((w == -1) && (errno == EPIPE))
307 if (FD_ISSET(
fdin,rfds)) {
311 r = read(
fdin, &
c, 1);
313 if ((r == -1) && (errno != EINTR))
324 sendlog1(
"warning: qmail-todo: qmail-send speaks an obscure dialect\n");
398 fd = open_read(
fn.s);
399 if (
fd == -1) {
sendlog3(
"warning: qmail-todo: unable to open ",
fn.s,
"\n");
return; }
403 if (stat(
fn.s,&st) == -1)
404 {
sendlog3(
"warning: qmail-todo: unable to stat ",
fn.s,
" for mess\n");
goto FAIL; }
408 if (unlink(
fn.s) == -1)
if (errno != ENOENT)
409 {
sendlog3(
"warning: qmail-todo: unable to unlink ",
fn.s,
" for mess\n");
goto FAIL; }
413 if (unlink(
fn.s) == -1)
if (errno != ENOENT)
414 {
sendlog3(
"warning: qmail-todo: unable to unlink ",
fn.s,
" for info\n");
goto FAIL; }
416 fdnumber = open_excl(
fn.s);
418 {
sendlog3(
"warning: qmail-todo: unable to create ",
fn.s,
" for info\n");
goto FAIL; }
436 sendlog3(
"warning: qmail-todo: trouble reading ",
fn.s,
"\n");
goto FAIL;
444 scan_ulong(
todoline.s + 1,&pid);
break;
448 sendlog3(
"warning: qmail-todo: trouble writing to ",
fn.s,
" for todo\n");
goto FAIL;
454 case 0:
nomem();
goto FAIL;
455 case 2:
c = 1;
break;
456 default:
c = 0;
break;
458 if (fdchan[
c] == -1) {
460 fdchan[
c] = open_excl(
fn.s);
462 {
sendlog3(
"warning: qmail-todo: unable to create ",
fn.s,
" for delivery\n");
goto FAIL; }
468 sendlog3(
"warning: qmail-todo: trouble writing to ",
fn.s,
" for delivery\n");
goto FAIL;
473 sendlog3(
"warning: qmail-todo: unknown record type in ",
fn.s,
"\n");
goto FAIL;
480 if (buffer_flush(&
bo) == -1)
481 {
sendlog3(
"warning: qmail-todo: trouble writing to ",
fn.s,
" for info\n");
goto FAIL; }
482 if (fsync(fdnumber) == -1)
483 {
sendlog3(
"warning: qmail-todo: trouble fsyncing ",
fn.s,
" for info\n");
goto FAIL; }
484 close(fdnumber); fdnumber = -1;
487 if (fdchan[
c] != -1) {
489 if (buffer_flush(&bchan[
c]) == -1) {
sendlog3(
"warning: qmail-todo: trouble writing to ",
fn.s,
" in channel\n");
goto FAIL; }
490 if (fsync(fdchan[
c]) == -1) {
sendlog3(
"warning: qmail-todo: trouble fsyncing ",
fn.s,
" in channel\n");
goto FAIL; }
491 close(fdchan[
c]); fdchan[
c] = -1;
499 sendlog3(
"warning: qmail-clean unable to clean up ",
fn.s,
"\n");
507 if (
fd != -1) close(
fd);
508 if (fdnumber != -1) close(fdnumber);
510 if (fdchan[
c] != -1) close(fdchan[
c]);
542 {
sendlog1(
"alert: qmail-todo: unable to reread control/locals\n");
return; }
545 {
sendlog1(
"alert: qmail-todo: unable to reread control/virtualdomains\n");
return; }
564 sendlog1(
"alert: qmail-todo: unable to reread controls: unable to switch to home directory\n");
569 while (chdir(
"queue") == -1) {
570 sendlog1(
"alert: qmail-todo: unable to switch back to queue directory; HELP! sleeping...\n");
586 {
sendlog1(
"alert: qmail-todo: cannot start: unable to switch to home directory\n");
_exit(110); }
588 {
sendlog1(
"alert: qmail-todo: cannot start: unable to read controls\n");
_exit(112); }
589 if (chdir(
"queue") == -1)
590 {
sendlog1(
"alert: qmail-todo: cannot start: unable to switch to queue directory\n");
_exit(110); }
599 r = read(
fdin, &
c, 1);
600 if ((r == -1) && (errno != EINTR))
622 if (wakeup <=
recent) tv.tv_sec = 0;
626 if (select(nfds,&rfds,&wfds,(fd_set *) 0,&tv) == -1)
630 sendlog1(
"warning: qmail-todo: trouble in select\n");
int constmap_init(struct constmap *cm, char *s, int len, int flagcolon)
int control_rldef(stralloc *sa, char *fn, int flagme, char *def)
int control_readfile(stralloc *sa, char *fn, int flagme)
int stralloc_copys(stralloc *, char const *)
unsigned int fmtqfn(char *s, char *dirslash, unsigned long id, int flagsplit)
void z(char *, char *, int, int, int, int)
void c(char *, char *, char *, int, int, int)
void fnmake_todo(unsigned long id)
void fnmake_info(unsigned long id)
char * chanaddr[CHANNELS]
void comm_write(unsigned long id, int local, int remote)
struct constmap mappercenthack
void fnmake_mess(unsigned long id)
void todo_do(fd_set *rfds)
char todobufchan[CHANNELS][1024]
void comm_do(fd_set *wfds, fd_set *rfds)
void todo_selprep(int *nfds, fd_set *rfds, datetime_sec *wakeup)
void comm_info(unsigned long id, unsigned long size, char *from, unsigned long pid, unsigned long uid)
struct constmap maplocals
void fnmake_chanaddr(unsigned long id, int c)
void comm_selprep(int *nfds, fd_set *wfds, fd_set *rfds)
void sendlog3(char *x, char *y, char *z)
char todobuf[BUFFER_INSIZE]