kamctl: fix dangerous 'rm -rf' code in case if variables are not defined
authorAlexander Lutay <alutay@sipwise.com>
Tue, 1 Aug 2017 21:20:41 +0000 (23:20 +0200)
committerDaniel-Constantin Mierla <miconda@gmail.com>
Wed, 2 Aug 2017 07:06:05 +0000 (09:06 +0200)
utils/kamctl/kamctl

index 30d5878..3aaecbd 100755 (executable)
@@ -2614,7 +2614,7 @@ tls_ca() {
                        merr "Failed to create root directory $CA_PATH"
                        exit 1
                fi
-               rm -fr $CA_PATH/*
+               rm -fr "${CA_PATH:?}"/*
                mkdir $CA_PATH/private
                mkdir $CA_PATH/certs
                touch $CA_PATH/index.txt
@@ -2685,7 +2685,7 @@ tls_ca() {
                        merr "Failed to create user directory $USER_DIR "
                        exit 1
                fi
-               rm -fr $USER_DIR/*
+               rm -fr "${USER_DIR:?}"/*
 
                mecho "Creating user certificate request"
                openssl req  -config $USER_CFG -out $USER_DIR/$USER-cert_req.pem \