Go back to exim.dat for Exim, get virtual delivery almost working
authorroot <root@deleuze.hcoop.net>
Thu, 1 Nov 2007 07:09:50 +0000 (03:09 -0400)
committerroot <root@deleuze.hcoop.net>
Tue, 17 Jun 2008 04:21:51 +0000 (00:21 -0400)
conf.d/auth/30_exim4-config_examples
conf.d/router/310_exim4-config_virtual_user
conf.d/transport/40_exim4-config_virtual_delivery
get-token

index f844199..b228b4c 100644 (file)
@@ -210,7 +210,7 @@ cram_md5:
   client_name = ${extract{1}{:}{${lookup{$host}nwildlsearch{CONFDIR/passwd.client}{$value}fail}}}
   client_secret = ${extract{2}{:}{${lookup{$host}nwildlsearch{CONFDIR/passwd.client}{$value}fail}}}
 
   client_name = ${extract{1}{:}{${lookup{$host}nwildlsearch{CONFDIR/passwd.client}{$value}fail}}}
   client_secret = ${extract{2}{:}{${lookup{$host}nwildlsearch{CONFDIR/passwd.client}{$value}fail}}}
 
-# hcoop-change: Authenticate against /etc/courier/userdb.dat for plain
+# hcoop-change: Authenticate against /etc/courier/exim.dat for plain
 # and login authenticators
 
 userdb_plain:
 # and login authenticators
 
 userdb_plain:
@@ -220,7 +220,7 @@ userdb_plain:
     ${if \
       crypteq {$3} \
               {${extract{systempw}{${tr{${lookup{$2} \
     ${if \
       crypteq {$3} \
               {${extract{systempw}{${tr{${lookup{$2} \
-                                 dbm{/etc/courier/userdb.dat} \
+                                 dbm{/etc/courier/exim.dat} \
                            }}{|}{ }}}}} \
       {yes} \
       {no} \
                            }}{|}{ }}}}} \
       {yes} \
       {no} \
@@ -235,7 +235,7 @@ userdb_login:
     ${if \
       crypteq {$2} \
               {${extract{systempw}{${tr{${lookup{$1} \
     ${if \
       crypteq {$2} \
               {${extract{systempw}{${tr{${lookup{$1} \
-                                 dbm{/etc/courier/userdb.dat} \
+                                 dbm{/etc/courier/exim.dat} \
                            }}{|}{ }}}}} \
       {yes} \
       {no} \
                            }}{|}{ }}}}} \
       {yes} \
       {no} \
index 8491201..6ff2d33 100644 (file)
@@ -3,7 +3,7 @@
 virtual_user:
   driver = accept
   transport = virtual_delivery
 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/userdb.dat} \
-                        }}{|}{ }}}}
+#  require_files = /home/vmail/${domain}/${local_part}
+  condition = ${extract{mail}{${tr{${lookup{$local_part@$domain} \
+                                 dbm{/etc/courier/exim.dat} \
+                        }}{|}{ }}}}
index 8dce1f9..49a27ef 100644 (file)
@@ -6,7 +6,7 @@ virtual_delivery:
   debug_print = "T: virtual_delivery for $local_part@$domain"
   driver = appendfile
   user = ${extract{uid}{${tr{${lookup{$local_part@$domain} \
   debug_print = "T: virtual_delivery for $local_part@$domain"
   driver = appendfile
   user = ${extract{uid}{${tr{${lookup{$local_part@$domain} \
-                                 dbm{/etc/courier/userdb.dat} \
+                                 dbm{/etc/courier/exim.dat} \
                         }}{|}{ }}}}
   group = mail
   mode = 0660
                         }}{|}{ }}}}
   group = mail
   mode = 0660
@@ -14,9 +14,9 @@ virtual_delivery:
   envelope_to_add
   return_path_add
   directory = ${extract{mail}{${tr{${lookup{$local_part@$domain} \
   envelope_to_add
   return_path_add
   directory = ${extract{mail}{${tr{${lookup{$local_part@$domain} \
-                                 dbm{/etc/courier/userdb.dat} \
+                                 dbm{/etc/courier/exim.dat} \
                         }}{|}{ }}}}${run{/etc/exim4/get-token \
                         ${extract{uid}{${tr{${lookup{$local_part@$domain} \
                         }}{|}{ }}}}${run{/etc/exim4/get-token \
                         ${extract{uid}{${tr{${lookup{$local_part@$domain} \
-                                 dbm{/etc/courier/userdb.dat} \
+                                 dbm{/etc/courier/exim.dat} \
                         }}{|}{ }}}}}{}}
   maildir_format
                         }}{|}{ }}}}}{}}
   maildir_format
index 3a28140..4d6f282 100755 (executable)
--- a/get-token
+++ b/get-token
@@ -15,8 +15,8 @@ REALUSER=$(whoami)
 USER=$1
 LOGFILE=/tmp/exim4/get-token-log.$USER
 
 USER=$1
 LOGFILE=/tmp/exim4/get-token-log.$USER
 
-if [ "$REALUSER" = "root" ]; then
-    if [ -n "$2" ]; then
+if test "$REALUSER" = "root"; then
+    if test -n "$2"; 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
@@ -24,7 +24,7 @@ if [ "$REALUSER" = "root" ]; then
 
     # Decide whether the user exists: getent returns 0 error code if so
     getent passwd "$USER" >/dev/null
 
     # Decide whether the user exists: getent returns 0 error code if so
     getent passwd "$USER" >/dev/null
-    if [ $? -ne 0 ]; then
+    if test $? -ne 0; then
         echo "$USER is not a local user, so ignoring them"
         exit 1
     else
         echo "$USER is not a local user, so ignoring them"
         exit 1
     else
@@ -32,6 +32,14 @@ if [ "$REALUSER" = "root" ]; then
     fi
 fi
 
     fi
 fi
 
+# Make sure USER exists, and resolve UIDs to a login name
+USER=$(getent passwd "$USER" | cut -d':' -f 1)
+
+if test -z "$USER"; then
+    echo "$USER is not a local user, so ignoring them"
+    exit 1
+fi
+
 # fuse stdin and stderr
 exec 2>&1
 
 # fuse stdin and stderr
 exec 2>&1