Skip to content

Add support for symbolic chmod options#6778

Open
nickjwhite wants to merge 1 commit into
podman-container-tools:mainfrom
nickjwhite:better-chmod
Open

Add support for symbolic chmod options#6778
nickjwhite wants to merge 1 commit into
podman-container-tools:mainfrom
nickjwhite:better-chmod

Conversation

@nickjwhite

@nickjwhite nickjwhite commented Apr 9, 2026

Copy link
Copy Markdown

What type of PR is this?

/kind feature

What this PR does / why we need it:

This adds an optional Chmod string option to GetOptions and PutOptions. If set, this overrides the ChmodDirs and ChmodFiles options. If unset, they continue to work as before.

The --chmod option to buildah add and buildah copy works with symbolic as well as numeric arguments.

How to verify it

See extra bats tests and copier tests.

Which issue(s) this PR fixes:

Fixes #6066

Special notes for your reviewer:

Note that I'm not sure whether the extra tests in commit_test.go add much value over those in copier/copier_test.go, but I used them while working on this change, so I figured I'd just include them.

Also I'm not sure if this is the way you want the vendored stuff to be included (I added the newly added directory after running 'make vendor') - let me know if I should do it differently.

#6732 suggested calling the new option in GetOptions & PutOptions ChmodStr, but I chose Chmod here because I think it's shorter and clearer.

Does this PR introduce a user-facing change?

The add and copy commands' --chmod argument now accepts symbolic notation, as well as the traditional numeric notation currently supported. Likewise copier's GetOptions and PutOptions now a Chmod option, which accepts numeric or symbolic notation, and if set overrides any ChmodDirs and ChmodFiles options.

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Apr 9, 2026
@packit-as-a-service

Copy link
Copy Markdown

Ephemeral COPR build failed. @containers/packit-build please check.

@nickjwhite nickjwhite force-pushed the better-chmod branch 2 times, most recently from 0d82f4b to 42d5139 Compare April 9, 2026 15:34

@nalind nalind left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Overall this looks very good to me. A couple of quibbles about using test helper functions that would shorten them, and a question about calling mode.Parse() multiple times when reading.

Comment thread commit_test.go Outdated
Comment thread copier/copier.go Outdated
Comment thread copier/copier_test.go Outdated
Comment thread copier/copier_test.go Outdated
Comment thread copier/copier_test.go Outdated
@nalind nalind mentioned this pull request Apr 14, 2026
51 tasks
@nickjwhite

Copy link
Copy Markdown
Author

Thanks for the detailed review, @nalind! I'll fix these up tomorrow and push a fresh version.

@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Apr 15, 2026
@nickjwhite

Copy link
Copy Markdown
Author

Thanks for the detailed review, @nalind! I'll fix these up tomorrow and push a fresh version.

I ended up not waiting 'til tomorrow and just doing it. Replaced a couple more if statements with assert.Equal while I was there, too.

I'm not sure what to do about the mode.Parse() call in copierHandlerGetOne(), I replied to your comment on that, happy to take your guidance on it.

@nalind nalind left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please go ahead and make that change. I think we're going to want this to be rebased before merging.

Comment thread copier/copier.go Outdated
Comment thread commit_test.go Outdated
@nickjwhite

Copy link
Copy Markdown
Author

Please go ahead and make that change. I think we're going to want this to be rebased before merging.

Done, including the rebase. I haven't tested as heavily, as the tests aren't all working on my local machine as they should, but I'll trust in the CI tests for now.

@nalind

nalind commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Done, including the rebase. I haven't tested as heavily, as the tests aren't all working on my local machine as they should, but I'll trust in the CI tests for now.

Changes look good, but usually I expect merge commits to be dropped during a rebase. Did you git fetch upstream; git rebase -i upstream/main, or use a different method?

@nickjwhite

Copy link
Copy Markdown
Author

Changes look good, but usually I expect merge commits to be dropped during a rebase. Did you git fetch upstream; git rebase -i upstream/main, or use a different method?

Oh, apologies, I said I rebased but I actually just merged main, indeed, my bad. I made a fresh branch from latest main, and cherry-picked & manually reapplied & amended my changes to it. So hopefully this is better.

Comment thread copier/copier.go Outdated
@nalind

nalind commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Much, better, thanks!

@nalind nalind left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@nalind

nalind commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

@containers/buildah-maintainers PTAL

@TomSweeneyRedHat

Copy link
Copy Markdown
Contributor

@nickjwhite looks like you may need to rebase this.

Comment thread tests/copy.bats
@TomSweeneyRedHat

Copy link
Copy Markdown
Contributor

Other than a few test tweaks, and a rebase
LGTM

@nickjwhite nickjwhite force-pushed the better-chmod branch 2 times, most recently from 85942ea to 7c3cb08 Compare April 26, 2026 20:47
@nickjwhite

Copy link
Copy Markdown
Author

@TomSweeneyRedHat can you take another look please? I added the extra tests you suggested and rebased, so this should be ready to go.

@TomSweeneyRedHat

Copy link
Copy Markdown
Contributor

@nickjwhite apologies for the very tardy re-review. LGTM.
However, it looks like you need to rebase before we can commit.

This adds an optional Chmod string option to GetOptions and PutOptions.
If set, this overrides the ChmodDirs and ChmodFiles options. If unset,
they continue to work as before.

The --chmod option to buildah add and buildah copy works with symbolic
as well as numeric arguments.

Fixes podman-container-tools#6066

Signed-off-by: Nick White <git@njw.name>
@nickjwhite

Copy link
Copy Markdown
Author

@nickjwhite apologies for the very tardy re-review. LGTM. However, it looks like you need to rebase before we can commit.

No problem Tom, thanks for the re-review! I have rebased again.

@nalind nalind left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, thanks!

@nickjwhite

Copy link
Copy Markdown
Author

Hi again, 2 LGTMs, any reason not to just merge it now? I expect you've all been busy pushing towards Podman 6, so no worries, I just don't want this to be forgotten about 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Containerfile --chmod +x not working in podman

3 participants