To install this patch, switch to your qmail-1.03 source directory.
Apply the patch using "patch qmail-popbull.0
+
+qmail-popbull.o: \
+compile qmail-popbull.c direntry.h substdio.h stralloc.h subfd.h \
+open.h fmt.h error.h datetime.h now.h str.h
+ ./compile qmail-popbull.c
+
qmail-popup: \
load qmail-popup.o commands.o timeoutread.o timeoutwrite.o now.o \
case.a fd.a sig.a wait.a stralloc.a alloc.a substdio.a error.a str.a \
@@ -1768,6 +1781,7 @@
qmail-command.8 qmail-control.9 qmail-getpw.9 qmail-header.5 \
qmail-inject.8 qmail-limits.9 qmail-local.8 qmail-log.5 \
qmail-lspawn.8 qmail-newmrh.9 qmail-newu.9 qmail-pop3d.8 \
+qmail-popbull.8 \
qmail-popup.8 qmail-pw2u.9 qmail-qmqpc.8 qmail-qmqpd.8 qmail-qmtpd.8 \
qmail-qread.8 qmail-qstat.8 qmail-queue.8 qmail-remote.8 \
qmail-rspawn.8 qmail-send.9 qmail-showctl.8 qmail-smtpd.8 \
diff -u orig/qmail-popbull.8 ./qmail-popbull.8
--- orig/qmail-popbull.8 Fri Mar 19 23:27:14 1999
+++ ./qmail-popbull.8 Sat Mar 20 00:39:15 1999
@@ -0,0 +1,60 @@
+.TH qmail-popbull 8
+.SH NAME
+qmail-popbull \- insert bulletins
+.SH SYNOPSIS
+.B qmail-popbull
+.I bulletin-directory
+.I pop3d-program
+.I Maildir
+.SH DESCRIPTION
+.B qmail-popbull
+examines a directory of bulletins whenever a user checks their pop3 mail.
+When a new bulletin is seen, it inserts the bulletin into the user's
+.I Maildir.
+
+It compares the time on a .timestamp file in the
+.I Maildir
+directory and compares it to the time on the bulletin. If the bulletin
+is newer,
+.B qmail-popbull
+inserts a symlink to the bulletin into the user's Maildir/new directory.
+The bulletin should be an ordinary email message. One reasonable use
+of
+.B qmail-popbull
+is to point it to the
+.B new
+directory of a special user's Maildir. When you send that user mail,
+it becomes a bulletin.
+
+.B Caution!
+The files in the bulletin directory must be readable by anyone, so
+you'll probably have to store the mail in the user's maildir using:
+.EX
+ ./Maildir/
+.br
+ |chmod ugo+r Maildir/new/*
+.EE
+
+When
+.B qmail-popbull
+is finished, it execs the
+.I pop3d-program
+with the remainder of its arguments as arguments to
+.I pop3d-program.
+
+.I pop3d-program
+can be any program, but that program's first argument must be the user's
+.I Maildir.
+
+Suggested invocation:
+.EX
+ qmail-popup YOURHOST /bin/checkpassword /var/qmail/bin/qmail-popbull
+.br
+ /var/spool/bulletins /var/qmail/bin/qmail-pop3d Maildir
+.br
+ (all on one line)
+.EE
+
+.SH "SEE ALSO"
+qmail-popup(8),
+qmail-pop3d(8)
diff -u orig/qmail-popbull.c ./qmail-popbull.c
--- orig/qmail-popbull.c Fri Mar 19 23:26:40 1999
+++ ./qmail-popbull.c Sat Mar 20 00:21:43 1999
@@ -0,0 +1,115 @@
+/* written by Russell Nelson for USWest.
+ * ported to 1.03 by Bruce Guenter
+ * multiple bulletins bug noticed and fixed by Brian Mullen
+ * cur timestamp can't be used, noticed by DJB, fixed by Brett Rabe.
+*/
+#include
+#include
+#include "direntry.h"
+#include "substdio.h"
+#include "stralloc.h"
+#include "subfd.h"
+#include "open.h"
+#include "fmt.h"
+#include "error.h"
+#include "datetime.h"
+#include "now.h"
+#include "str.h"
+
+void die() { _exit(100); }
+void die_temp() { _exit(111); }
+void die_usage() {
+ substdio_putsflush(subfderr,"qmail-popbull: usage: qmail-popbull bulldir pop3d maildir\n"); die_temp(); }
+void die_nobulldir() {
+ substdio_putsflush(subfderr,"qmail-popbull: fatal: unable to read bulldir\n"); die_temp(); }
+void die_nomaildir() {
+ substdio_putsflush(subfderr,"qmail-popbull: fatal: unable to write to maildir\n"); die_temp(); }
+void die_nocdmaildir() {
+ substdio_putsflush(subfderr,"qmail-popbull: fatal: unable to change to maildir\n"); die_temp(); }
+void die_nomem() {
+ substdio_putsflush(subfderr,"qmail-popbull: fatal: out of memory\n"); die_temp(); }
+
+stralloc fn = {0};
+stralloc fn2 = {0};
+char fntmptph[80 + FMT_ULONG * 2];
+
+void fnmake_maildir()
+{
+ unsigned long pid;
+ unsigned long time;
+ char host[64];
+ char *s;
+ int loop;
+ struct stat st;
+ int fd;
+
+ pid = getpid();
+ host[0] = 0;
+ gethostname(host,sizeof(host));
+ for (loop = 0;;++loop)
+ {
+ time = now();
+ s = fntmptph;
+ s += fmt_str(s,"new/");
+ s += fmt_ulong(s,time); *s++ = '.';
+ s += fmt_ulong(s,pid); *s++ = '.';
+ s += fmt_strn(s,host,sizeof(host)); *s++ = 0;
+ if (stat(fntmptph,&st) == -1)
+ if (errno == error_noent)
+ break;
+ /* really should never get to this point */
+ if (loop == 2)
+ _exit(1);
+ sleep(2);
+ }
+}
+
+
+void main(argc,argv)
+int argc;
+char **argv;
+{
+ int fd;
+ struct stat st;
+ datetime_sec ts_date;
+ char *bulldirname;
+ char *programname;
+ char *maildirname;
+ DIR *bulldir;
+ direntry *d;
+ char **childargs;
+ char num[80];
+
+ if (!(bulldirname = argv[1])) die_usage();
+ if (!(programname = argv[2])) die_usage();
+ if (!(maildirname = argv[3])) die_usage();
+
+ if (chdir(maildirname) == -1) die_nocdmaildir();
+ argv[3] = ".";
+
+ if (stat(".timestamp", &st) == -1) ts_date = 0;
+ else ts_date = st.st_mtime;
+ fd = open_trunc(".timestamp");
+ close (fd);
+
+ bulldir = opendir(bulldirname);
+ if (!bulldir) die_nobulldir();
+ while(d = readdir(bulldir))
+ {
+ if (str_equal(d->d_name,".")) continue;
+ if (str_equal(d->d_name,"..")) continue;
+ if (!stralloc_copys(&fn, bulldirname)) die_nomem();
+ if (!stralloc_cats(&fn, "/")) die_nomem();
+ if (!stralloc_cats(&fn, d->d_name)) die_nomem();
+ if (!stralloc_0(&fn)) die_nomem();
+ if (stat(fn.s, &st) == -1) die(); if ((st.st_mode & 0222) == 0) continue;
+ if (st.st_mtime > ts_date)
+ {
+ fnmake_maildir();
+ symlink(fn.s, fntmptph);
+ }
+ }
+ closedir(bulldir);
+ childargs = argv + 2;
+ execvp(*childargs,childargs);
+}
diff -u orig/install-big.c ./install-big.c
--- orig/install-big.c Fri Apr 16 11:01:32 1999
+++ ./install-big.c Fri Apr 16 11:03:06 1999
@@ -122,6 +122,7 @@
c(auto_qmail,"bin","qmail-tcpto",auto_uido,auto_gidq,0755);
c(auto_qmail,"bin","qmail-tcpok",auto_uido,auto_gidq,0755);
c(auto_qmail,"bin","qmail-pop3d",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","qmail-popbull",auto_uido,auto_gidq,0755);
c(auto_qmail,"bin","qmail-popup",auto_uido,auto_gidq,0711);
c(auto_qmail,"bin","qmail-qmqpc",auto_uido,auto_gidq,0755);
c(auto_qmail,"bin","qmail-qmqpd",auto_uido,auto_gidq,0755);