diff --git a/bitnami/tomcat/11.0/debian-12/Dockerfile b/bitnami/tomcat/11.0/debian-12/Dockerfile index bdc5f827c940..fecceaa46dcf 100644 --- a/bitnami/tomcat/11.0/debian-12/Dockerfile +++ b/bitnami/tomcat/11.0/debian-12/Dockerfile @@ -8,7 +8,7 @@ ARG JAVA_EXTRA_SECURITY_DIR="/bitnami/java/extra-security" ARG TARGETARCH LABEL org.opencontainers.image.base.name="docker.io/bitnami/minideb:bookworm" \ - org.opencontainers.image.created="2026-05-23T12:03:51Z" \ + org.opencontainers.image.created="2026-06-01T13:47:11Z" \ org.opencontainers.image.description="Application packaged by Broadcom, Inc." \ org.opencontainers.image.documentation="https://github.com/bitnami/containers/tree/main/bitnami/tomcat/README.md" \ org.opencontainers.image.source="https://github.com/bitnami/containers/tree/main/bitnami/tomcat" \ @@ -36,12 +36,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 @@ -53,7 +53,7 @@ RUN /opt/bitnami/scripts/java/postunpack.sh RUN /opt/bitnami/scripts/tomcat/postunpack.sh ENV APP_VERSION="11.0.22" \ BITNAMI_APP_NAME="tomcat" \ - IMAGE_REVISION="3" \ + IMAGE_REVISION="4" \ JAVA_HOME="/opt/bitnami/java" \ PATH="/opt/bitnami/common/bin:/opt/bitnami/java/bin:/opt/bitnami/tomcat/bin:$PATH" diff --git a/bitnami/tomcat/11.0/debian-12/prebuildfs/opt/bitnami/checksums/jre-21.0.11-11-1-linux-amd64-debian-12.tar.gz.sha256 b/bitnami/tomcat/11.0/debian-12/prebuildfs/opt/bitnami/checksums/jre-21.0.11-11-1-linux-amd64-debian-12.tar.gz.sha256 new file mode 100644 index 000000000000..f1872279a271 --- /dev/null +++ b/bitnami/tomcat/11.0/debian-12/prebuildfs/opt/bitnami/checksums/jre-21.0.11-11-1-linux-amd64-debian-12.tar.gz.sha256 @@ -0,0 +1 @@ +190f3814d0362c10bc2373945a5fe00ff46aa2980ac2224528a32c7766a2b72d jre-21.0.11-11-1-linux-amd64-debian-12.tar.gz diff --git a/bitnami/tomcat/11.0/debian-12/prebuildfs/opt/bitnami/checksums/jre-21.0.11-11-1-linux-arm64-debian-12.tar.gz.sha256 b/bitnami/tomcat/11.0/debian-12/prebuildfs/opt/bitnami/checksums/jre-21.0.11-11-1-linux-arm64-debian-12.tar.gz.sha256 new file mode 100644 index 000000000000..03a5b4115128 --- /dev/null +++ b/bitnami/tomcat/11.0/debian-12/prebuildfs/opt/bitnami/checksums/jre-21.0.11-11-1-linux-arm64-debian-12.tar.gz.sha256 @@ -0,0 +1 @@ +08f71653cfeafd8e168835acfa95678ad52649c0b8c3512d285cedead2ea0a62 jre-21.0.11-11-1-linux-arm64-debian-12.tar.gz diff --git a/bitnami/tomcat/11.0/debian-12/prebuildfs/opt/bitnami/checksums/render-template-1.0.9-165-linux-amd64-debian-12.tar.gz.sha256 b/bitnami/tomcat/11.0/debian-12/prebuildfs/opt/bitnami/checksums/render-template-1.0.9-165-linux-amd64-debian-12.tar.gz.sha256 new file mode 100644 index 000000000000..ecf216f2789c --- /dev/null +++ b/bitnami/tomcat/11.0/debian-12/prebuildfs/opt/bitnami/checksums/render-template-1.0.9-165-linux-amd64-debian-12.tar.gz.sha256 @@ -0,0 +1 @@ +374910c7361f00d393eca79a749d29f389b4522057902c7655f0a3a5ae3d1b32 render-template-1.0.9-165-linux-amd64-debian-12.tar.gz diff --git a/bitnami/tomcat/11.0/debian-12/prebuildfs/opt/bitnami/checksums/render-template-1.0.9-165-linux-arm64-debian-12.tar.gz.sha256 b/bitnami/tomcat/11.0/debian-12/prebuildfs/opt/bitnami/checksums/render-template-1.0.9-165-linux-arm64-debian-12.tar.gz.sha256 new file mode 100644 index 000000000000..e15b6bdd7577 --- /dev/null +++ b/bitnami/tomcat/11.0/debian-12/prebuildfs/opt/bitnami/checksums/render-template-1.0.9-165-linux-arm64-debian-12.tar.gz.sha256 @@ -0,0 +1 @@ +d492024d2d8261cfb147e7b508d341b91349fd41cf41aecd0706046be8cb108b render-template-1.0.9-165-linux-arm64-debian-12.tar.gz diff --git a/bitnami/tomcat/11.0/debian-12/prebuildfs/opt/bitnami/checksums/tomcat-11.0.22-0-linux-amd64-debian-12.tar.gz.sha256 b/bitnami/tomcat/11.0/debian-12/prebuildfs/opt/bitnami/checksums/tomcat-11.0.22-0-linux-amd64-debian-12.tar.gz.sha256 new file mode 100644 index 000000000000..b015a45f0c30 --- /dev/null +++ b/bitnami/tomcat/11.0/debian-12/prebuildfs/opt/bitnami/checksums/tomcat-11.0.22-0-linux-amd64-debian-12.tar.gz.sha256 @@ -0,0 +1 @@ +ba92f90472e326a7586e95703ce37d554a3914315df79d103eee67df92092867 tomcat-11.0.22-0-linux-amd64-debian-12.tar.gz diff --git a/bitnami/tomcat/11.0/debian-12/prebuildfs/opt/bitnami/checksums/tomcat-11.0.22-0-linux-arm64-debian-12.tar.gz.sha256 b/bitnami/tomcat/11.0/debian-12/prebuildfs/opt/bitnami/checksums/tomcat-11.0.22-0-linux-arm64-debian-12.tar.gz.sha256 new file mode 100644 index 000000000000..b9acb0982451 --- /dev/null +++ b/bitnami/tomcat/11.0/debian-12/prebuildfs/opt/bitnami/checksums/tomcat-11.0.22-0-linux-arm64-debian-12.tar.gz.sha256 @@ -0,0 +1 @@ +584e7c3d93d14199a55732e09c8398ad53dcaa64a7b0896c624d485f5a71d94d tomcat-11.0.22-0-linux-arm64-debian-12.tar.gz diff --git a/bitnami/tomcat/11.0/debian-12/prebuildfs/opt/bitnami/scripts/libfile.sh b/bitnami/tomcat/11.0/debian-12/prebuildfs/opt/bitnami/scripts/libfile.sh index 1c69e0e48a5d..335c1c7c9ef7 100644 --- a/bitnami/tomcat/11.0/debian-12/prebuildfs/opt/bitnami/scripts/libfile.sh +++ b/bitnami/tomcat/11.0/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/tomcat/11.0/debian-12/prebuildfs/opt/bitnami/scripts/libfs.sh b/bitnami/tomcat/11.0/debian-12/prebuildfs/opt/bitnami/scripts/libfs.sh index 1337f6c2dd59..b16efabd3230 100644 --- a/bitnami/tomcat/11.0/debian-12/prebuildfs/opt/bitnami/scripts/libfs.sh +++ b/bitnami/tomcat/11.0/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/tomcat/11.0/debian-12/rootfs/opt/bitnami/scripts/libtomcat.sh b/bitnami/tomcat/11.0/debian-12/rootfs/opt/bitnami/scripts/libtomcat.sh index faf081f97c86..c87405cb2e81 100644 --- a/bitnami/tomcat/11.0/debian-12/rootfs/opt/bitnami/scripts/libtomcat.sh +++ b/bitnami/tomcat/11.0/debian-12/rootfs/opt/bitnami/scripts/libtomcat.sh @@ -107,6 +107,7 @@ tomcat_ensure_user_exists() { --insert '$new_node' --type attr --name 'password' --value "$password" \ --insert '$new_node' --type attr --name 'roles' --value "manager-gui,admin-gui" \ "$TOMCAT_USERS_CONF_FILE" + chmod 600 "$TOMCAT_USERS_CONF_FILE" } ######################## @@ -119,18 +120,19 @@ tomcat_ensure_user_exists() { # None ######################### tomcat_enable_ajp() { - local ajp_port="${1:?missing ajp port}" # We want to locate the AJP connector right after the related comment, hence the substitution and not using xmlstarlet # Unfortunately the AJP connector is inside a multi-line comment, so the simplest approach is to add a new line in the proper location local ajp_protocol="AJP/1.3" local ajp_selector="//Connector[@protocol=\"${ajp_protocol}\"]" + local secret_attr="secretRequired=\"false\"" + ! is_empty_value "${TOMCAT_AJP_SECRET:-}" && secret_attr="secretRequired=\"true\" secret=\"${TOMCAT_AJP_SECRET:-}\"" if is_empty_value "$(xmlstarlet sel --template --value-of "${ajp_selector}/@port" "$TOMCAT_CONF_FILE")"; then # Ensure that it is only added once - local ajp_connector="" + local ajp_connector="" replace_in_file "$TOMCAT_CONF_FILE" "^(\s*)()$" "\1\2\n\1${ajp_connector}" else # If it was already added, update the port number - xmlstarlet ed -S --inplace --update "${ajp_selector}/@port" --value "$ajp_port" "$TOMCAT_CONF_FILE" + xmlstarlet ed -S --inplace --update "${ajp_selector}/@port" --value "$TOMCAT_AJP_PORT_NUMBER" "$TOMCAT_CONF_FILE" fi } @@ -177,7 +179,7 @@ EOF if is_boolean_yes "$TOMCAT_ENABLE_AJP"; then info "Enabling AJP" - tomcat_enable_ajp "$TOMCAT_AJP_PORT_NUMBER" + tomcat_enable_ajp fi if is_boolean_yes "$TOMCAT_ENABLE_AUTH"; then @@ -198,7 +200,7 @@ EOF info "Ensuring Tomcat directories exist" ensure_dir_exists "$TOMCAT_WEBAPPS_DIR" # Use tomcat:root ownership for compatibility when running as a non-root user - am_i_root && configure_permissions_ownership "$TOMCAT_WEBAPPS_DIR" -d "775" -f "664" -u "$TOMCAT_DAEMON_USER" -g "root" + am_i_root && configure_permissions_ownership "$TOMCAT_WEBAPPS_DIR" -d "775" -f "664" -u "$TOMCAT_DAEMON_USER" -g "root" -n if is_boolean_yes "$TOMCAT_INSTALL_DEFAULT_WEBAPPS"; then info "Deploying Tomcat from scratch" diff --git a/bitnami/tomcat/11.0/debian-12/rootfs/opt/bitnami/scripts/tomcat-env.sh b/bitnami/tomcat/11.0/debian-12/rootfs/opt/bitnami/scripts/tomcat-env.sh index 8130f63c3b54..81c0d1ea35e3 100644 --- a/bitnami/tomcat/11.0/debian-12/rootfs/opt/bitnami/scripts/tomcat-env.sh +++ b/bitnami/tomcat/11.0/debian-12/rootfs/opt/bitnami/scripts/tomcat-env.sh @@ -77,12 +77,12 @@ export TOMCAT_HTTP_PORT_NUMBER="${TOMCAT_HTTP_PORT_NUMBER:-8080}" export TOMCAT_AJP_PORT_NUMBER="${TOMCAT_AJP_PORT_NUMBER:-8009}" export TOMCAT_USERNAME="${TOMCAT_USERNAME:-manager}" export TOMCAT_PASSWORD="${TOMCAT_PASSWORD:-}" -export TOMCAT_ALLOW_REMOTE_MANAGEMENT="${TOMCAT_ALLOW_REMOTE_MANAGEMENT:-yes}" # only used during the first initialization +export TOMCAT_ALLOW_REMOTE_MANAGEMENT="${TOMCAT_ALLOW_REMOTE_MANAGEMENT:-no}" # only used during the first initialization export TOMCAT_ENABLE_AUTH="${TOMCAT_ENABLE_AUTH:-yes}" export TOMCAT_ENABLE_AJP="${TOMCAT_ENABLE_AJP:-no}" export TOMCAT_START_RETRIES="${TOMCAT_START_RETRIES:-12}" export TOMCAT_EXTRA_JAVA_OPTS="${TOMCAT_EXTRA_JAVA_OPTS:-}" -export TOMCAT_INSTALL_DEFAULT_WEBAPPS="${TOMCAT_INSTALL_DEFAULT_WEBAPPS:-yes}" +export TOMCAT_INSTALL_DEFAULT_WEBAPPS="${TOMCAT_INSTALL_DEFAULT_WEBAPPS:-no}" # Default JVM configuration export JAVA_HOME="${BITNAMI_ROOT_DIR}/java" diff --git a/bitnami/tomcat/README.md b/bitnami/tomcat/README.md index e2200132fdac..7d0cdf7826cd 100644 --- a/bitnami/tomcat/README.md +++ b/bitnami/tomcat/README.md @@ -103,12 +103,12 @@ The following tables list the main variables you can set. | `TOMCAT_AJP_PORT_NUMBER` | Tomcat AJP port number. | `8009` | | `TOMCAT_USERNAME` | Tomcat username. | `manager` | | `TOMCAT_PASSWORD` | Tomcat password. | `nil` | -| `TOMCAT_ALLOW_REMOTE_MANAGEMENT` | Whether to allow connections from remote addresses to the Tomcat manager application. | `yes` | +| `TOMCAT_ALLOW_REMOTE_MANAGEMENT` | Whether to allow connections from remote addresses to the Tomcat manager application. | `no` | | `TOMCAT_ENABLE_AUTH` | Whether to enable authentication for Tomcat manager applications. | `yes` | | `TOMCAT_ENABLE_AJP` | Whether to enable the Tomcat AJP connector. | `no` | | `TOMCAT_START_RETRIES` | The number or retries while waiting for Catalina to start. | `12` | | `TOMCAT_EXTRA_JAVA_OPTS` | Additional Java settings for Tomcat. | `nil` | -| `TOMCAT_INSTALL_DEFAULT_WEBAPPS` | Whether to add default webapps (ROOT, manager, host-manager, etc.) for deployment. | `yes` | +| `TOMCAT_INSTALL_DEFAULT_WEBAPPS` | Whether to add default webapps (ROOT, manager, host-manager, etc.) for deployment. | `no` | | `JAVA_OPTS` | Java runtime parameters. | `-Djava.awt.headless=true -XX:+UseG1GC -Dfile.encoding=UTF-8 -Djava.net.preferIPv4Stack=true -Djava.net.preferIPv4Addresses=true -Duser.home=${TOMCAT_HOME}` | #### Read-only environment variables