Get vmail working!
authorroot <root@deleuze.hcoop.net>
Mon, 5 Nov 2007 20:40:35 +0000 (15:40 -0500)
committerroot <root@deleuze.hcoop.net>
Tue, 17 Jun 2008 04:21:51 +0000 (00:21 -0400)
conf.d/router/310_exim4-config_virtual_user
conf.d/transport/40_exim4-config_virtual_delivery
get-token

dissimilarity index 66%
index 6ff2d33..b2f28f8 100644 (file)
@@ -1,9 +1,14 @@
-# hcoop-change: Route mail for hosted domains
-
-virtual_user:
-  driver = accept
-  transport = virtual_delivery
-#  require_files = /home/vmail/${domain}/${local_part}
-  condition = ${extract{mail}{${tr{${lookup{$local_part@$domain} \
-                                 dbm{/etc/courier/exim.dat} \
-                        }}{|}{ }}}}
+# hcoop-change: Route mail for hosted domains
+
+virtual_user:
+  driver = accept
+  transport = virtual_delivery
+  # Look up the parameters for this email address, and store them in
+  # $address_data for later use.  If no data exists for this address,
+  # then "fail", which causes Exim to move on to the next router.
+  # This allows us to access the contents of $address_data in the
+  # virtual_delivery transport later on, without having to do multiple
+  # accesses to exim.dat.
+  address_data = ${tr{${lookup{$local_part@$domain} \
+                              dbm{/etc/courier/exim.dat}{$value} fail }} \
+                     {|}{ }}
dissimilarity index 60%
index 49a27ef..d18a328 100644 (file)
@@ -1,22 +1,16 @@
-# hcoop-change: This transport is used to deliver mail to virtual
-# mailboxes (i.e. email accounts which have been granted to non-hcoop
-# members by the owner of the domain)
-
-virtual_delivery:
-  debug_print = "T: virtual_delivery for $local_part@$domain"
-  driver = appendfile
-  user = ${extract{uid}{${tr{${lookup{$local_part@$domain} \
-                                 dbm{/etc/courier/exim.dat} \
-                        }}{|}{ }}}}
-  group = mail
-  mode = 0660
-  mode_fail_narrower = false
-  envelope_to_add
-  return_path_add
-  directory = ${extract{mail}{${tr{${lookup{$local_part@$domain} \
-                                 dbm{/etc/courier/exim.dat} \
-                        }}{|}{ }}}}${run{/etc/exim4/get-token \
-                        ${extract{uid}{${tr{${lookup{$local_part@$domain} \
-                                 dbm{/etc/courier/exim.dat} \
-                        }}{|}{ }}}}}{}}
-  maildir_format
+# hcoop-change: This transport is used to deliver mail to virtual
+# mailboxes (i.e. email accounts which have been granted to non-hcoop
+# members by the owner of the domain)
+
+virtual_delivery:
+  debug_print = "T: virtual_delivery for $local_part@$domain"
+  driver = appendfile
+  user = ${extract{uid}{$address_data}}
+  group = nogroup
+  mode = 0600
+  mode_fail_narrower = false
+  envelope_to_add
+  return_path_add
+  directory = ${extract{mail}{$address_data}}${run{/etc/exim4/get-token \
+                        ${extract{uid}{$address_data}}}{}}
+  maildir_format
index 4d6f282..0c7abe5 100755 (executable)
--- a/get-token
+++ b/get-token
@@ -16,7 +16,7 @@ USER=$1
 LOGFILE=/tmp/exim4/get-token-log.$USER
 
 if test "$REALUSER" = "root"; then
 LOGFILE=/tmp/exim4/get-token-log.$USER
 
 if test "$REALUSER" = "root"; then
-    if test -n "$2"; then
+    if test "$2" = "norecurse"; then
         echo "Error: running as root even after trying to change to $USER" \
             > $LOGFILE
         exit 1
         echo "Error: running as root even after trying to change to $USER" \
             > $LOGFILE
         exit 1
@@ -34,6 +34,7 @@ fi
 
 # Make sure USER exists, and resolve UIDs to a login name
 USER=$(getent passwd "$USER" | cut -d':' -f 1)
 
 # Make sure USER exists, and resolve UIDs to a login name
 USER=$(getent passwd "$USER" | cut -d':' -f 1)
+LOGFILE=/tmp/exim4/get-token-log.$USER
 
 if test -z "$USER"; then
     echo "$USER is not a local user, so ignoring them"
 
 if test -z "$USER"; then
     echo "$USER is not a local user, so ignoring them"
@@ -49,6 +50,12 @@ exec >& $LOGFILE
 # print name of user
 echo "Running as user $REALUSER"
 
 # print name of user
 echo "Running as user $REALUSER"
 
+# debugging output
+if test "$2" = "debug"; then
+    shift; shift
+    echo "Debugging output: $*"
+fi
+
 # set the credentials cache
 export KRB5CCNAME=FILE:/tmp/exim4/krb5cc_$USER.email
 
 # set the credentials cache
 export KRB5CCNAME=FILE:/tmp/exim4/krb5cc_$USER.email