diff --git a/CHANGELOG.md b/CHANGELOG.md index 37a660376..1904596bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ All notable changes to this project will be documented in this file. ### Added - spark-connect-client: A new image for Spark connect tests and demos ([#1034]) +- nifi: check for correct permissions and ownerships in /stackable folder via + `check-permissions-ownership.sh` provided in stackable-base image ([#1027]). ### Changed @@ -14,9 +16,11 @@ All notable changes to this project will be documented in this file. ### Fixed +- nifi: reduce docker image size by removing the recursive chown/chmods in the final image ([#1027]). - spark-k8s: reduce docker image size by removing the recursive chown/chmods in the final image ([#1042]). - Add `--locked` flag to `cargo install` commands for reproducible builds ([#1044]). +[#1027]: https://github.com/stackabletech/docker-images/pull/1027 [#1034]: https://github.com/stackabletech/docker-images/pull/1034 [#1042]: https://github.com/stackabletech/docker-images/pull/1042 [#1044]: https://github.com/stackabletech/docker-images/pull/1044 diff --git a/nifi/Dockerfile b/nifi/Dockerfile index 3ca3bfcfc..93daaa019 100644 --- a/nifi/Dockerfile +++ b/nifi/Dockerfile @@ -7,9 +7,11 @@ ARG PRODUCT ARG MAVEN_VERSION="3.9.8" ARG STACKABLE_USER_UID -RUN microdnf update && \ - microdnf clean all && \ - rm -rf /var/cache/yum +RUN < +# ./check-permissions-ownership.sh /stackable ${STACKABLE_USER_UID} 0 +# + +if [[ $# -ne 3 ]]; then + echo "Wrong number of parameters supplied. Usage:" + echo "$0 " + echo "$0 /stackable 1000 0" + exit 1 +fi + +DIRECTORY=$1 +EXPECTED_UID=$2 +EXPECTED_GID=$3 + +error_flag=0 + +# Check ownership +while IFS= read -r -d '' file; do + uid=$(stat -c "%u" "$file") + gid=$(stat -c "%g" "$file") + + if [[ "$uid" -ne "$EXPECTED_UID" || "$gid" -ne "$EXPECTED_GID" ]]; then + echo "Ownership mismatch: $file (Expected: $EXPECTED_UID:$EXPECTED_GID, Found: $uid:$gid)" + error_flag=1 + fi +done < <(find "$DIRECTORY" -print0) + +# Check permissions +while IFS= read -r -d '' file; do + perms=$(stat -c "%A" "$file") + owner_perms="${perms:1:3}" + group_perms="${perms:4:3}" + + if [[ "$owner_perms" != "$group_perms" ]]; then + echo "Permission mismatch: $file (Owner: $owner_perms, Group: $group_perms)" + error_flag=1 + fi +done < <(find "$DIRECTORY" -print0) + +if [[ $error_flag -ne 0 ]]; then + echo "Permission and Ownership checks failed for $DIRECTORY!" + exit 1 +fi + +echo "Permission and Ownership checks succeeded for $DIRECTORY!" diff --git a/stackable-base/Dockerfile b/stackable-base/Dockerfile index 6735fd52d..f38d5b614 100644 --- a/stackable-base/Dockerfile +++ b/stackable-base/Dockerfile @@ -204,6 +204,10 @@ COPY --from=config-utils --chown=${STACKABLE_USER_UID}:0 /config-utils/config-ut # Debug tool that logs generic system information. COPY --from=containerdebug --chown=${STACKABLE_USER_UID}:0 /containerdebug/target/release/containerdebug /stackable/containerdebug +# **check-permissions-ownership.sh** +# Bash script to check proper permissions and ownership requirements in the final Stackable images +COPY --chown=${STACKABLE_USER_UID}:0 shared/checks/check-permissions-ownership.sh /bin/check-permissions-ownership.sh + ENV PATH="${PATH}:/stackable" # These labels have mostly been superceded by the OpenContainer spec annotations below but it doesn't hurt to include them diff --git a/vector/Dockerfile b/vector/Dockerfile index e73571b64..058be4c78 100644 --- a/vector/Dockerfile +++ b/vector/Dockerfile @@ -14,16 +14,22 @@ ARG STACKABLE_USER_UID # This happens by writing a "shutdown file" in a shared volume # See https://github.com/stackabletech/airflow-operator/blob/23.4.1/rust/operator-binary/src/airflow_db_controller.rs#L269 for an example # The Vector container waits for this file to appear and this waiting happens using `inotifywait` which comes from the `inotify-tools` package -RUN ARCH="${TARGETARCH/amd64/x86_64}" ARCH="${ARCH/arm64/aarch64}" && \ - rpm --install \ - "https://repo.stackable.tech/repository/packages/vector/vector-${PRODUCT}-${RPM_RELEASE}.${ARCH}.rpm" \ - "https://repo.stackable.tech/repository/packages/inotify-tools/inotify-tools-${INOTIFY_TOOLS}.${ARCH}.rpm" && \ - mkdir /licenses && \ - cp /usr/share/licenses/vector-${PRODUCT}/LICENSE /licenses/VECTOR_LICENSE && \ - # Create the directory /stackable/vector/var. - # This directory is set by operator-rs in the parameter `data_dir` - # of the Vector configuration. The directory is used for persisting - # Vector state, such as on-disk buffers, file checkpoints, and more. - # Vector needs write permissions. - mkdir --parents /stackable/vector/var && \ - chown --recursive ${STACKABLE_USER_UID}:0 /stackable/ +RUN <