diff --git a/bitnami/pgbouncer/1/debian-12/Dockerfile b/bitnami/pgbouncer/1/debian-12/Dockerfile index 7abf1bb66f79..67f0ec316406 100644 --- a/bitnami/pgbouncer/1/debian-12/Dockerfile +++ b/bitnami/pgbouncer/1/debian-12/Dockerfile @@ -7,7 +7,7 @@ ARG DOWNLOADS_URL="downloads.bitnami.com/files/stacksmith" ARG TARGETARCH LABEL org.opencontainers.image.base.name="docker.io/bitnami/minideb:bookworm" \ - org.opencontainers.image.created="2026-05-23T10:14:23Z" \ + org.opencontainers.image.created="2026-05-27T13:22:46Z" \ org.opencontainers.image.description="Application packaged by Broadcom, Inc." \ org.opencontainers.image.documentation="https://github.com/bitnami/containers/tree/main/bitnami/pgbouncer/README.md" \ org.opencontainers.image.source="https://github.com/bitnami/containers/tree/main/bitnami/pgbouncer" \ @@ -37,12 +37,12 @@ RUN --mount=type=secret,id=downloads_url,env=SECRET_DOWNLOADS_URL \ for COMPONENT in "${COMPONENTS[@]}"; do \ if [ ! -f "${COMPONENT}.tar.gz" ]; then \ curl -SsLf "https://${DOWNLOADS_URL}/${COMPONENT}.tar.gz" -O ; \ - curl -SsLf "https://${DOWNLOADS_URL}/${COMPONENT}.tar.gz.sha256" -O ; \ fi ; \ - sha256sum -c "${COMPONENT}.tar.gz.sha256" ; \ + sha256sum -c "/opt/bitnami/checksums/${COMPONENT}.tar.gz.sha256" ; \ tar -zxf "${COMPONENT}.tar.gz" -C /opt/bitnami --strip-components=2 --no-same-owner ; \ - rm -rf "${COMPONENT}".tar.gz{,.sha256} ; \ - done + rm -rf "${COMPONENT}".tar.gz ; \ + done ; \ + rm -rf /opt/bitnami/checksums ; RUN apt-get update && apt-get upgrade -y && \ apt-get clean && rm -rf /var/lib/apt/lists /var/cache/apt/archives RUN chmod g+rwX /opt/bitnami @@ -57,7 +57,7 @@ COPY rootfs / RUN /opt/bitnami/scripts/pgbouncer/postunpack.sh ENV APP_VERSION="1.25.2" \ BITNAMI_APP_NAME="pgbouncer" \ - IMAGE_REVISION="3" \ + IMAGE_REVISION="4" \ LANG="en_US.UTF-8" \ LANGUAGE="en_US:en" \ LD_LIBRARY_PATH="/opt/bitnami/postgresql/lib:$LD_LIBRARY_PATH" \ diff --git a/bitnami/pgbouncer/1/debian-12/prebuildfs/opt/bitnami/checksums/ini-file-1.4.9-10-linux-amd64-debian-12.tar.gz.sha256 b/bitnami/pgbouncer/1/debian-12/prebuildfs/opt/bitnami/checksums/ini-file-1.4.9-10-linux-amd64-debian-12.tar.gz.sha256 new file mode 100644 index 000000000000..f7f6d777442b --- /dev/null +++ b/bitnami/pgbouncer/1/debian-12/prebuildfs/opt/bitnami/checksums/ini-file-1.4.9-10-linux-amd64-debian-12.tar.gz.sha256 @@ -0,0 +1 @@ +7576302f2870643e4c48e7a4be12fef12e472e68b0b407e6033f812c8742c1f1 ini-file-1.4.9-10-linux-amd64-debian-12.tar.gz diff --git a/bitnami/pgbouncer/1/debian-12/prebuildfs/opt/bitnami/checksums/ini-file-1.4.9-10-linux-arm64-debian-12.tar.gz.sha256 b/bitnami/pgbouncer/1/debian-12/prebuildfs/opt/bitnami/checksums/ini-file-1.4.9-10-linux-arm64-debian-12.tar.gz.sha256 new file mode 100644 index 000000000000..fd41b7a8f0ce --- /dev/null +++ b/bitnami/pgbouncer/1/debian-12/prebuildfs/opt/bitnami/checksums/ini-file-1.4.9-10-linux-arm64-debian-12.tar.gz.sha256 @@ -0,0 +1 @@ +83dd2355db6b63fc46bb02008fdace7510b339c88d91d45abaa256f2a7ae54bd ini-file-1.4.9-10-linux-arm64-debian-12.tar.gz diff --git a/bitnami/pgbouncer/1/debian-12/prebuildfs/opt/bitnami/checksums/nss-wrapper-1.1.16-0-linux-amd64-debian-12.tar.gz.sha256 b/bitnami/pgbouncer/1/debian-12/prebuildfs/opt/bitnami/checksums/nss-wrapper-1.1.16-0-linux-amd64-debian-12.tar.gz.sha256 new file mode 100644 index 000000000000..cf2734607b9e --- /dev/null +++ b/bitnami/pgbouncer/1/debian-12/prebuildfs/opt/bitnami/checksums/nss-wrapper-1.1.16-0-linux-amd64-debian-12.tar.gz.sha256 @@ -0,0 +1 @@ +af31040a9ef21924a1d4c6d3f0bd6a6be9ef701c9e726b9b3997b82394779b6e nss-wrapper-1.1.16-0-linux-amd64-debian-12.tar.gz diff --git a/bitnami/pgbouncer/1/debian-12/prebuildfs/opt/bitnami/checksums/nss-wrapper-1.1.16-0-linux-arm64-debian-12.tar.gz.sha256 b/bitnami/pgbouncer/1/debian-12/prebuildfs/opt/bitnami/checksums/nss-wrapper-1.1.16-0-linux-arm64-debian-12.tar.gz.sha256 new file mode 100644 index 000000000000..c4594d6aa7c5 --- /dev/null +++ b/bitnami/pgbouncer/1/debian-12/prebuildfs/opt/bitnami/checksums/nss-wrapper-1.1.16-0-linux-arm64-debian-12.tar.gz.sha256 @@ -0,0 +1 @@ +9315fee0fbce2e445778f4cddd4b5a9ae657d40bcc4c9534430d8eaeecf7307c nss-wrapper-1.1.16-0-linux-arm64-debian-12.tar.gz diff --git a/bitnami/pgbouncer/1/debian-12/prebuildfs/opt/bitnami/checksums/pgbouncer-1.25.2-0-linux-amd64-debian-12.tar.gz.sha256 b/bitnami/pgbouncer/1/debian-12/prebuildfs/opt/bitnami/checksums/pgbouncer-1.25.2-0-linux-amd64-debian-12.tar.gz.sha256 new file mode 100644 index 000000000000..14a09edbef60 --- /dev/null +++ b/bitnami/pgbouncer/1/debian-12/prebuildfs/opt/bitnami/checksums/pgbouncer-1.25.2-0-linux-amd64-debian-12.tar.gz.sha256 @@ -0,0 +1 @@ +c23d7248d89f7d96810e8f290c1dd9edb63dbb7cffcc72ef4854a97630d5eefe pgbouncer-1.25.2-0-linux-amd64-debian-12.tar.gz diff --git a/bitnami/pgbouncer/1/debian-12/prebuildfs/opt/bitnami/checksums/pgbouncer-1.25.2-0-linux-arm64-debian-12.tar.gz.sha256 b/bitnami/pgbouncer/1/debian-12/prebuildfs/opt/bitnami/checksums/pgbouncer-1.25.2-0-linux-arm64-debian-12.tar.gz.sha256 new file mode 100644 index 000000000000..25d172145ddc --- /dev/null +++ b/bitnami/pgbouncer/1/debian-12/prebuildfs/opt/bitnami/checksums/pgbouncer-1.25.2-0-linux-arm64-debian-12.tar.gz.sha256 @@ -0,0 +1 @@ +ccd2e0aec6505d73d73e5dc8658a9e21154020e354fd5a41b9e9eecee7d758dd pgbouncer-1.25.2-0-linux-arm64-debian-12.tar.gz diff --git a/bitnami/pgbouncer/1/debian-12/prebuildfs/opt/bitnami/checksums/postgresql-client-14.23.0-0-linux-amd64-debian-12.tar.gz.sha256 b/bitnami/pgbouncer/1/debian-12/prebuildfs/opt/bitnami/checksums/postgresql-client-14.23.0-0-linux-amd64-debian-12.tar.gz.sha256 new file mode 100644 index 000000000000..5288cced6350 --- /dev/null +++ b/bitnami/pgbouncer/1/debian-12/prebuildfs/opt/bitnami/checksums/postgresql-client-14.23.0-0-linux-amd64-debian-12.tar.gz.sha256 @@ -0,0 +1 @@ +796173bb91375cbf3a454e5ac29eca0edd9d7c5ef499c9cf35b487a523c0e478 postgresql-client-14.23.0-0-linux-amd64-debian-12.tar.gz diff --git a/bitnami/pgbouncer/1/debian-12/prebuildfs/opt/bitnami/checksums/postgresql-client-14.23.0-0-linux-arm64-debian-12.tar.gz.sha256 b/bitnami/pgbouncer/1/debian-12/prebuildfs/opt/bitnami/checksums/postgresql-client-14.23.0-0-linux-arm64-debian-12.tar.gz.sha256 new file mode 100644 index 000000000000..6a8f9044fbe3 --- /dev/null +++ b/bitnami/pgbouncer/1/debian-12/prebuildfs/opt/bitnami/checksums/postgresql-client-14.23.0-0-linux-arm64-debian-12.tar.gz.sha256 @@ -0,0 +1 @@ +86e1c80b22ca819d17ccb79faf278d37148bc5e48e6f9011e6c256c8892486a8 postgresql-client-14.23.0-0-linux-arm64-debian-12.tar.gz diff --git a/bitnami/pgbouncer/1/debian-12/prebuildfs/opt/bitnami/checksums/wait-for-port-1.0.10-10-linux-amd64-debian-12.tar.gz.sha256 b/bitnami/pgbouncer/1/debian-12/prebuildfs/opt/bitnami/checksums/wait-for-port-1.0.10-10-linux-amd64-debian-12.tar.gz.sha256 new file mode 100644 index 000000000000..c96cae9e8074 --- /dev/null +++ b/bitnami/pgbouncer/1/debian-12/prebuildfs/opt/bitnami/checksums/wait-for-port-1.0.10-10-linux-amd64-debian-12.tar.gz.sha256 @@ -0,0 +1 @@ +4af7eb9cb9f027f08bd67ead26a6585ac71810c7dc396a453df794235e3476b3 wait-for-port-1.0.10-10-linux-amd64-debian-12.tar.gz diff --git a/bitnami/pgbouncer/1/debian-12/prebuildfs/opt/bitnami/checksums/wait-for-port-1.0.10-10-linux-arm64-debian-12.tar.gz.sha256 b/bitnami/pgbouncer/1/debian-12/prebuildfs/opt/bitnami/checksums/wait-for-port-1.0.10-10-linux-arm64-debian-12.tar.gz.sha256 new file mode 100644 index 000000000000..aebeba63fd0f --- /dev/null +++ b/bitnami/pgbouncer/1/debian-12/prebuildfs/opt/bitnami/checksums/wait-for-port-1.0.10-10-linux-arm64-debian-12.tar.gz.sha256 @@ -0,0 +1 @@ +72c721c238602c257e3f933797f266358032e3d2267c4f99707a33de5ee2038e wait-for-port-1.0.10-10-linux-arm64-debian-12.tar.gz diff --git a/bitnami/pgbouncer/1/debian-12/prebuildfs/opt/bitnami/scripts/libfile.sh b/bitnami/pgbouncer/1/debian-12/prebuildfs/opt/bitnami/scripts/libfile.sh index 1c69e0e48a5d..335c1c7c9ef7 100644 --- a/bitnami/pgbouncer/1/debian-12/prebuildfs/opt/bitnami/scripts/libfile.sh +++ b/bitnami/pgbouncer/1/debian-12/prebuildfs/opt/bitnami/scripts/libfile.sh @@ -139,3 +139,40 @@ wait_for_log_entry() { return 1 fi } + +######################## +# Creates a secure temporary file containing the provided secret +# Arguments: +# $1 - secret to write to the temporary file +# Returns: +# String +######################### +credential_to_temp_file() { + local secret="$1" + local tmp_file + + # Use mktemp with a specific prefix for easier debugging if something lingers + if ! tmp_file=$(mktemp "${TMPDIR:-/tmp}/at.cred.XXXXXXXX"); then + echo "Error: Failed to create temp file" >&2 + return 1 + fi + + # Restrict permissions before writing the secret + chmod 0600 "$tmp_file" + # Write secret and ensure it's flushed to disk + printf "%s" "$secret" > "$tmp_file" + # Output the filename so the caller can capture it + echo "$tmp_file" +} + +######################## +# Cleans up temporary files created by credential_to_temp_file +# Arguments: +# None +# Returns: +# None +######################### +cleanup_credentials() { + debug "Cleaning up temporary files containing credentials" + rm -rf "${TMPDIR:-/tmp}"/at.cred.* +} diff --git a/bitnami/pgbouncer/1/debian-12/prebuildfs/opt/bitnami/scripts/libfs.sh b/bitnami/pgbouncer/1/debian-12/prebuildfs/opt/bitnami/scripts/libfs.sh index 1337f6c2dd59..b16efabd3230 100644 --- a/bitnami/pgbouncer/1/debian-12/prebuildfs/opt/bitnami/scripts/libfs.sh +++ b/bitnami/pgbouncer/1/debian-12/prebuildfs/opt/bitnami/scripts/libfs.sh @@ -131,6 +131,7 @@ relativize() { # -d|--dir-mode - mode for files. # -u|--user - user # -g|--group - group +# -n|--no-dereference - do not follow symlinks (use for runtime root chown of daemon-writable dirs) # Returns: # None ######################### @@ -140,6 +141,7 @@ configure_permissions_ownership() { local file_mode="" local user="" local group="" + local follow_symlinks="yes" # Validate arguments shift 1 @@ -161,6 +163,9 @@ configure_permissions_ownership() { shift group="${1:?missing group}" ;; + -n | --no-dereference) + follow_symlinks="no" + ;; *) echo "Invalid command line flag $1" >&2 return 1 @@ -169,22 +174,29 @@ configure_permissions_ownership() { shift done + # -L: follow symlinks and emits the target path + # This is dangerous at runtime, given a co-located lower-privileged process with write access + # to the target path can redirect the chown/chmod to arbitrary paths. Example: + # Lower-privileged process run: ln -s /etc /tmp/etc + # Then, setup.sh runs: configure_permissions_ownership --dir-mode 775 /tmp + local find_L_flag=(); [[ "$follow_symlinks" == "yes" ]] && find_L_flag=("-L") + # -h: changes symlink inode ownership without touching the target. + local chown_flags=(); [[ "$follow_symlinks" == "no" ]] && chown_flags=("-h") read -r -a filepaths <<<"$paths" for p in "${filepaths[@]}"; do if [[ -e "$p" ]]; then - find -L "$p" -printf "" if [[ -n $dir_mode ]]; then - find -L "$p" -type d ! -perm "$dir_mode" -print0 | xargs -r -0 chmod "$dir_mode" + find "${find_L_flag[@]}" "$p" -not -type l -type d ! -perm "$dir_mode" -print0 | xargs -r -0 chmod "$dir_mode" fi if [[ -n $file_mode ]]; then - find -L "$p" -type f ! -perm "$file_mode" -print0 | xargs -r -0 chmod "$file_mode" + find "${find_L_flag[@]}" "$p" -not -type l -type f ! -perm "$file_mode" -print0 | xargs -r -0 chmod "$file_mode" fi if [[ -n $user ]] && [[ -n $group ]]; then - find -L "$p" -print0 | xargs -r -0 chown "${user}:${group}" + find "${find_L_flag[@]}" "$p" -print0 | xargs -r -0 chown "${chown_flags[@]}" "${user}:${group}" elif [[ -n $user ]] && [[ -z $group ]]; then - find -L "$p" -print0 | xargs -r -0 chown "${user}" + find "${find_L_flag[@]}" "$p" -print0 | xargs -r -0 chown "${chown_flags[@]}" "${user}" elif [[ -z $user ]] && [[ -n $group ]]; then - find -L "$p" -print0 | xargs -r -0 chgrp "${group}" + find "${find_L_flag[@]}" "$p" -print0 | xargs -r -0 chgrp "${chown_flags[@]}" "${group}" fi else stderr_print "$p does not exist" diff --git a/bitnami/pgbouncer/1/debian-12/rootfs/opt/bitnami/scripts/libpgbouncer.sh b/bitnami/pgbouncer/1/debian-12/rootfs/opt/bitnami/scripts/libpgbouncer.sh index 1ace061b387e..59b72496a498 100644 --- a/bitnami/pgbouncer/1/debian-12/rootfs/opt/bitnami/scripts/libpgbouncer.sh +++ b/bitnami/pgbouncer/1/debian-12/rootfs/opt/bitnami/scripts/libpgbouncer.sh @@ -206,8 +206,8 @@ pgbouncer_initialize() { info "Configuring credentials" # Create credentials file if ! pgbouncer_is_file_external "userlist.txt"; then - echo "\"$(pgbouncer_escape_auth "$POSTGRESQL_USERNAME")\" \"$(pgbouncer_escape_auth "$POSTGRESQL_PASSWORD")\"" \ - > "$PGBOUNCER_AUTH_FILE" + install -m 600 /dev/null "$PGBOUNCER_AUTH_FILE" + echo "\"$(pgbouncer_escape_auth "$POSTGRESQL_USERNAME")\" \"$(pgbouncer_escape_auth "$POSTGRESQL_PASSWORD")\"" >> "$PGBOUNCER_AUTH_FILE" echo "$PGBOUNCER_USERLIST" >> "$PGBOUNCER_AUTH_FILE" else debug "User list file mounted externally, skipping configuration" @@ -336,12 +336,12 @@ pgbouncer_initialize() { fi # Configuring permissions for tmp and logs folders - am_i_root && configure_permissions_ownership "$PGBOUNCER_TMP_DIR $PGBOUNCER_LOG_DIR" -u "$PGBOUNCER_DAEMON_USER" -g "$PGBOUNCER_DAEMON_GROUP" + am_i_root && configure_permissions_ownership "$PGBOUNCER_TMP_DIR $PGBOUNCER_LOG_DIR" -u "$PGBOUNCER_DAEMON_USER" -g "$PGBOUNCER_DAEMON_GROUP" -n # Configure ownership and permissions for the socket directory if PGBOUNCER_SOCKET_DIR is set. # This ensures the directory is usable by PGBOUNCER_DAEMON_USER, especially if it's a root-owned mount point. - if ! is_empty_value "$PGBOUNCER_SOCKET_DIR"; then - am_i_root && configure_permissions_ownership "$PGBOUNCER_SOCKET_DIR" -u "$PGBOUNCER_DAEMON_USER" -g "$PGBOUNCER_DAEMON_GROUP" --dir-mode "0755" + if am_i_root && ! is_empty_value "$PGBOUNCER_SOCKET_DIR" && [[ "$PGBOUNCER_SOCKET_DIR" != "/tmp" ]]; then + configure_permissions_ownership "$PGBOUNCER_SOCKET_DIR" -u "$PGBOUNCER_DAEMON_USER" -g "$PGBOUNCER_DAEMON_GROUP" --dir-mode "0755" -n fi # Avoid exit code of previous commands to affect the result of this function