Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

campaigns: widen permissions on mounted paths #366

Merged
merged 4 commits into from
Nov 5, 2020

Conversation

LawnGnome
Copy link
Contributor

This fixes #365 by ensuring that files and workspaces mounted into campaign containers are world readable, writable, and executable as appropriate.

This fixes #365 by ensuring that files and workspaces mounted into
campaign containers are world readable, writable, and executable as
appropriate.
@LawnGnome LawnGnome requested a review from a team November 4, 2020 21:22
Copy link
Member

@eseliger eseliger left a comment

Choose a reason for hiding this comment

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

Nice 👍

internal/campaigns/archive_fetcher.go Show resolved Hide resolved
// that the file is globally writable. If the execute bit is normally
// set on the zipped up file, let's ensure we propagate that to the
// group and other permission bits too.
if f.Mode()&0111 != 0 {
Copy link
Member

Choose a reason for hiding this comment

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

Nice catch

@@ -97,6 +97,12 @@ func runSteps(ctx context.Context, wc *WorkspaceCreator, repo *graphql.Repositor
}
defer os.Remove(runScriptFile.Name())

// This file needs to be readable within the container regardless of
// the user the container is running as.
if err := runScriptFile.Chmod(0644); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

does it not need to be executable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Counter intuitively, no! The Docker command basically boils down to this:

docker run --entrypoint /bin/bash -- sha256:CONTAINER_ID /tmp/some-horrible-script-name

Since the shell is the entrypoint, only that needs to be executable, and the script being run is just a regular old command line parameter.

@LawnGnome
Copy link
Contributor Author

OK, it looks like we have some Windows issues, so please hold while I figure out how much they matter. (My suspicion is: not much, given the different Docker execution model on Windows.)

Copy link
Contributor

@chrispine chrispine left a comment

Choose a reason for hiding this comment

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

Thanks for getting to this so quickly!


have := mustGetPerm(t, path)

// Go maps Windows file attributes onto Unix permissions in a fairly trivial
Copy link
Member

Choose a reason for hiding this comment

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

🤯
Thanks for finding this!

@mrnugget
Copy link
Contributor

mrnugget commented Nov 5, 2020

Good stuff!

@LawnGnome LawnGnome merged commit 58838e8 into main Nov 5, 2020
@LawnGnome LawnGnome deleted the aharvey/fix-permissions branch November 5, 2020 17:53
scjohns pushed a commit that referenced this pull request Apr 24, 2023
This fixes #365 by ensuring that files and workspaces mounted into
campaign containers are world readable, writable, and executable as
appropriate.
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.

campaigns: create files/directories that might be mounted into the container with global permissions
4 participants