* Safer handling of $1 in all scripts
[hcoop/domtool2.git] / scripts / domtool-addcert-daemon
index 96242f4..4cac202 100755 (executable)
@@ -1,8 +1,14 @@
 #!/bin/sh -e
 
 #!/bin/sh -e
 
-  KEYDIR=/afs/hcoop.net/common/etc/domtool/keys/$1
+USER="$1"
+if test -z "$USER"; then
+        echo Usage: domtool-addcert USERNAME
+        exit 1
+fi
+
+  KEYDIR=/afs/hcoop.net/common/etc/domtool/keys/$USER
  KEYFILE=$KEYDIR/key.pem
  KEYFILE=$KEYDIR/key.pem
-CERTFILE=/afs/hcoop.net/common/etc/domtool/certs/$1.pem
+CERTFILE=/afs/hcoop.net/common/etc/domtool/certs/$USER.pem
   NEWREQ=~/.newreq.pem
      NEW=~/.new.pem
    KEYIN=~/.keyin
   NEWREQ=~/.newreq.pem
      NEW=~/.new.pem
    KEYIN=~/.keyin
@@ -15,8 +21,8 @@ echo "." >>$KEYIN
 echo "." >>$KEYIN
 echo "." >>$KEYIN
 echo "." >>$KEYIN
 echo "." >>$KEYIN
 echo "." >>$KEYIN
 echo "." >>$KEYIN
-echo "$1" >>$KEYIN
-echo "$1@hcoop.net" >>$KEYIN
+echo "$USER" >>$KEYIN
+echo "$USER@hcoop.net" >>$KEYIN
 echo "" >>$KEYIN
 echo "" >>$KEYIN
 openssl req -new -key $KEYFILE -out $NEWREQ -days 365 <$KEYIN
 echo "" >>$KEYIN
 echo "" >>$KEYIN
 openssl req -new -key $KEYFILE -out $NEWREQ -days 365 <$KEYIN