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

Add 'relabel' to --mount options #4034

Merged
merged 1 commit into from
Sep 17, 2019

Conversation

rhatdan
Copy link
Member

@rhatdan rhatdan commented Sep 16, 2019

Currently if a user specifies a --mount option, their is no way to tell SELinux
to relabel the mount point.

This patch addes the relabel=shared and relabel=private options.

Signed-off-by: Daniel J Walsh dwalsh@redhat.com

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rhatdan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/S labels Sep 16, 2019
@rhatdan
Copy link
Member Author

rhatdan commented Sep 16, 2019

This should help rectify containers/podman-compose#41
@mheon we could probably add volume support to the --mount option now as well.

@giuseppe
Copy link
Member

LGTM

@@ -470,6 +470,8 @@ Current supported mount TYPES are bind, and tmpfs.

type=bind,source=/path/on/host,destination=/path/in/container

type=bind,src=/path/on/host,dst=/path/in/container,relabel=shared

Copy link
Member

Choose a reason for hiding this comment

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

Just double checking. src and dst are both valid? The other examples have source and destination

Copy link
Member Author

Choose a reason for hiding this comment

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

It is supported and documented in the man page

@mheon
Copy link
Member

mheon commented Sep 16, 2019 via email

@rhatdan
Copy link
Member Author

rhatdan commented Sep 16, 2019

Man pages don't document volume support.

Docker does not look like it supports relabeling at all at least in the man pages. bind-propagation makes no sense for relabelling.

@mheon
Copy link
Member

mheon commented Sep 16, 2019

The --mount flag does not support z or Z options for modifying selinux labels.

Interesting...

Alright, this sounds reasonable, then.

@rhatdan
Copy link
Member Author

rhatdan commented Sep 16, 2019

Added docs for volume support.

@@ -467,6 +467,22 @@ func getBindMount(args []string) (spec.Mount, error) {
}
newMount.Destination = kv[1]
setDest = true
case "relabel":
if setRelabel {
return newMount, errors.Wrapf(optionArgError, "cannot pass 'ro' or 'rw' options more than once")
Copy link
Member

Choose a reason for hiding this comment

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

Change ro and rw to relabel

@mheon
Copy link
Member

mheon commented Sep 16, 2019

LGTM once my comment nit is addressed

@AkihiroSuda
Copy link
Collaborator

:z and :Z tend to be considered dangerous, and maybe it is going to be deprecated for Moby/Docker

Why not let users to chcon explicitly?

Currently if a user specifies a --mount option, their is no way to tell SELinux
to relabel the mount point.

This patch addes the relabel=shared and relabel=private options.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
@rhatdan
Copy link
Member Author

rhatdan commented Sep 16, 2019

@AkihiroSuda You can not chroot explicity except for shared. Since the container engine picks out the label, it can not be done as a private lable. Always labeling as shared, means all of the containers would have the ability to modify content and potentially cause containers to be attacked.

If you want to volume mount in /var/lib/mariadb into a container that is running mariadb, then you want the database to be private to the container.

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 17, 2019
@openshift-merge-robot openshift-merge-robot merged commit 799aa70 into containers:master Sep 17, 2019
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 26, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants