Go back to exim.dat for Exim, get virtual delivery almost working
[hcoop/config/exim.git] / get-token
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
 
-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
@@ -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
-    if [ $? -ne 0 ]; then
+    if test $? -ne 0; then
         echo "$USER is not a local user, so ignoring them"
         exit 1
     else
@@ -32,6 +32,14 @@ if [ "$REALUSER" = "root" ]; then
     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