From 97c0c67be6a6e98ab2ce879895168bd8a4d2b4c8 Mon Sep 17 00:00:00 2001
From: Eric Nemchik <eric@nemchik.com>
Date: Wed, 4 Nov 2020 16:38:38 -0600
Subject: [PATCH] add wrapper script to set umask on downstream images Ref:
 92c6e348cffd05ff4fd78c038f43877e7886ff85

---
 Dockerfile                | 1 +
 Dockerfile.aarch64        | 1 +
 Dockerfile.armhf          | 1 +
 root/usr/bin/with-contenv | 7 +++++++
 4 files changed, 10 insertions(+)
 create mode 100644 root/usr/bin/with-contenv

diff --git a/Dockerfile b/Dockerfile
index f56490c..f95691f 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -99,6 +99,7 @@ RUN \
 	/app \
 	/config \
 	/defaults && \
+ mv /usr/bin/with-contenv /usr/bin/with-contenvb && \
  echo "**** cleanup ****" && \
  apt-get clean && \
  rm -rf \
diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64
index dff2769..bc2a1f5 100644
--- a/Dockerfile.aarch64
+++ b/Dockerfile.aarch64
@@ -99,6 +99,7 @@ RUN \
 	/app \
 	/config \
 	/defaults && \
+ mv /usr/bin/with-contenv /usr/bin/with-contenvb && \
  echo "**** add qemu ****" && \
  curl -o \
  /usr/bin/qemu-aarch64-static -L \
diff --git a/Dockerfile.armhf b/Dockerfile.armhf
index e9c989c..e334f1b 100644
--- a/Dockerfile.armhf
+++ b/Dockerfile.armhf
@@ -99,6 +99,7 @@ RUN \
 	/app \
 	/config \
 	/defaults && \
+ mv /usr/bin/with-contenv /usr/bin/with-contenvb && \
  echo "**** add qemu ****" && \
  curl -o \
  /usr/bin/qemu-arm-static -L \
diff --git a/root/usr/bin/with-contenv b/root/usr/bin/with-contenv
new file mode 100644
index 0000000..b535def
--- /dev/null
+++ b/root/usr/bin/with-contenv
@@ -0,0 +1,7 @@
+#! /bin/bash
+if [[ -f /var/run/s6/container_environment/UMASK ]] && [[ "$(pwdx $$)" =~ "/run/s6/services/" ]]; then
+  umask $(cat /var/run/s6/container_environment/UMASK)
+  exec /usr/bin/with-contenvb "$@"
+else
+  exec /usr/bin/with-contenvb "$@"
+fi
-- 
GitLab