Skip to content

Commit 29a5268

Browse files
kpougetpraveenkumar
authored andcommitted
systemd/crc-cluster-status.sh: don't leak the kubeadmin password
1 parent 8e354dc commit 29a5268

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

systemd/crc-cluster-status.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/bin/bash
22

3+
set -o pipefail
4+
set -o errexit
5+
set -o nounset
6+
set -o errtrace
37
set -x
48

59
export KUBECONFIG=/opt/kubeconfig
@@ -9,19 +13,19 @@ if [ ! -f /opt/crc/pass_kubeadmin ]; then
913
exit 1
1014
fi
1115

12-
PASS_KUBEADMIN="$(cat /opt/crc/pass_kubeadmin)"
13-
1416
rm -rf /tmp/.crc-cluster-ready
1517

1618
if ! oc adm wait-for-stable-cluster --minimum-stable-period=1m --timeout=10m; then
1719
exit 1
1820
fi
1921

20-
set +x
22+
2123
echo "Logging into OpenShift with kubeadmin user to update $KUBECONFIG"
2224
COUNTER=1
2325
MAXIMUM_LOGIN_RETRY=10
24-
until oc login --insecure-skip-tls-verify=true -u kubeadmin -p "$PASS_KUBEADMIN" https://api.crc.testing:6443 > /dev/null 2>&1; do
26+
27+
# use a `(set +x)` subshell to avoid leaking the password
28+
until (set +x ; oc login --insecure-skip-tls-verify=true -u kubeadmin -p "$(cat /opt/crc/pass_kubeadmin)" https://api.crc.testing:6443 > /dev/null 2>&1); do
2529
if [ "$COUNTER" -ge "$MAXIMUM_LOGIN_RETRY" ]; then
2630
echo "Unable to login to the cluster..., authentication failed."
2731
exit 1
@@ -33,4 +37,3 @@ done
3337

3438
# need to set a marker to let `crc` know the cluster is ready
3539
touch /tmp/.crc-cluster-ready
36-

0 commit comments

Comments
 (0)