Skip to content

Commit 7511464

Browse files
committed
fix: use whitelist approach for docker UID/GID permission fixing
Replace broken selective find command with explicit directory whitelist for container-managed directories. Fix execution order to run setup_nonroot_user before ensure_agent_binaries. - Fix regression from commit 5807889 causing "Permission denied" errors - Whitelist approach: .npm-global, .local, .oh-my-zsh, .skills, .config, .cache, go - Add comprehensive research doc on UID/GID handling patterns - Add devlog documenting fix and industry validation
1 parent 5fbc737 commit 7511464

3 files changed

Lines changed: 978 additions & 3 deletions

File tree

docker-entrypoint.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,17 @@ setup_nonroot_user() {
218218
DEVA_UID="$actual_uid"
219219
fi
220220
fi
221-
# Only chown files owned by container, skip mounted volumes
222-
find "$DEVA_HOME" -maxdepth 1 ! -type l -user root -exec chown "$DEVA_UID:$DEVA_GID" {} \; 2>/dev/null || true
221+
# Fix container-managed directories (whitelist approach - safe for mounted volumes)
222+
# These directories are created at image build time and must be chowned to match host UID
223+
for dir in .npm-global .local .oh-my-zsh .skills .config .cache go; do
224+
if [ -d "$DEVA_HOME/$dir" ] && [ ! -L "$DEVA_HOME/$dir" ]; then
225+
chown -R "$DEVA_UID:$DEVA_GID" "$DEVA_HOME/$dir" 2>/dev/null || true
226+
fi
227+
done
228+
# Fix container-created dotfiles
229+
find "$DEVA_HOME" -maxdepth 1 \( -type f -o -type d \) -name '.*' \
230+
! -name '..' ! -name '.' \
231+
-exec chown "$DEVA_UID:$DEVA_GID" {} \; 2>/dev/null || true
223232
fi
224233

225234
chmod 755 /root 2>/dev/null || true
@@ -288,10 +297,10 @@ main() {
288297
cd "$WORKDIR"
289298
fi
290299

291-
ensure_agent_binaries
292300
setup_nonroot_user
293301
fix_rust_permissions
294302
fix_docker_socket_permissions
303+
ensure_agent_binaries
295304

296305
if [ $# -eq 0 ]; then
297306
if [ "$DEVA_AGENT" = "codex" ]; then

0 commit comments

Comments
 (0)