Skip to content

Commit 4caee3e

Browse files
lroolleclaude[bot]claude
authored
fix: handle UID 0 (root user) case in docker-entrypoint.sh (#22)
* fix: handle UID 0 (root user) case in docker-entrypoint.sh - Detect when host user is root (CLAUDE_UID=0) - Use fallback UID 1000 to avoid conflict with existing root user - Also handle CLAUDE_GID=0 case with same fallback - Display clear warning messages about fallback behavior - Preserves security by still running as non-root in container - Fixes "usermod: UID '0' already exists" error Resolves #21 Co-authored-by: Eric Wang <lroolle@users.noreply.github.com> * fix: handle UID=0 and GID=0 independently for security - Separate UID=0 and GID=0 checks to prevent security bypass - Fix case where host user has UID≠0 but GID=0 (would assign root group) - Remove inaccurate warning message about file ownership - Addresses Cursor BugBot security vulnerability report 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: add explicit github_token to claude-code-review action - Add github_token parameter to prevent OIDC token exchange errors - Fixes 401 Unauthorized - Invalid OIDC token error in claude-review CI - Action was trying to use GitHub App auth instead of direct token auth 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * docs: add OIDC token fix to dev log 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * refactor: remove redundant comments in UID/GID handling - Remove obvious comments that don't add value - Add missing dev log entry for root user handling fix 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * feat: dynamic fallback UID/GID selection for root users - Replace hardcoded 1000 fallback with dynamic search - Find first available UID/GID starting from 1000 - Prevents collision with existing container users/groups - More robust handling of edge cases 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * simplify: revert to hardcoded 1000 fallback for root users - Use UID/GID 1000 fallback for predictable file ownership - Existing usermod logic handles UID collision properly - Most host users are UID 1000, so this provides correct file ownership - Simpler than dynamic search while achieving the goal 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * docs: clarify root cause and solution for UID 0 handling - Explain why UID 0 can't be reassigned (root user exists) - Clarify security fix prevents root group assignment - Note that 1000 fallback provides proper file ownership 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com> Co-authored-by: Eric Wang <lroolle@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com>
1 parent 64306d2 commit 4caee3e

3 files changed

Lines changed: 41 additions & 0 deletions

File tree

.github/workflows/claude-code-review.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ jobs:
3838
uses: anthropics/claude-code-action@beta
3939
with:
4040
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
41+
github_token: ${{ secrets.GITHUB_TOKEN }}
4142

4243
# Optional: Specify model (defaults to Claude Sonnet 4, uncomment for Claude Opus 4)
4344
# model: "claude-opus-4-20250514"

DEV-LOGS.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,36 @@
55

66
## Issue Analysis: 2025-06-23
77

8+
### [bug-fixed] Root user (UID 0) handling in docker-entrypoint.sh
9+
10+
**Problem**: `sudo claude-yolo` fails with "usermod: UID '0' already exists" error.
11+
12+
**Root Cause**: Can't reassign existing UID 0 (root) to claude user.
13+
14+
**Security Fix**: Handle UID=0 and GID=0 independently to prevent root group assignment.
15+
16+
**Solution**: Use fallback UID/GID 1000 for proper file ownership with existing collision handling.
17+
18+
**Status**: ✅ **COMPLETED** - PR #22
19+
20+
---
21+
22+
## Issue Analysis: 2025-06-23
23+
24+
### [bug-fixed] Claude Code Review OIDC token authentication error
25+
26+
**Problem**: CI failing with "Invalid OIDC token" after changing permissions to write.
27+
28+
**Solution**: Added explicit `github_token: ${{ secrets.GITHUB_TOKEN }}` to force direct token auth.
29+
30+
**Cause**: Write permissions trigger GitHub App auth by default, but no App configured.
31+
32+
**Status**: ✅ **COMPLETED**
33+
34+
---
35+
36+
## Issue Analysis: 2025-06-23
37+
838
### [enhancement-completed] Claude Code Review workflow simplification
939

1040
**Problem**: Overcomplicated workflow with manual duplicate detection using GitHub CLI.

docker-entrypoint.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,16 @@ setup_nonroot_user() {
5959
local current_uid=$(id -u "$CLAUDE_USER")
6060
local current_gid=$(id -g "$CLAUDE_USER")
6161

62+
if [ "$CLAUDE_UID" = "0" ]; then
63+
echo "[entrypoint] WARNING: Host user is root (UID=0). Using fallback UID 1000 for security."
64+
CLAUDE_UID=1000
65+
fi
66+
67+
if [ "$CLAUDE_GID" = "0" ]; then
68+
echo "[entrypoint] WARNING: Host user is in root group (GID=0). Using fallback GID 1000 for security."
69+
CLAUDE_GID=1000
70+
fi
71+
6272
if [ "$CLAUDE_GID" != "$current_gid" ]; then
6373
[ "$VERBOSE" = "true" ] && echo "[entrypoint] updating $CLAUDE_USER GID: $current_gid -> $CLAUDE_GID"
6474
if getent group "$CLAUDE_GID" >/dev/null 2>&1; then

0 commit comments

Comments
 (0)