Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Ansible FreeIPA
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirror
Ansible FreeIPA
Commits
cd3646ad
Commit
cd3646ad
authored
3 years ago
by
Thomas Woerner
Browse files
Options
Downloads
Patches
Plain Diff
shellcheck: Double quote to prevent globbing and word splitting
This patch is needed to pass Automation Hub tests.
parent
2e8c2f88
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
tests/ca-less/generate-certificates.sh
+31
-31
31 additions, 31 deletions
tests/ca-less/generate-certificates.sh
tests/user/users.sh
+16
-14
16 additions, 14 deletions
tests/user/users.sh
tests/user/users_absent.sh
+10
-10
10 additions, 10 deletions
tests/user/users_absent.sh
with
57 additions
and
55 deletions
tests/ca-less/generate-certificates.sh
+
31
−
31
View file @
cd3646ad
...
...
@@ -21,36 +21,36 @@ function generate_ipa_pkcs12_certificate {
# Generate CSR and private key
openssl req
-new
-newkey
rsa:4096
-nodes
\
-subj
"/C=US/ST=Test/L=Testing/O=Default/CN=
${
ipa_fqdn
}
"
\
-keyout
${
certs_dir
}
/private.key
\
-out
${
certs_dir
}
/request.csr
-keyout
"
${
certs_dir
}
/private.key
"
\
-out
"
${
certs_dir
}
/request.csr
"
# Sign CSR to generate PEM certificate
if
[
-z
"
${
extensions_file
}
"
]
;
then
openssl x509
-req
-days
365
-sha256
\
-CAcreateserial
\
-CA
${
root_ca_cert
}
\
-CAkey
${
root_ca_private_key
}
\
-in
${
certs_dir
}
/request.csr
\
-out
${
certs_dir
}
/cert.pem
-CA
"
${
root_ca_cert
}
"
\
-CAkey
"
${
root_ca_private_key
}
"
\
-in
"
${
certs_dir
}
/request.csr
"
\
-out
"
${
certs_dir
}
/cert.pem
"
else
openssl x509
-req
-days
365
-sha256
\
-CAcreateserial
\
-CA
${
ROOT_CA_DIR
}
/cert.pem
\
-CAkey
${
ROOT_CA_DIR
}
/private.key
\
-extfile
${
extensions_file
}
\
-extensions
${
extensions_name
}
\
-in
${
certs_dir
}
/request.csr
\
-out
${
certs_dir
}
/cert.pem
-CA
"
${
ROOT_CA_DIR
}
/cert.pem
"
\
-CAkey
"
${
ROOT_CA_DIR
}
/private.key
"
\
-extfile
"
${
extensions_file
}
"
\
-extensions
"
${
extensions_name
}
"
\
-in
"
${
certs_dir
}
/request.csr
"
\
-out
"
${
certs_dir
}
/cert.pem
"
fi
# Convert certificate to PKCS12 format
openssl pkcs12
-export
\
-name
${
cert_name
}
\
-certfile
${
root_ca_cert
}
\
-in
${
certs_dir
}
/cert.pem
\
-inkey
${
certs_dir
}
/private.key
\
-name
"
${
cert_name
}
"
\
-certfile
"
${
root_ca_cert
}
"
\
-in
"
${
certs_dir
}
/cert.pem
"
\
-inkey
"
${
certs_dir
}
/private.key
"
\
-passout
"pass:
${
PKCS12_PASSWORD
}
"
\
-out
${
certs_dir
}
/cert.p12
-out
"
${
certs_dir
}
/cert.p12
"
}
# generate_ipa_pkcs12_certificates $ipa_fqdn $ipa_domain
...
...
@@ -73,27 +73,27 @@ function generate_ipa_pkcs12_certificates {
fi
# Generate certificates folder structure
mkdir
-p
${
ROOT_CA_DIR
}
mkdir
-p
${
DIRSRV_CERTS_DIR
}
/
$host
mkdir
-p
${
HTTPD_CERTS_DIR
}
/
$host
mkdir
-p
${
PKINIT_CERTS_DIR
}
/
$host
mkdir
-p
"
${
ROOT_CA_DIR
}
"
mkdir
-p
"
${
DIRSRV_CERTS_DIR
}
/
$host
"
mkdir
-p
"
${
HTTPD_CERTS_DIR
}
/
$host
"
mkdir
-p
"
${
PKINIT_CERTS_DIR
}
/
$host
"
# Generate root CA
if
[
!
-f
"
${
ROOT_CA_DIR
}
/private.key"
]
;
then
openssl genrsa
\
-out
${
ROOT_CA_DIR
}
/private.key 4096
-out
"
${
ROOT_CA_DIR
}
/private.key
"
4096
openssl req
-new
-x509
-sha256
-nodes
-days
3650
\
-subj
"/C=US/ST=Test/L=Testing/O=Default"
\
-key
${
ROOT_CA_DIR
}
/private.key
\
-out
${
ROOT_CA_DIR
}
/cert.pem
-key
"
${
ROOT_CA_DIR
}
/private.key
"
\
-out
"
${
ROOT_CA_DIR
}
/cert.pem
"
fi
# Generate a certificate for the Directory Server
if
[
!
-f
"
${
DIRSRV_CERTS_DIR
}
/
$host
/cert.pem"
]
;
then
generate_ipa_pkcs12_certificate
\
"dirsrv-cert"
\
$host
\
"
$host
"
\
"
${
DIRSRV_CERTS_DIR
}
/
$host
"
\
"
${
ROOT_CA_DIR
}
/cert.pem"
\
"
${
ROOT_CA_DIR
}
/private.key"
...
...
@@ -103,7 +103,7 @@ function generate_ipa_pkcs12_certificates {
if
[
!
-f
"
${
HTTPD_CERTS_DIR
}
/
$host
/cert.pem"
]
;
then
generate_ipa_pkcs12_certificate
\
"httpd-cert"
\
$host
\
"
$host
"
\
"
${
HTTPD_CERTS_DIR
}
/
$host
"
\
"
${
ROOT_CA_DIR
}
/cert.pem"
\
"
${
ROOT_CA_DIR
}
/private.key"
...
...
@@ -115,7 +115,7 @@ function generate_ipa_pkcs12_certificates {
generate_ipa_pkcs12_certificate
\
"pkinit-cert"
\
$host
\
"
$host
"
\
"
${
PKINIT_CERTS_DIR
}
/
$host
"
\
"
${
ROOT_CA_DIR
}
/cert.pem"
\
"
${
ROOT_CA_DIR
}
/private.key"
\
...
...
@@ -135,17 +135,17 @@ function delete_ipa_pkcs12_certificates {
exit
0
;
fi
rm
-f
certificates/
*
/
$host
/
*
rm
-f
${
ROOT_CA_DIR
}
/
*
rm
-f
certificates/
*
/
"
$host
"
/
*
rm
-f
"
${
ROOT_CA_DIR
}
"
/
*
}
# Entrypoint
case
"
$1
"
in
create
)
generate_ipa_pkcs12_certificates
$2
$3
generate_ipa_pkcs12_certificates
"
$2
"
"
$3
"
;;
delete
)
delete_ipa_pkcs12_certificates
$2
delete_ipa_pkcs12_certificates
"
$2
"
;;
*
)
echo
$"Usage:
$0
{create|delete}"
...
...
This diff is collapsed.
Click to expand it.
tests/user/users.sh
+
16
−
14
View file @
cd3646ad
...
...
@@ -4,24 +4,26 @@ NUM=${1-1000}
FILE
=
"users.json"
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
echo
" {"
>>
$FILE
echo
"
\"
name
\"
:
\"
user
$i
\"
,"
>>
$FILE
echo
"
\"
first
\"
:
\"
First
$i
\"
,"
>>
$FILE
echo
"
\"
last
\"
:
\"
Last
$i
\"
,"
>>
$FILE
echo
"
\"
password
\"
:
\"
user
${
i
}
PW
\"
,"
>>
$FILE
echo
"
\"
passwordexpiration
\"
:
\"
$date
\"
"
>>
$FILE
if
[
$i
-lt
$NUM
]
;
then
echo
" },"
>>
$FILE
for
i
in
$(
seq
1
"
$NUM
"
)
;
do
{
echo
" {"
echo
"
\"
name
\"
:
\"
user
$i
\"
,"
echo
"
\"
first
\"
:
\"
First
$i
\"
,"
echo
"
\"
last
\"
:
\"
Last
$i
\"
,"
echo
"
\"
password
\"
:
\"
user
${
i
}
PW
\"
,"
echo
"
\"
passwordexpiration
\"
:
\"
$date
\"
"
}
>>
"
$FILE
"
if
[
"
$i
"
-lt
"
$NUM
"
]
;
then
echo
" },"
>>
"
$FILE
"
else
echo
" }"
>>
$FILE
echo
" }"
>>
"
$FILE
"
fi
done
echo
" ]"
>>
$FILE
echo
" ]"
>>
"
$FILE
"
echo
"}"
>>
$FILE
echo
"}"
>>
"
$FILE
"
This diff is collapsed.
Click to expand it.
tests/user/users_absent.sh
+
10
−
10
View file @
cd3646ad
...
...
@@ -3,20 +3,20 @@
NUM
=
1000
FILE
=
"users_absent.json"
echo
"{"
>
$FILE
echo
"{"
>
"
$FILE
"
echo
"
\"
users
\"
: ["
>>
$FILE
echo
"
\"
users
\"
: ["
>>
"
$FILE
"
for
i
in
$(
seq
1
$NUM
)
;
do
echo
" {"
>>
$FILE
echo
"
\"
name
\"
:
\"
user
$i
\"
,"
>>
$FILE
if
[
$i
-lt
$NUM
]
;
then
echo
" },"
>>
$FILE
for
i
in
$(
seq
1
"
$NUM
"
)
;
do
echo
" {"
>>
"
$FILE
"
echo
"
\"
name
\"
:
\"
user
$i
\"
,"
>>
"
$FILE
"
if
[
"
$i
"
-lt
"
$NUM
"
]
;
then
echo
" },"
>>
"
$FILE
"
else
echo
" }"
>>
$FILE
echo
" }"
>>
"
$FILE
"
fi
done
echo
" ]"
>>
$FILE
echo
" ]"
>>
"
$FILE
"
echo
"}"
>>
$FILE
echo
"}"
>>
"
$FILE
"
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment