RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1811773 - [RFE] cockpit-podman ability to set selinux contexts for volumes
Summary: [RFE] cockpit-podman ability to set selinux contexts for volumes
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: cockpit-podman
Version: 8.1
Hardware: Unspecified
OS: Unspecified
Target Milestone: rc
: 8.4
Assignee: Jindrich Novy
QA Contact: Jan Ščotka
Depends On:
Blocks: 1186913
TreeView+ depends on / blocked
Reported: 2020-03-09 18:05 UTC by Klaas Demter
Modified: 2024-06-13 22:30 UTC (History)
8 users (show)

Fixed In Version: cockpit-podman-25-1.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Last Closed: 2021-05-18 15:32:55 UTC
Type: Feature Request
Target Upstream Version:

Attachments (Terms of Use)

System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-94884 0 None None None 2023-04-10 08:26:44 UTC

Description Klaas Demter 2020-03-09 18:05:35 UTC
Description of problem:
I would like to be able to specify selinux options for volumes based on hostdirs. Currently I can only select read only or readwrite, it is missing the z and Z options.

From podman-run manpage:
       To change a label in the container context, you can add either of two suffixes :z or :Z to the volume mount. These suffixes tell Podman to relabel file objects on the shared volumes. The z option tells Podman that two
       containers share the volume content. As a result, Podman labels the content with a shared content label. Shared volume labels allow all containers to read/write content.  The Z option tells Podman to label the content with a
       private unshared label.  Only the current container can use a private volume.

There was a bug against cockpit-docker but it was never finished:

Version-Release number of selected component (if applicable):

How reproducible:
Create container from cockpit dashboard, only options you can select are readonly or readwrite

Actual results:
Unable to set z/Z option for a hostdir volume 

Expected results:
Able to set z/Z option for a hostdir volume

Comment 1 Matej Marušák 2020-07-17 08:26:28 UTC
Upstream PR https://github.com/cockpit-project/cockpit-podman/pull/435

Comment 8 Joy Pu 2021-02-22 15:14:08 UTC
Test with cockpit-podman-28.1-1.module+el8.4.0+10073+30e5ea69.noarch and seems the Z/z flag is not work as expected:

Create a container with share/private from cockpit-podman website, and check the container with inspect in the host. And the Mode Z/z is not set as expect:
# podman inspect romantic_elgamal --format "{{.Mounts}}"
[{bind  /mnt/mytest /mnt   [rbind] true rprivate}]

Comment 10 Martin Pitt 2021-02-23 05:35:10 UTC
@ypu , this is not the correct way to test that. Mode z/Z has *no influence* on the mount, it is a file system property on the host on the bind mounted directory. E.g.

$ mkdir data
$ ls -ldZ data
drwxr-xr-x. 2 martin martin unconfined_u:object_r:user_tmp_t:s0 40 23. Feb 06:30 data

$ podman run -it -v ./data:/data:z registry.fedoraproject.org/fedora sleep infinity

$ ls -lZd data
drwxr-xr-x. 2 martin martin system_u:object_r:container_file_t:s0 40 23. Feb 06:30 data

^^ see how the z changed the type of the directory to container_file_t

$ podman inspect sharp_babbage --format "{{.Mounts}}"
[{bind  /tmp/data /data   [nosuid nodev rbind] true rprivate}]

The real test is whether you can access the directory inside the container with SELinux enabled:

$ podman exec sharp_babbage touch /data/hello.txt
$ ls -l data/hello.txt 
-rw-r--r--. 1 martin martin 0 23. Feb 06:34 data/hello.txt

Without z/Z this would not work.

Comment 11 Joy Pu 2021-02-23 07:30:47 UTC
Hi Martin,
Thanks a lot for the information. I used to use a named volume with -v and the lable is shows in the Mounts. But you are right it is different from the directory mount. And double checked with cockpit-podman and both private and shared mode works as expected. So set this to verified.

Comment 13 errata-xmlrpc 2021-05-18 15:32:55 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: container-tools:rhel8 security, bug fix, and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.


Note You need to log in before you can comment on or make changes to this bug.