From a6a3b421c524bedf167d7d4cf94a49ca785a4131 Mon Sep 17 00:00:00 2001 From: Damien Date: Tue, 26 May 2026 17:42:24 +0200 Subject: [PATCH] Add cleanup for temporary directory Previously the temporary directory was removed via the RETURN trap but this could be bypassed if the script exited early. Now we explicitly clean up the directory in all exit paths. --- openbao/install.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openbao/install.sh b/openbao/install.sh index c5cc2c3..af92848 100755 --- a/openbao/install.sh +++ b/openbao/install.sh @@ -119,12 +119,12 @@ install_or_upgrade_bao() { log_info "Downloading OpenBao ${tag} (${arch}) from ${url}..." tmpdir=$(mktemp -d) - trap 'rm -rf "$tmpdir"' RETURN curl -fsSL "$url" -o "${tmpdir}/bao.tar.gz" tar -xzf "${tmpdir}/bao.tar.gz" -C "$tmpdir" if [[ ! -f "${tmpdir}/bao" ]]; then log_error "Archive did not contain expected 'bao' binary." + rm -rf "$tmpdir" exit 1 fi @@ -149,6 +149,8 @@ install_or_upgrade_bao() { log_info "Restarting openbao service..." rc-service openbao start fi + + rm -rf "$tmpdir" } # ============================================================