[Server-devel] [PATCH] create_user: fix handling of parameters - fixes empty authorized_keys

Martin Langhoff martin at laptop.org
Tue Sep 15 06:08:54 EDT 2009


We need doublequotes for interpolation. Single quotes look more
symmetrical in if [ "$a" == 'x' ] constructs but we want the left
side to be interpolated and the right side to be taken literally.
---
 scripts/create_user |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/scripts/create_user b/scripts/create_user
index 4e1a898..96cd522 100755
--- a/scripts/create_user
+++ b/scripts/create_user
@@ -40,13 +40,13 @@ die() {
 PASSWD_ONLY=0
 # this option allows the homedir setup (including dealings with ssh key)
 # to be skipped. useful when restoring from backups.
-if [ '$1' == '--passwd-only' ]; then
+if [ "$1" == '--passwd-only' ]; then
 	PASSWD_ONLY=1
 fi
 
 read username
 read full_name
-if [ '$PASSWD_ONLY' == '0' ]; then
+if [ "$PASSWD_ONLY" == '0' ]; then
 	read uuid       #unused!
 	read pubkey
 fi
@@ -54,7 +54,7 @@ fi
 # check for sane values
 export LC_ALL=C
 echo "$username" | grep -s -E '^[A-Z]{3}[A-F0-9]{8}$' &> /dev/null || die "bad username"
-if [ '$PASSWD_ONLY' == '0' ]; then
+if [ "$PASSWD_ONLY" == '0' ]; then
 	echo "$pubkey" | grep -s -E '^[A-Za-z0-9+/=]+$' &> /dev/null || die "bad public key"
 fi
 
@@ -78,7 +78,7 @@ else
     NEW_USER=1
 fi
 
-[ '$PASSWD_ONLY' == '1' ] && exit 0
+[ "$PASSWD_ONLY" == '1' ] && exit 0
 
 #from here, if a new user was created, a failure will leave the user
 #there but unconfigured. So rather than simply dying, we try to clean
-- 
1.6.0.6



More information about the Server-devel mailing list