Skip to content

Commit 6fd5454

Browse files
[openvpn] Address config discovery review feedback #572
- Replaced ls with find for safer file discovery. - Handled edge case where stale openvpn.conf could be selected. - Updated logic per CodeRabbit review recommendations. Fixes #572
1 parent 67bfbc0 commit 6fd5454

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

images/common/utils.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,13 @@ function openvpn_config_download {
243243
${API_INTERNAL}/controller/vpn/checksum/$UUID/?key=$KEY
244244
tar xzf vpn.tar.gz
245245
chmod 600 *.pem
246-
247-
# Dynamically locate the config file and standardize its name for supervisord
248-
CONF_FILE=$(ls *.conf 2>/dev/null | head -n 1)
249-
if [ -n "$CONF_FILE" ] && [ "$CONF_FILE" != "openvpn.conf" ]; then
250-
mv "$CONF_FILE" openvpn.conf
246+
# Prefer a newly extracted non-standard filename and normalize it.
247+
CONF_FILE=$(find . -maxdepth 1 -type f -name '*.conf' ! -name 'openvpn.conf' -print -quit)
248+
if [ -n "$CONF_FILE" ]; then
249+
mv -f -- "$CONF_FILE" openvpn.conf
250+
elif [ ! -f openvpn.conf ]; then
251+
echo "ERROR: no OpenVPN config file found after extraction" >&2
252+
return 1
251253
fi
252254
}
253255

0 commit comments

Comments
 (0)