From f1bc36aedb6cd38a5f41ccb346ec68f8d28d11b2 Mon Sep 17 00:00:00 2001 From: Olav Vitters Date: Sat, 25 Jul 2020 14:42:21 +0200 Subject: create-ssl-certificate: ShellCheck: fix quoting issues and undefined behaviour --- create-ssl-certificate | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/create-ssl-certificate b/create-ssl-certificate index 599719b..a0d7352 100755 --- a/create-ssl-certificate +++ b/create-ssl-certificate @@ -14,12 +14,12 @@ pkg=${args[0]} # name of the package num=${args[1]} # number of packages installed srv=${args[2]} # name of the service -if [ -z "$pkg" -o -z "$num" -o -z "$srv" ]; then +if [ -z "$pkg" ] || [ -z "$num" ] || [ -z "$srv" ]; then echo "usage: $0 [-g ] [-b] " 1>&2 exit 1 fi -if [ ! -f /etc/pki/tls/private/$srv.pem ]; then +if [ ! -f "/etc/pki/tls/private/$srv.pem" ]; then # default values host=$(hostname) KEY_LENGTH=2048 @@ -35,7 +35,7 @@ if [ ! -f /etc/pki/tls/private/$srv.pem ]; then conffile=/tmp/$$ keyfile=/etc/pki/tls/private/$srv.pem - if [ "$bundle" == true ]; then + if [ "$bundle" = "true" ]; then certfile=$keyfile else certfile=/etc/pki/tls/certs/$srv.pem @@ -59,16 +59,16 @@ basicConstraints = CA:FALSE EOF # generate certificates - openssl req -new -x509 -days $CERT_DAYS \ - -config $conffile \ - -keyout $keyfile \ - -out $certfile >/dev/null + openssl req -new -x509 -days "$CERT_DAYS" \ + -config "$conffile" \ + -keyout "$keyfile" \ + -out "$certfile" >/dev/null # enforce strict perms on key if [ -n "$group" ]; then - chmod 640 $keyfile - chgrp $group $keyfile + chmod 640 "$keyfile" + chgrp "$group" "$keyfile" else - chmod 600 $keyfile + chmod 600 "$keyfile" fi fi -- cgit v1.2.1