Skip to content

Commit ee36e47

Browse files
committed
ASU-1793: Fix init.sh pem key handling
1 parent 0a8b660 commit ee36e47

1 file changed

Lines changed: 9 additions & 14 deletions

File tree

docker/openshift/init.sh

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,19 @@ if [ -n "${DRUPAL_SIMPLE_OAUTH_PRIVATE_KEY_PEM}" ] || [ -n "${DRUPAL_SIMPLE_OAUT
2121
# Create files with correct permissions even when chmod is blocked.
2222
umask 077
2323

24+
# Always rewrite the key files when the env vars are set so that corrupt
25+
# contents from previous deploys are replaced. rm+create ensures a fresh
26+
# inode with the current umask.
2427
if [ -n "${DRUPAL_SIMPLE_OAUTH_PRIVATE_KEY_PEM}" ]; then
25-
if [ -f "${private_key_path}" ] && ! chmod 600 "${private_key_path}" 2>/dev/null; then
26-
rm -f "${private_key_path}" || true
27-
fi
28-
if [ ! -f "${private_key_path}" ]; then
29-
printf '%b\n' "${DRUPAL_SIMPLE_OAUTH_PRIVATE_KEY_PEM}" > "${private_key_path}"
30-
chmod 600 "${private_key_path}" || true
31-
fi
28+
rm -f "${private_key_path}" 2>/dev/null || true
29+
printf '%b\n' "${DRUPAL_SIMPLE_OAUTH_PRIVATE_KEY_PEM}" > "${private_key_path}"
30+
chmod 600 "${private_key_path}" 2>/dev/null || true
3231
fi
3332

3433
if [ -n "${DRUPAL_SIMPLE_OAUTH_PUBLIC_KEY_PEM}" ]; then
35-
if [ -f "${public_key_path}" ] && ! chmod 600 "${public_key_path}" 2>/dev/null; then
36-
rm -f "${public_key_path}" || true
37-
fi
38-
if [ ! -f "${public_key_path}" ]; then
39-
printf '%b\n' "${DRUPAL_SIMPLE_OAUTH_PUBLIC_KEY_PEM}" > "${public_key_path}"
40-
chmod 600 "${public_key_path}" || true
41-
fi
34+
rm -f "${public_key_path}" 2>/dev/null || true
35+
printf '%b\n' "${DRUPAL_SIMPLE_OAUTH_PUBLIC_KEY_PEM}" > "${public_key_path}"
36+
chmod 644 "${public_key_path}" 2>/dev/null || true
4237
fi
4338

4439
umask "${old_umask}" || true

0 commit comments

Comments
 (0)