aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlav Vitters <olav@vitters.nl>2020-07-25 14:42:21 +0200
committerOlav Vitters <olav@vitters.nl>2020-07-25 14:42:21 +0200
commitf1bc36aedb6cd38a5f41ccb346ec68f8d28d11b2 (patch)
treeb2a049f8318da774db9d2d370e230b1bc3c9af64
parentde5dd52d363913bf684aa232c027d1b83fe444d9 (diff)
downloadrpm-helper-f1bc36aedb6cd38a5f41ccb346ec68f8d28d11b2.tar
rpm-helper-f1bc36aedb6cd38a5f41ccb346ec68f8d28d11b2.tar.gz
rpm-helper-f1bc36aedb6cd38a5f41ccb346ec68f8d28d11b2.tar.bz2
rpm-helper-f1bc36aedb6cd38a5f41ccb346ec68f8d28d11b2.tar.xz
rpm-helper-f1bc36aedb6cd38a5f41ccb346ec68f8d28d11b2.zip
create-ssl-certificate: ShellCheck: fix quoting issues and undefined behaviour
-rwxr-xr-xcreate-ssl-certificate20
1 files 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 <group>] [-b] <pkg name> <num installed> <service>" 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