Skip to content

armgit / kwant

Public Imported from GitHub
0

Your own team of AI bots in one self-hosted binary: spaces, every account you have, handoffs, approvals and routines. Open-source, self-hosted alternative to Grok Bot, Claude Duet and OpenAI dots. Rust + React.

Make container entrypoints readable under any host umask

Lin (kwant bot)cf59d1eacd97
diff --git a/docker/browser.Dockerfile b/docker/browser.Dockerfile
index 035217d8..5fcccb3c 100644
--- a/docker/browser.Dockerfile
+++ b/docker/browser.Dockerfile
@@ -3,8 +3,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends chromium socat
&& rm -rf /var/lib/apt/lists/* \
&& useradd --uid 1000 --create-home browser \
&& chromium --version && socat -V
+# The build context may be written under a strict umask (e.g. 077), so set the full mode:
+# adding only the execute bit leaves the script unreadable to the unprivileged browser user.
COPY browser-entrypoint.sh /usr/local/bin/browser-entrypoint
-RUN test -s /usr/local/bin/browser-entrypoint && chmod +x /usr/local/bin/browser-entrypoint
+RUN test -s /usr/local/bin/browser-entrypoint && chmod 755 /usr/local/bin/browser-entrypoint
USER browser
ENV HOME=/tmp XDG_CONFIG_HOME=/tmp/.config XDG_CACHE_HOME=/tmp/.cache
EXPOSE 9222
diff --git a/docker/sandbox.Dockerfile b/docker/sandbox.Dockerfile
index 1eb734dc..67e9437c 100644
--- a/docker/sandbox.Dockerfile
+++ b/docker/sandbox.Dockerfile
@@ -25,6 +25,6 @@ WORKDIR /workspace
EXPOSE 9222
COPY docker/entrypoint.sh /entrypoint.sh
-RUN chmod +x /entrypoint.sh
+RUN chmod 755 /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
diff --git a/tests/docker_packaging_test.rs b/tests/docker_packaging_test.rs
index ba6b5dd9..9dd4f16a 100644
--- a/tests/docker_packaging_test.rs
+++ b/tests/docker_packaging_test.rs
@@ -17,3 +17,17 @@ fn test_docker_packaging_files_exist_and_valid() {
assert!(ep_content.contains("--remote-debugging-port=9222"));
assert!(ep_content.contains("--headless"));
}
+
+/// Scripts copied into images keep the host file mode, which a strict umask can make 0600.
+/// `chmod +x` alone then leaves them unreadable to a non-root USER, so every image sets 755.
+#[test]
+fn test_copied_entrypoints_are_world_readable() {
+ for (dockerfile, script) in [
+ ("docker/browser.Dockerfile", "/usr/local/bin/browser-entrypoint"),
+ ("docker/sandbox.Dockerfile", "/entrypoint.sh"),
+ ] {
+ let content = std::fs::read_to_string(dockerfile).unwrap();
+ assert!(content.contains(&format!("chmod 755 {script}")), "{dockerfile} must chmod 755 {script}");
+ assert!(!content.contains("chmod +x"), "{dockerfile} must not rely on chmod +x alone");
+ }
+}