Skip to content

mz864: chown implicitly created WORKDIR parent directories to the active user#867

Open
mzihlmann wants to merge 2 commits into
mainfrom
mz864-workdir-chown-implicit-dirs
Open

mz864: chown implicitly created WORKDIR parent directories to the active user#867
mzihlmann wants to merge 2 commits into
mainfrom
mz864-workdir-chown-implicit-dirs

Conversation

@mzihlmann

Copy link
Copy Markdown
Collaborator

Fixes #864

WORKDIR chowns only the final directory it creates. When it also has to create missing parents, MkdirAllWithPermissions runs os.MkdirAll for the whole tree but os.Chown only on the leaf, so the implicit parents stay root owned while buildkit assigns the active USER to every directory it creates. WORKDIR /work/dir under USER 1000 therefore leaves /work owned by root in kaniko but by 1000 in buildkit. This chowns every directory that the call newly creates, gated behind FF_KANIKO_CHOWN_ON_IMPLICIT_DIRS and enabled in the integration suite, matching the existing FF_KANIKO_COPY_CHMOD_ON_IMPLICIT_DIRS pattern for the COPY side of the same family.

@mzihlmann mzihlmann force-pushed the mz864-workdir-chown-implicit-dirs branch 2 times, most recently from 5a8d563 to 4563b31 Compare July 3, 2026 16:22
@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/util/fs_util.go 83.33% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@mzihlmann mzihlmann force-pushed the mz864-workdir-chown-implicit-dirs branch from 4563b31 to 7241a61 Compare July 3, 2026 16:37
@mzihlmann mzihlmann requested review from 0hlov3, BobDu, babs and nejch July 3, 2026 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WORKDIR leaves implicitly created parent directories owned by root instead of the active USER

1 participant