diff options
| author | Haixiao Yan <haixiao.yan.cn@windriver.com> | 2025-09-12 09:59:33 +0800 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-09-15 17:57:23 +0100 |
| commit | f5adf527f2e3279432800218986505f894167d3d (patch) | |
| tree | 5e97bafcaa389f6a0cb09c6198b18ae33eb5337e | |
| parent | 6091eb2b58a5004f68acb1819387eb80a1001ca6 (diff) | |
| download | poky-f5adf527f2e3279432800218986505f894167d3d.tar.gz | |
buildtools-tarball: fix unbound variable issues under 'set -u'
When Bash runs with 'set -u' (nounset), accessing an unset variable
directly (e.g. [ -z "$SSL_CERT_FILE" ]) causes a fatal "unbound variable"
error. As a result, the fallback logic to set SSL_CERT_FILE/SSL_CERT_DIR
is never triggered and the script aborts.
The current code assumes these variables may be unset or empty, but does
not guard against 'set -u'. This breaks builds in stricter shell
environments or when users explicitly enable 'set -u'.
Fix this by using parameter expansion with a default value, e.g.
"${SSL_CERT_FILE:-}", so that unset variables are treated as empty
strings. This preserves the intended logic (respect host env first, then
CAFILE/CAPATH, then buildtools defaults) and makes the script robust
under 'set -u'.
(From OE-Core rev: 4d880c2eccd534133a2a4e6579d955605c0956ec)
Signed-off-by: Haixiao Yan <haixiao.yan.cn@windriver.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
4 files changed, 14 insertions, 14 deletions
diff --git a/meta/recipes-connectivity/openssl/files/environment.d-openssl.sh b/meta/recipes-connectivity/openssl/files/environment.d-openssl.sh index 71d378734c..0e75e34f9d 100644 --- a/meta/recipes-connectivity/openssl/files/environment.d-openssl.sh +++ b/meta/recipes-connectivity/openssl/files/environment.d-openssl.sh | |||
| @@ -5,16 +5,16 @@ export BB_ENV_PASSTHROUGH_ADDITIONS="${BB_ENV_PASSTHROUGH_ADDITIONS:-} OPENSSL_C | |||
| 5 | 5 | ||
| 6 | # Respect host env SSL_CERT_FILE/SSL_CERT_DIR first, then auto-detected host cert, then cert in buildtools | 6 | # Respect host env SSL_CERT_FILE/SSL_CERT_DIR first, then auto-detected host cert, then cert in buildtools |
| 7 | # CAFILE/CAPATH is auto-deteced when source buildtools | 7 | # CAFILE/CAPATH is auto-deteced when source buildtools |
| 8 | if [ -z "$SSL_CERT_FILE" ]; then | 8 | if [ -z "${SSL_CERT_FILE:-}" ]; then |
| 9 | if [ -n "$CAFILE" ];then | 9 | if [ -n "${CAFILE:-}" ];then |
| 10 | export SSL_CERT_FILE="$CAFILE" | 10 | export SSL_CERT_FILE="$CAFILE" |
| 11 | elif [ -e "${OECORE_NATIVE_SYSROOT}/etc/ssl/certs/ca-certificates.crt" ];then | 11 | elif [ -e "${OECORE_NATIVE_SYSROOT}/etc/ssl/certs/ca-certificates.crt" ];then |
| 12 | export SSL_CERT_FILE="$OECORE_NATIVE_SYSROOT/usr/lib/ssl-3/certs/ca-certificates.crt" | 12 | export SSL_CERT_FILE="$OECORE_NATIVE_SYSROOT/usr/lib/ssl-3/certs/ca-certificates.crt" |
| 13 | fi | 13 | fi |
| 14 | fi | 14 | fi |
| 15 | 15 | ||
| 16 | if [ -z "$SSL_CERT_DIR" ]; then | 16 | if [ -z "${SSL_CERT_DIR:-}" ]; then |
| 17 | if [ -n "$CAPATH" ];then | 17 | if [ -n "${CAPATH:-}" ];then |
| 18 | export SSL_CERT_DIR="$CAPATH" | 18 | export SSL_CERT_DIR="$CAPATH" |
| 19 | elif [ -e "${OECORE_NATIVE_SYSROOT}/etc/ssl/certs/ca-certificates.crt" ];then | 19 | elif [ -e "${OECORE_NATIVE_SYSROOT}/etc/ssl/certs/ca-certificates.crt" ];then |
| 20 | export SSL_CERT_DIR="$OECORE_NATIVE_SYSROOT/usr/lib/ssl-3/certs" | 20 | export SSL_CERT_DIR="$OECORE_NATIVE_SYSROOT/usr/lib/ssl-3/certs" |
diff --git a/meta/recipes-devtools/git/git/environment.d-git.sh b/meta/recipes-devtools/git/git/environment.d-git.sh index 9c7b5a9251..fdfa721c3b 100644 --- a/meta/recipes-devtools/git/git/environment.d-git.sh +++ b/meta/recipes-devtools/git/git/environment.d-git.sh | |||
| @@ -1,15 +1,15 @@ | |||
| 1 | # Respect host env GIT_SSL_CAINFO/GIT_SSL_CAPATH first, then auto-detected host cert, then cert in buildtools | 1 | # Respect host env GIT_SSL_CAINFO/GIT_SSL_CAPATH first, then auto-detected host cert, then cert in buildtools |
| 2 | # CAFILE/CAPATH is auto-deteced when source buildtools | 2 | # CAFILE/CAPATH is auto-deteced when source buildtools |
| 3 | if [ -z "$GIT_SSL_CAINFO" ]; then | 3 | if [ -z "${GIT_SSL_CAINFO:-}" ]; then |
| 4 | if [ -n "$CAFILE" ];then | 4 | if [ -n "${CAFILE:-}" ];then |
| 5 | export GIT_SSL_CAINFO="$CAFILE" | 5 | export GIT_SSL_CAINFO="$CAFILE" |
| 6 | elif [ -e "${OECORE_NATIVE_SYSROOT}/etc/ssl/certs/ca-certificates.crt" ];then | 6 | elif [ -e "${OECORE_NATIVE_SYSROOT}/etc/ssl/certs/ca-certificates.crt" ];then |
| 7 | export GIT_SSL_CAINFO="${OECORE_NATIVE_SYSROOT}/etc/ssl/certs/ca-certificates.crt" | 7 | export GIT_SSL_CAINFO="${OECORE_NATIVE_SYSROOT}/etc/ssl/certs/ca-certificates.crt" |
| 8 | fi | 8 | fi |
| 9 | fi | 9 | fi |
| 10 | 10 | ||
| 11 | if [ -z "$GIT_SSL_CAPATH" ]; then | 11 | if [ -z "${GIT_SSL_CAPATH:-}" ]; then |
| 12 | if [ -n "$CAPATH" ];then | 12 | if [ -n "${CAPATH:-}" ];then |
| 13 | export GIT_SSL_CAPATH="$CAPATH" | 13 | export GIT_SSL_CAPATH="$CAPATH" |
| 14 | elif [ -e "${OECORE_NATIVE_SYSROOT}/etc/ssl/certs/ca-certificates.crt" ];then | 14 | elif [ -e "${OECORE_NATIVE_SYSROOT}/etc/ssl/certs/ca-certificates.crt" ];then |
| 15 | export GIT_SSL_CAPATH="${OECORE_NATIVE_SYSROOT}/etc/ssl/certs" | 15 | export GIT_SSL_CAPATH="${OECORE_NATIVE_SYSROOT}/etc/ssl/certs" |
diff --git a/meta/recipes-devtools/python/python3-requests/environment.d-python3-requests.sh b/meta/recipes-devtools/python/python3-requests/environment.d-python3-requests.sh index 492177a9c3..400972814b 100644 --- a/meta/recipes-devtools/python/python3-requests/environment.d-python3-requests.sh +++ b/meta/recipes-devtools/python/python3-requests/environment.d-python3-requests.sh | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | # Respect host env REQUESTS_CA_BUNDLE first, then auto-detected host cert, then cert in buildtools | 1 | # Respect host env REQUESTS_CA_BUNDLE first, then auto-detected host cert, then cert in buildtools |
| 2 | # CAFILE/CAPATH is auto-deteced when source buildtools | 2 | # CAFILE/CAPATH is auto-deteced when source buildtools |
| 3 | if [ -z "$REQUESTS_CA_BUNDLE" ]; then | 3 | if [ -z "${REQUESTS_CA_BUNDLE:-}" ]; then |
| 4 | if [ -n "$CAFILE" ];then | 4 | if [ -n "${CAFILE:-}" ];then |
| 5 | export REQUESTS_CA_BUNDLE="$CAFILE" | 5 | export REQUESTS_CA_BUNDLE="$CAFILE" |
| 6 | elif [ -e "${OECORE_NATIVE_SYSROOT}/etc/ssl/certs/ca-certificates.crt" ];then | 6 | elif [ -e "${OECORE_NATIVE_SYSROOT}/etc/ssl/certs/ca-certificates.crt" ];then |
| 7 | export REQUESTS_CA_BUNDLE="${OECORE_NATIVE_SYSROOT}/etc/ssl/certs/ca-certificates.crt" | 7 | export REQUESTS_CA_BUNDLE="${OECORE_NATIVE_SYSROOT}/etc/ssl/certs/ca-certificates.crt" |
diff --git a/meta/recipes-support/curl/curl/environment.d-curl.sh b/meta/recipes-support/curl/curl/environment.d-curl.sh index 7c2971b3da..581108ef35 100644 --- a/meta/recipes-support/curl/curl/environment.d-curl.sh +++ b/meta/recipes-support/curl/curl/environment.d-curl.sh | |||
| @@ -1,15 +1,15 @@ | |||
| 1 | # Respect host env CURL_CA_BUNDLE/CURL_CA_PATH first, then auto-detected host cert, then cert in buildtools | 1 | # Respect host env CURL_CA_BUNDLE/CURL_CA_PATH first, then auto-detected host cert, then cert in buildtools |
| 2 | # CAFILE/CAPATH is auto-deteced when source buildtools | 2 | # CAFILE/CAPATH is auto-deteced when source buildtools |
| 3 | if [ -z "$CURL_CA_PATH" ]; then | 3 | if [ -z "${CURL_CA_PATH:-}" ]; then |
| 4 | if [ -n "$CAFILE" ];then | 4 | if [ -n "${CAFILE:-}" ];then |
| 5 | export CURL_CA_BUNDLE="$CAFILE" | 5 | export CURL_CA_BUNDLE="$CAFILE" |
| 6 | elif [ -e "${OECORE_NATIVE_SYSROOT}/etc/ssl/certs/ca-certificates.crt" ];then | 6 | elif [ -e "${OECORE_NATIVE_SYSROOT}/etc/ssl/certs/ca-certificates.crt" ];then |
| 7 | export CURL_CA_BUNDLE="${OECORE_NATIVE_SYSROOT}/etc/ssl/certs/ca-certificates.crt" | 7 | export CURL_CA_BUNDLE="${OECORE_NATIVE_SYSROOT}/etc/ssl/certs/ca-certificates.crt" |
| 8 | fi | 8 | fi |
| 9 | fi | 9 | fi |
| 10 | 10 | ||
| 11 | if [ -z "$CURL_CA_PATH" ]; then | 11 | if [ -z "${CURL_CA_PATH:-}" ]; then |
| 12 | if [ -n "$CAPATH" ];then | 12 | if [ -n "${CAPATH:-}" ];then |
| 13 | export CURL_CA_PATH="$CAPATH" | 13 | export CURL_CA_PATH="$CAPATH" |
| 14 | elif [ -e "${OECORE_NATIVE_SYSROOT}/etc/ssl/certs/ca-certificates.crt" ];then | 14 | elif [ -e "${OECORE_NATIVE_SYSROOT}/etc/ssl/certs/ca-certificates.crt" ];then |
| 15 | export CURL_CA_PATH="${OECORE_NATIVE_SYSROOT}/etc/ssl/certs" | 15 | export CURL_CA_PATH="${OECORE_NATIVE_SYSROOT}/etc/ssl/certs" |
