nightmaremail

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 8a5ef2bef9844e066cab9f4a48fccfc4c40b3de0
parent 8bdeb55fde017cf79c5dafb199d6a04f8c8bea00
Author: Rolf Eike Beer <eike@sf-mail.de>
Date:   Tue, 27 Aug 2019 20:46:08 +0200

remove inefficient maildirwatch

This made sense at a time where maildir was a new concept, but most relevant
mailers natively support maildir these days. There are also more efficient
syscalls to watch directories meanwhile, and people usually also do not have
local mail stores anyway. If one really needs it this can be done more
efficiently using e.g. the *notify() syscalls on Linux.

Diffstat:
MCHANGES.md | 1+
MMakefile | 21++-------------------
MTARGETS | 3---
Mhier.c | 3---
Dmaildirwatch.1 | 23-----------------------
Dmaildirwatch.c | 124-------------------------------------------------------------------------------
Mqmail.7 | 3+--
7 files changed, 4 insertions(+), 174 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md @@ -1,3 +1,4 @@ +- 20200614 remove maildirwatch - 20200614 stop rewriting RCPT TO: domains when they are a CNAME (RFC 5321 5.1) - 20200523 doc: give text files .md extensions. - 20200523 cleanup: remove qsmhook, replaced by preline. diff --git a/Makefile b/Makefile @@ -783,7 +783,7 @@ qmail-pop3d qmail-popup qmail-qmqpc qmail-qmqpd qmail-qmtpd \ qmail-smtpd sendmail tcp-env qmail-newmrh config config-fast \ dnsptr dnsip dnsfq hostname ipmeprint qreceipt qbiff \ forward preline condredirect bouncesaying except maildirmake \ -maildir2mbox maildirwatch install instpackage instchown \ +maildir2mbox install instpackage instchown \ instcheck home home+df proc proc+df binm1 binm1+df binm2 binm2+df \ binm3 binm3+df @@ -846,23 +846,6 @@ maildirmake.o: \ compile maildirmake.c strerr.h ./compile maildirmake.c -maildirwatch: \ -load maildirwatch.o hfield.o headerbody.o maildir.o prioq.o now.o \ -getln.a env.a open.a strerr.a stralloc.a substdio.a error.a \ -str.a - ./load maildirwatch hfield.o headerbody.o maildir.o \ - prioq.o now.o getln.a env.a open.a strerr.a stralloc.a \ - substdio.a error.a str.a - -maildirwatch.0: \ -maildirwatch.1 - -maildirwatch.o: \ -compile maildirwatch.c getln.h substdio.h subfd.h substdio.h prioq.h \ -datetime.h gen_alloc.h stralloc.h gen_alloc.h str.h hfield.h \ -readwrite.h open.h headerbody.h maildir.h strerr.h - ./compile maildirwatch.c - mailsubj: \ warn-auto.sh mailsubj.sh conf-qmail conf-break conf-split cat warn-auto.sh mailsubj.sh \ @@ -904,7 +887,7 @@ qmail-pw2u.0 qmail-qread.0 qmail-qstat.0 qmail-tcpto.0 qmail-tcpok.0 \ qmail-pop3d.0 qmail-popup.0 qmail-qmqpc.0 qmail-qmqpd.0 qmail-qmtpd.0 \ qmail-smtpd.0 tcp-env.0 qmail-newmrh.0 qreceipt.0 qbiff.0 forward.0 \ preline.0 condredirect.0 bouncesaying.0 except.0 maildirmake.0 \ -maildir2mbox.0 maildirwatch.0 qmail.0 qmail-limits.0 qmail-log.0 \ +maildir2mbox.0 qmail.0 qmail-limits.0 qmail-log.0 \ qmail-control.0 qmail-header.0 qmail-users.0 dot-qmail.0 \ qmail-command.0 tcp-environ.0 maildir.0 mbox.0 addresses.0 \ envelopes.0 forgeries.0 diff --git a/TARGETS b/TARGETS @@ -290,8 +290,6 @@ maildirmake.o maildirmake maildir2mbox.o maildir2mbox -maildirwatch.o -maildirwatch hier.o install instcheck.o @@ -353,7 +351,6 @@ bouncesaying.0 except.0 maildirmake.0 maildir2mbox.0 -maildirwatch.0 qmail.0 qmail-limits.7 qmail-limits.0 diff --git a/hier.c b/hier.c @@ -138,7 +138,6 @@ void hier() c(auto_qmail,"bin","except",auto_uido,auto_gidq,0755); c(auto_qmail,"bin","maildirmake",auto_uido,auto_gidq,0755); c(auto_qmail,"bin","maildir2mbox",auto_uido,auto_gidq,0755); - c(auto_qmail,"bin","maildirwatch",auto_uido,auto_gidq,0755); c(auto_qmail,"man/man5","addresses.5",auto_uido,auto_gidq,0644); c(auto_qmail,"man/cat5","addresses.0",auto_uido,auto_gidq,0644); @@ -180,8 +179,6 @@ void hier() c(auto_qmail,"man/cat1","maildirmake.0",auto_uido,auto_gidq,0644); c(auto_qmail,"man/man1","maildir2mbox.1",auto_uido,auto_gidq,0644); c(auto_qmail,"man/cat1","maildir2mbox.0",auto_uido,auto_gidq,0644); - c(auto_qmail,"man/man1","maildirwatch.1",auto_uido,auto_gidq,0644); - c(auto_qmail,"man/cat1","maildirwatch.0",auto_uido,auto_gidq,0644); c(auto_qmail,"man/man1","mailsubj.1",auto_uido,auto_gidq,0644); c(auto_qmail,"man/cat1","mailsubj.0",auto_uido,auto_gidq,0644); c(auto_qmail,"man/man1","qreceipt.1",auto_uido,auto_gidq,0644); diff --git a/maildirwatch.1 b/maildirwatch.1 @@ -1,23 +0,0 @@ -.TH maildirwatch 1 -.SH NAME -maildirwatch \- look for new mail in a maildir -.SH SYNOPSIS -.B maildirwatch -.SH DESCRIPTION -.B maildirwatch -watches your -.I maildir -for new mail. -You must supply a -.B MAILDIR -environment variable -with the name of your -.I maildir -directory. - -.B maildirwatch -prints a new mail summary twice per minute. -It is designed to run inside a (VT100-compatible) window; -it clears the window before each summary. -.SH "SEE ALSO" -maildir(5) diff --git a/maildirwatch.c b/maildirwatch.c @@ -1,124 +0,0 @@ -#include "getln.h" -#include "substdio.h" -#include "subfd.h" -#include "prioq.h" -#include "stralloc.h" -#include "str.h" -#include "hfield.h" -#include "readwrite.h" -#include "open.h" -#include "headerbody.h" -#include "maildir.h" - -#define FATAL "maildirwatch: fatal: " - -void die_nomem() { strerr_die2x(111,FATAL,"out of memory"); } - -stralloc recipient = {0}; -stralloc sender = {0}; -stralloc fromline = {0}; -stralloc text = {0}; - -void addtext(s,n) char *s; int n; -{ - if (!stralloc_catb(&text,s,n)) die_nomem(); - if (text.len > 158) text.len = 158; -} -void dobody(h) stralloc *h; { addtext(h->s,h->len); } -void doheader(h) stralloc *h; -{ - int i; - switch(hfield_known(h->s,h->len)) - { - case H_SUBJECT: - i = hfield_skipname(h->s,h->len); - addtext(h->s + i,h->len - i); - break; - case H_DELIVEREDTO: - i = hfield_skipname(h->s,h->len); - if (i < h->len) - if (!stralloc_copyb(&recipient,h->s + i,h->len - i - 1)) die_nomem(); - break; - case H_RETURNPATH: - i = hfield_skipname(h->s,h->len); - if (i < h->len) - if (!stralloc_copyb(&sender,h->s + i,h->len - i - 1)) die_nomem(); - break; - case H_FROM: - if (!stralloc_copyb(&fromline,h->s,h->len - 1)) die_nomem(); - break; - } -} -void finishheader() { ; } - -stralloc filenames = {0}; -prioq pq = {0}; - -char inbuf[SUBSTDIO_INSIZE]; -substdio ssin; - -int main(void) -{ - struct prioq_elt pe; - int fd; - int i; - - if (maildir_chdir() == -1) - strerr_die1(111,FATAL,&maildir_chdir_err); - - for (;;) - { - maildir_clean(&filenames); - if (maildir_scan(&pq,&filenames,1,0) == -1) - strerr_die1(111,FATAL,&maildir_scan_err); - - substdio_putsflush(subfdout,"\033[;H\033[;J"); - - while (prioq_min(&pq,&pe)) - { - prioq_delmin(&pq); - - fd = open_read(filenames.s + pe.id); - if (fd == -1) continue; - substdio_fdbuf(&ssin,read,fd,inbuf,sizeof(inbuf)); - - if (!stralloc_copys(&sender,"?")) die_nomem(); - if (!stralloc_copys(&recipient,"?")) die_nomem(); - if (!stralloc_copys(&fromline,"")) die_nomem(); - if (!stralloc_copys(&text,"")) die_nomem(); - if (headerbody(&ssin,doheader,finishheader,dobody) == -1) - strerr_die2x(111,FATAL,"trouble reading new message"); - - for (i = 0;i < fromline.len;++i) - if ((fromline.s[i] < 32) || (fromline.s[i] > 126)) - fromline.s[i] = '/'; - for (i = 0;i < sender.len;++i) - if ((sender.s[i] < 32) || (sender.s[i] > 126)) - sender.s[i] = '?'; - for (i = 0;i < recipient.len;++i) - if ((recipient.s[i] < 32) || (recipient.s[i] > 126)) - recipient.s[i] = '?'; - for (i = 0;i < text.len;++i) - if ((text.s[i] < 32) || (text.s[i] > 126)) - text.s[i] = '/'; - substdio_puts(subfdout,"FROM "); - substdio_put(subfdout,sender.s,sender.len); - substdio_puts(subfdout," TO <"); - substdio_put(subfdout,recipient.s,recipient.len); - substdio_puts(subfdout,">\n"); - if (fromline.len) - { - substdio_puts(subfdout,"\033[1m"); - substdio_put(subfdout,fromline.s,fromline.len); - substdio_puts(subfdout,"\033[0m\n"); - } - substdio_put(subfdout,text.s,text.len); - substdio_puts(subfdout,"\n\n"); - - close(fd); - } - - substdio_flush(subfdout); - sleep(30); - } -} diff --git a/qmail.7 b/qmail.7 @@ -19,9 +19,8 @@ and .BR condredirect (1). Other helpful commands include .BR maildirmake (1), -.BR maildir2mbox (1), and -.BR maildirwatch (1). +.BR maildir2mbox (1). System administrators who want to control the entire .B qmail