new-user: Expand ~$USERNM correctly
[clinton/scripts.git] / new-user
index 79cf96e..345f105 100755 (executable)
--- a/new-user
+++ b/new-user
@@ -2,7 +2,7 @@
 
 USERNM=$1
 REALNM=$2
-EMAILADDR=$4
+EMAILADDR=$3
 PWFILE=/var/lib/portal/$USERNM
 
 if test -z "$USERNM"; then 
@@ -58,8 +58,10 @@ if test -z "$EMAILADDR"; then
        echo "Skipping email forwarding, no email address was specified."
 else
        echo setting email forward to "$EMAILADDR"
-       sh -c "echo '$EMAILADDR' > ~$USERNM/.public/.forward" || \
+       FORWARD_PATH=$(sh -c "echo ~$USERNM/.public/.forward")
+       echo "$EMAILADDR" > $FORWARD_PATH || \
        ( echo "Failed to set forward address" && exit 6 )
+       chown $USERNM $FORWARD_PATH
 fi
 
 #