1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
|
--- Makefile Mon Jun 15 06:53:16 1998
+++ ../qmail-1.03-modified/Makefile Tue Sep 8 15:36:43 1998
@@ -803,6 +803,7 @@
predate datemail mailsubj qmail-upq qmail-showctl qmail-newu \
qmail-pw2u qmail-qread qmail-qstat qmail-tcpto qmail-tcpok \
qmail-pop3d qmail-popup qmail-qmqpc qmail-qmqpd qmail-qmtpd \
+qmail-popbull \
qmail-smtpd sendmail tcp-env qmail-newmrh config config-fast dnscname \
dnsptr dnsip dnsmxip dnsfq hostname ipmeprint qreceipt qsmhook qbiff \
forward preline condredirect bouncesaying except maildirmake \
@@ -930,6 +931,7 @@
qmail-queue.0 qmail-inject.0 mailsubj.0 qmail-showctl.0 qmail-newu.0 \
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-popbull.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 \
@@ -1286,6 +1288,18 @@
timeoutwrite.h
./compile qmail-pop3d.c
+qmail-popbull: \
+load qmail-popbull.o now.o substdio.a stralloc.a alloc.a str.a error.a
+ ./load qmail-popbull now.o substdio.a stralloc.a alloc.a fs.a str.a err
or.a
+
+qmail-popbull.0: \
+qmail-popbull.8
+ nroff -man qmail-popbull.8 > qmail-popbull.0
+
+qmail-popbull.o: \
+compile qmail-popbull.c direntry.h substdio.h stralloc.h fmt.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 \
diff -u -P ./qmail-popbull.8 new/qmail-popbull.8
--- ./qmail-popbull.8 Wed Dec 31 19:00:00 1969
+++ new/qmail-popbull.8 Wed Nov 19 08:53:24 1997
@@ -0,0 +1,50 @@
+.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 the
+.I Maildir 's
+.B cur
+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.
+
+When it 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 -P ./qmail-popbull.c new/qmail-popbull.c
--- ./qmail-popbull.c Wed Dec 31 19:00:00 1969
+++ new/qmail-popbull.c Wed Nov 19 08:40:07 1997
@@ -0,0 +1,108 @@
+#include <sys/types.h>
+#include <sys/stat.h>
+#include "direntry.h"
+#include "substdio.h"
+#include "stralloc.h"
+#include "subfd.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 pop3
d 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_nomem() {
+ substdio_putsflush(subfderr,"qmail-popbull: fatal: out of memory\n"); die_tem
p(); }
+
+stralloc cur_name = {0};
+stralloc fn = {0};
+stralloc fn2 = {0};
+char fntmptph[80 + FMT_ULONG * 2];
+
+void fnmake_maildir(dir)
+char *dir;
+{
+ 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 cur_date;
+ char *bulldirname;
+ char *programname;
+ char *maildirname;
+ DIR *bulldir;
+ direntry *d;
+ char **childargs;
+
+ if (!(bulldirname = argv[1])) die_usage();
+ if (!(programname = argv[2])) die_usage();
+ if (!(maildirname = argv[3])) die_usage();
+
+ if (!stralloc_copys(&cur_name, maildirname)) die_nomem();
+ if (!stralloc_cats(&cur_name, "/cur")) die_nomem();
+ if (!stralloc_0(&cur_name)) die_nomem();
+
+ if (stat(cur_name.s, &st) == -1) die_nomaildir();
+ cur_date = st.st_atime;
+
+ 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_mtime > cur_date)
+ {
+ fnmake_maildir();
+ if (!stralloc_copys(&fn2, maildirname)) die_nomem();
+ if (!stralloc_cats(&fn2, "/")) die_nomem();
+ if (!stralloc_cats(&fn2, fntmptph)) die_nomem();
+ if (!stralloc_0(&fn2)) die_nomem();
+ symlink(fn.s, fn2.s);
+ }
+ }
+ closedir(bulldir);
+ childargs = argv + 2;
+ execvp(*childargs,childargs);
+}
|