Skip to content

fix: skip chmod/chown on pre-existing dirs in MakeDir#1025

Open
Pangjiping wants to merge 3 commits into
mainfrom
fix/makedirs-chmod-preexisting-1024
Open

fix: skip chmod/chown on pre-existing dirs in MakeDir#1025
Pangjiping wants to merge 3 commits into
mainfrom
fix/makedirs-chmod-preexisting-1024

Conversation

@Pangjiping

Copy link
Copy Markdown
Collaborator

Summary

  • MakeDir now checks if directory exists before MkdirAll; only applies ChmodFile to newly created dirs
  • SetFileOwnership returns nil when both owner and group are empty, instead of forcing chown to current uid/gid
  • Adds tests for both fixes

Closes #1024

Test plan

  • TestMakeDir_PreExistingDir — pre-existing dir not chmod'd, no error
  • TestMakeDir_NewDir — new dir created with correct permissions
  • TestSetFileOwnership_EmptyOwnerGroup — empty owner/group is no-op

🤖 Generated with Claude Code

MakeDir unconditionally ran chmod+chown after MkdirAll, breaking
createDirectories for pre-existing system dirs like /tmp where the
sandbox user lacks permission. Now only applies chmod to newly created
dirs. Also fixes SetFileOwnership to no-op when no owner/group specified
instead of forcing chown to current uid/gid.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 987154ee63

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread components/execd/pkg/web/controller/utils_test.go Outdated
Comment thread components/execd/pkg/web/controller/utils.go Outdated
- Skip exact mode assertion on Windows where os.Chmod only maps
  the read-only attribute
- Add os.Stat check in SetFileOwnership no-op path so empty
  permissions on a missing file still returns ENOENT
- Add TestSetFileOwnership_MissingFile test

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9c181b601d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread components/execd/pkg/web/controller/utils_test.go Outdated
Comment thread components/execd/pkg/web/controller/utils.go Outdated
- SetFileOwnership now returns error when owner/group is specified but
  lookup fails, instead of silently ignoring
- Early return nil only when both owner and group are empty (truly
  unspecified)
- Add Windows skip guards to ownership tests since SetFileOwnership
  is a no-op placeholder on Windows
- Add TestSetFileOwnership_InvalidOwner test

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c6332b40d8

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread components/execd/pkg/web/controller/utils.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working component/execd

Projects

None yet

Development

Successfully merging this pull request may close these issues.

createDirectories chmods pre-existing directories, breaking writeFile under /tmp and other system dirs

3 participants