mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-08-01 12:24:43 +00:00
shellcheck: Double quote to prevent globbing and word splitting
This patch is needed to pass Automation Hub tests.
This commit is contained in:
@@ -21,36 +21,36 @@ function generate_ipa_pkcs12_certificate {
|
|||||||
# Generate CSR and private key
|
# Generate CSR and private key
|
||||||
openssl req -new -newkey rsa:4096 -nodes \
|
openssl req -new -newkey rsa:4096 -nodes \
|
||||||
-subj "/C=US/ST=Test/L=Testing/O=Default/CN=${ipa_fqdn}" \
|
-subj "/C=US/ST=Test/L=Testing/O=Default/CN=${ipa_fqdn}" \
|
||||||
-keyout ${certs_dir}/private.key \
|
-keyout "${certs_dir}/private.key" \
|
||||||
-out ${certs_dir}/request.csr
|
-out "${certs_dir}/request.csr"
|
||||||
|
|
||||||
# Sign CSR to generate PEM certificate
|
# Sign CSR to generate PEM certificate
|
||||||
if [ -z "${extensions_file}" ]; then
|
if [ -z "${extensions_file}" ]; then
|
||||||
openssl x509 -req -days 365 -sha256 \
|
openssl x509 -req -days 365 -sha256 \
|
||||||
-CAcreateserial \
|
-CAcreateserial \
|
||||||
-CA ${root_ca_cert} \
|
-CA "${root_ca_cert}" \
|
||||||
-CAkey ${root_ca_private_key} \
|
-CAkey "${root_ca_private_key}" \
|
||||||
-in ${certs_dir}/request.csr \
|
-in "${certs_dir}/request.csr" \
|
||||||
-out ${certs_dir}/cert.pem
|
-out "${certs_dir}/cert.pem"
|
||||||
else
|
else
|
||||||
openssl x509 -req -days 365 -sha256 \
|
openssl x509 -req -days 365 -sha256 \
|
||||||
-CAcreateserial \
|
-CAcreateserial \
|
||||||
-CA ${ROOT_CA_DIR}/cert.pem \
|
-CA "${ROOT_CA_DIR}/cert.pem" \
|
||||||
-CAkey ${ROOT_CA_DIR}/private.key \
|
-CAkey "${ROOT_CA_DIR}/private.key" \
|
||||||
-extfile ${extensions_file} \
|
-extfile "${extensions_file}" \
|
||||||
-extensions ${extensions_name} \
|
-extensions "${extensions_name}" \
|
||||||
-in ${certs_dir}/request.csr \
|
-in "${certs_dir}/request.csr" \
|
||||||
-out ${certs_dir}/cert.pem
|
-out "${certs_dir}/cert.pem"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Convert certificate to PKCS12 format
|
# Convert certificate to PKCS12 format
|
||||||
openssl pkcs12 -export \
|
openssl pkcs12 -export \
|
||||||
-name ${cert_name} \
|
-name "${cert_name}" \
|
||||||
-certfile ${root_ca_cert} \
|
-certfile "${root_ca_cert}" \
|
||||||
-in ${certs_dir}/cert.pem \
|
-in "${certs_dir}/cert.pem" \
|
||||||
-inkey ${certs_dir}/private.key \
|
-inkey "${certs_dir}/private.key" \
|
||||||
-passout "pass:${PKCS12_PASSWORD}" \
|
-passout "pass:${PKCS12_PASSWORD}" \
|
||||||
-out ${certs_dir}/cert.p12
|
-out "${certs_dir}/cert.p12"
|
||||||
}
|
}
|
||||||
|
|
||||||
# generate_ipa_pkcs12_certificates $ipa_fqdn $ipa_domain
|
# generate_ipa_pkcs12_certificates $ipa_fqdn $ipa_domain
|
||||||
@@ -73,27 +73,27 @@ function generate_ipa_pkcs12_certificates {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Generate certificates folder structure
|
# Generate certificates folder structure
|
||||||
mkdir -p ${ROOT_CA_DIR}
|
mkdir -p "${ROOT_CA_DIR}"
|
||||||
mkdir -p ${DIRSRV_CERTS_DIR}/$host
|
mkdir -p "${DIRSRV_CERTS_DIR}/$host"
|
||||||
mkdir -p ${HTTPD_CERTS_DIR}/$host
|
mkdir -p "${HTTPD_CERTS_DIR}/$host"
|
||||||
mkdir -p ${PKINIT_CERTS_DIR}/$host
|
mkdir -p "${PKINIT_CERTS_DIR}/$host"
|
||||||
|
|
||||||
# Generate root CA
|
# Generate root CA
|
||||||
if [ ! -f "${ROOT_CA_DIR}/private.key" ]; then
|
if [ ! -f "${ROOT_CA_DIR}/private.key" ]; then
|
||||||
openssl genrsa \
|
openssl genrsa \
|
||||||
-out ${ROOT_CA_DIR}/private.key 4096
|
-out "${ROOT_CA_DIR}/private.key" 4096
|
||||||
|
|
||||||
openssl req -new -x509 -sha256 -nodes -days 3650 \
|
openssl req -new -x509 -sha256 -nodes -days 3650 \
|
||||||
-subj "/C=US/ST=Test/L=Testing/O=Default" \
|
-subj "/C=US/ST=Test/L=Testing/O=Default" \
|
||||||
-key ${ROOT_CA_DIR}/private.key \
|
-key "${ROOT_CA_DIR}/private.key" \
|
||||||
-out ${ROOT_CA_DIR}/cert.pem
|
-out "${ROOT_CA_DIR}/cert.pem"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Generate a certificate for the Directory Server
|
# Generate a certificate for the Directory Server
|
||||||
if [ ! -f "${DIRSRV_CERTS_DIR}/$host/cert.pem" ]; then
|
if [ ! -f "${DIRSRV_CERTS_DIR}/$host/cert.pem" ]; then
|
||||||
generate_ipa_pkcs12_certificate \
|
generate_ipa_pkcs12_certificate \
|
||||||
"dirsrv-cert" \
|
"dirsrv-cert" \
|
||||||
$host \
|
"$host" \
|
||||||
"${DIRSRV_CERTS_DIR}/$host" \
|
"${DIRSRV_CERTS_DIR}/$host" \
|
||||||
"${ROOT_CA_DIR}/cert.pem" \
|
"${ROOT_CA_DIR}/cert.pem" \
|
||||||
"${ROOT_CA_DIR}/private.key"
|
"${ROOT_CA_DIR}/private.key"
|
||||||
@@ -103,7 +103,7 @@ function generate_ipa_pkcs12_certificates {
|
|||||||
if [ ! -f "${HTTPD_CERTS_DIR}/$host/cert.pem" ]; then
|
if [ ! -f "${HTTPD_CERTS_DIR}/$host/cert.pem" ]; then
|
||||||
generate_ipa_pkcs12_certificate \
|
generate_ipa_pkcs12_certificate \
|
||||||
"httpd-cert" \
|
"httpd-cert" \
|
||||||
$host \
|
"$host" \
|
||||||
"${HTTPD_CERTS_DIR}/$host" \
|
"${HTTPD_CERTS_DIR}/$host" \
|
||||||
"${ROOT_CA_DIR}/cert.pem" \
|
"${ROOT_CA_DIR}/cert.pem" \
|
||||||
"${ROOT_CA_DIR}/private.key"
|
"${ROOT_CA_DIR}/private.key"
|
||||||
@@ -115,7 +115,7 @@ function generate_ipa_pkcs12_certificates {
|
|||||||
|
|
||||||
generate_ipa_pkcs12_certificate \
|
generate_ipa_pkcs12_certificate \
|
||||||
"pkinit-cert" \
|
"pkinit-cert" \
|
||||||
$host \
|
"$host" \
|
||||||
"${PKINIT_CERTS_DIR}/$host" \
|
"${PKINIT_CERTS_DIR}/$host" \
|
||||||
"${ROOT_CA_DIR}/cert.pem" \
|
"${ROOT_CA_DIR}/cert.pem" \
|
||||||
"${ROOT_CA_DIR}/private.key" \
|
"${ROOT_CA_DIR}/private.key" \
|
||||||
@@ -135,17 +135,17 @@ function delete_ipa_pkcs12_certificates {
|
|||||||
exit 0;
|
exit 0;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -f certificates/*/$host/*
|
rm -f certificates/*/"$host"/*
|
||||||
rm -f ${ROOT_CA_DIR}/*
|
rm -f "${ROOT_CA_DIR}"/*
|
||||||
}
|
}
|
||||||
|
|
||||||
# Entrypoint
|
# Entrypoint
|
||||||
case "$1" in
|
case "$1" in
|
||||||
create)
|
create)
|
||||||
generate_ipa_pkcs12_certificates $2 $3
|
generate_ipa_pkcs12_certificates "$2" "$3"
|
||||||
;;
|
;;
|
||||||
delete)
|
delete)
|
||||||
delete_ipa_pkcs12_certificates $2
|
delete_ipa_pkcs12_certificates "$2"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo $"Usage: $0 {create|delete}"
|
echo $"Usage: $0 {create|delete}"
|
||||||
|
|||||||
@@ -4,24 +4,26 @@ NUM=${1-1000}
|
|||||||
FILE="users.json"
|
FILE="users.json"
|
||||||
date=$(date --date='+2 years' "+%Y-%m-%d %H:%M:%S")
|
date=$(date --date='+2 years' "+%Y-%m-%d %H:%M:%S")
|
||||||
|
|
||||||
echo "{" > $FILE
|
echo "{" > "$FILE"
|
||||||
|
|
||||||
echo " \"users\": [" >> $FILE
|
echo " \"users\": [" >> "$FILE"
|
||||||
|
|
||||||
for i in $(seq 1 $NUM); do
|
for i in $(seq 1 "$NUM"); do
|
||||||
echo " {" >> $FILE
|
{
|
||||||
echo " \"name\": \"user$i\"," >> $FILE
|
echo " {"
|
||||||
echo " \"first\": \"First $i\"," >> $FILE
|
echo " \"name\": \"user$i\","
|
||||||
echo " \"last\": \"Last $i\"," >> $FILE
|
echo " \"first\": \"First $i\","
|
||||||
echo " \"password\": \"user${i}PW\"," >> $FILE
|
echo " \"last\": \"Last $i\","
|
||||||
echo " \"passwordexpiration\": \"$date\"" >> $FILE
|
echo " \"password\": \"user${i}PW\","
|
||||||
if [ $i -lt $NUM ]; then
|
echo " \"passwordexpiration\": \"$date\""
|
||||||
echo " }," >> $FILE
|
} >> "$FILE"
|
||||||
|
if [ "$i" -lt "$NUM" ]; then
|
||||||
|
echo " }," >> "$FILE"
|
||||||
else
|
else
|
||||||
echo " }" >> $FILE
|
echo " }" >> "$FILE"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
echo " ]" >> $FILE
|
echo " ]" >> "$FILE"
|
||||||
|
|
||||||
echo "}" >> $FILE
|
echo "}" >> "$FILE"
|
||||||
|
|||||||
@@ -3,20 +3,20 @@
|
|||||||
NUM=1000
|
NUM=1000
|
||||||
FILE="users_absent.json"
|
FILE="users_absent.json"
|
||||||
|
|
||||||
echo "{" > $FILE
|
echo "{" > "$FILE"
|
||||||
|
|
||||||
echo " \"users\": [" >> $FILE
|
echo " \"users\": [" >> "$FILE"
|
||||||
|
|
||||||
for i in $(seq 1 $NUM); do
|
for i in $(seq 1 "$NUM"); do
|
||||||
echo " {" >> $FILE
|
echo " {" >> "$FILE"
|
||||||
echo " \"name\": \"user$i\"," >> $FILE
|
echo " \"name\": \"user$i\"," >> "$FILE"
|
||||||
if [ $i -lt $NUM ]; then
|
if [ "$i" -lt "$NUM" ]; then
|
||||||
echo " }," >> $FILE
|
echo " }," >> "$FILE"
|
||||||
else
|
else
|
||||||
echo " }" >> $FILE
|
echo " }" >> "$FILE"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
echo " ]" >> $FILE
|
echo " ]" >> "$FILE"
|
||||||
|
|
||||||
echo "}" >> $FILE
|
echo "}" >> "$FILE"
|
||||||
|
|||||||
Reference in New Issue
Block a user