--- vddeliver.c.orig	2003-02-14 12:26:29.000000000 -0600
+++ vddeliver.c	2003-02-14 13:23:17.000000000 -0600
@@ -1,15 +1,22 @@
+#define USE_SYSLOG 1
+#undef USE_SYSLOG
+
 #include <sys/stat.h>
+#ifdef USE_SYSLOG
+#include <syslog.h>
+#endif /* USE_SYSLOG */
 #include "env.h"
 #include "pathexec.h"
 #include "str.h"
 #include "case.h"
 #include "error.h"
 #include "stralloc.h"
+#include "openreadclose.h"
 #include "strerr.h"
 
 #include "auto_qmail_local.h"
 
-void usage() { strerr_die1x(100,"vudeliver: usage: vudeliver defaultdelivery"); }
+void usage() { strerr_die1x(100,"vddeliver: usage: vddeliver defaultdelivery"); }
 void temp_nomem() { strerr_die1x(111,"Out of memory. (#4.3.0)"); }
 void die_nombox() {
   strerr_die1x(100, "Sorry, no mailbox here by that name. (#5.1.1)");
@@ -20,6 +27,7 @@
 char *defaultdelivery;
 static stralloc local = {0};
 static stralloc newhome = {0};
+static stralloc catchall = {0};
 
 void deliver() {
   char *(args[11]);
@@ -67,6 +75,35 @@
     if (!stralloc_0(&newhome)) temp_nomem();
     if (stat(newhome.s, &st) == 0) return;
   }
+
+  /* Try a catch-all account (isl) */
+  if (!stralloc_copys(&catchall, home)) temp_nomem();
+  if (!stralloc_cats(&catchall, "/.catchall")) temp_nomem();
+  if (!stralloc_0(&catchall)) temp_nomem();
+
+#ifdef USE_SYSLOG
+  syslog(LOG_DEBUG,"Catch-all path is <%s>", catchall.s);
+#endif /* USE_SYSLOG */
+
+  if (openreadclose(catchall.s, &local, 32) != 1) die_nombox();
+  if (!stralloc_0(&local)) temp_nomem();
+  local.s[str_chr(local.s,'\n')] = 0;
+
+#ifdef USE_SYSLOG
+  syslog(LOG_DEBUG,"Catch-all name is <%s>", local.s);
+#endif /* USE_SYSLOG */
+
+  if (!stralloc_copys(&newhome, home)) temp_nomem();
+  if (!stralloc_append(&newhome, "/")) temp_nomem();
+  if (!stralloc_cats(&newhome, local.s)) temp_nomem();
+  if (!stralloc_0(&newhome)) temp_nomem();
+
+#ifdef USE_SYSLOG
+  syslog(LOG_DEBUG,"New home is <%s>", newhome.s);
+#endif /* USE_SYSLOG */
+
+  if (stat(newhome.s, &st) == 0) return;
+ 
   die_nombox();
 }
 
@@ -74,10 +111,19 @@
 {
   int i;
 
+#ifdef USE_SYSLOG
+  openlog("vddeliver", LOG_PID, LOG_MAIL);
+  syslog(LOG_DEBUG,"Initialized...");
+#endif /* USE_SYSLOG */
+
   if (argc != 2) usage();
   extension = "";
   home = env_get("HOME");
   defaultdelivery = argv[1];
   userext();
   deliver();
+
+#ifdef USE_SYSLOG
+  closelog();
+#endif /* USE_SYSLOG */
 }
