Bug 1173423 - SELinux is preventing docker from 'write' accesses on the file /etc/docker/key.json.
Summary: SELinux is preventing docker from 'write' accesses on the file /etc/docker/ke...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy
Version: 22
Hardware: x86_64
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Miroslav Grepl
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard: abrt_hash:1ffb579cf65a07792487346ff70...
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-12-12 06:10 UTC by Igor Gnatenko
Modified: 2015-03-10 02:59 UTC (History)
8 users (show)

Fixed In Version: selinux-policy-3.13.1-116.fc22
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-03-10 02:59:03 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Igor Gnatenko 2014-12-12 06:10:05 UTC
Description of problem:
SELinux is preventing docker from 'write' accesses on the file /etc/docker/key.json.

*****  Plugin catchall_labels (83.8 confidence) suggests   *******************

If you want to allow docker to have write access on the key.json file
Then you need to change the label on /etc/docker/key.json
Do
# semanage fcontext -a -t FILE_TYPE '/etc/docker/key.json'
where FILE_TYPE is one of the following: afs_cache_t, cgroup_t, docker_home_t, docker_lock_t, docker_log_t, docker_share_t, docker_tmp_t, docker_tmpfs_t, docker_var_lib_t, docker_var_run_t, initrc_tmp_t, puppet_tmp_t, svirt_sandbox_file_t, sysfs_t, systemd_passwd_var_run_t, unlabeled_t, user_cron_spool_t. 
Then execute: 
restorecon -v '/etc/docker/key.json'


*****  Plugin catchall (17.1 confidence) suggests   **************************

If you believe that docker should be allowed write access on the key.json file by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# grep docker /var/log/audit/audit.log | audit2allow -M mypol
# semodule -i mypol.pp

Additional Information:
Source Context                system_u:system_r:docker_t:s0
Target Context                system_u:object_r:etc_t:s0
Target Objects                /etc/docker/key.json [ file ]
Source                        docker
Source Path                   docker
Port                          <Unknown>
Host                          (removed)
Source RPM Packages           
Target RPM Packages           
Policy RPM                    selinux-policy-3.13.1-99.fc22.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     (removed)
Platform                      Linux (removed) 3.18.0-1.fc22.x86_64 #1 SMP Tue
                              Dec 9 14:49:38 UTC 2014 x86_64 x86_64
Alert Count                   1
First Seen                    2014-12-12 02:43:26 MSK
Last Seen                     2014-12-12 02:43:26 MSK
Local ID                      e797967c-c138-455d-81a0-1ae7f9c4c813

Raw Audit Messages
type=AVC msg=audit(1418337806.450:2972): avc:  denied  { write } for  pid=25409 comm="docker" path="/etc/docker/key.json" dev="sda4" ino=1387722 scontext=system_u:system_r:docker_t:s0 tcontext=system_u:object_r:etc_t:s0 tclass=file permissive=1


Hash: docker,docker_t,etc_t,file,write

Version-Release number of selected component:
selinux-policy-3.13.1-99.fc22.noarch

Additional info:
reporter:       libreport-2.3.0
hashmarkername: setroubleshoot
kernel:         3.18.0-1.fc22.x86_64
type:           libreport

Comment 1 Daniel Walsh 2014-12-12 12:59:07 UTC
1572405786e6ff9ba9af5aef6bb5664ef3ba2201 fixes this in git.

Comment 2 Lukas Vrabec 2014-12-12 14:17:22 UTC
commit 1572405786e6ff9ba9af5aef6bb5664ef3ba2201
Author: Dan Walsh <dwalsh>
Date:   Fri Dec 12 07:58:06 2014 -0500

    Docker has a new config/key file it writes to /etc/docker


Thank you Dan.
Back ported F20,F21.

Comment 3 Daniel Walsh 2014-12-12 17:16:38 UTC
GOing to need this in RHEL7...

Comment 4 Lukas Vrabec 2014-12-12 18:17:21 UTC
Yes, Rhel7 included.

Comment 5 J. Sastre 2014-12-25 18:44:40 UTC
This still occurs the very first time docker is started (/etc/docker dir has not been created yet).

The problem is that a type_transition to allow docker_t to create files and folders with the right label (docker_config_t) under /etc is missing.


Adding the following to docker local policy solves the problem:

files_etc_filetrans(docker_t, docker_config_t, { dir file })


Tested on f21. Should work on rawhide too.

Comment 6 Daniel Walsh 2014-12-30 16:40:31 UTC
/etc/docker should be in the docker.spec rpm, it should be owned by it.

files_etc_filetrans(docker_t, docker_config_t, dir, "docker")

SHould be added but nothing more.  This would allow docker to create a docker directory in a directory labeled etc_t.  Your version would allow it to create any directory/file in a directory labeled etc_t if the file or directory did not already exist.

Comment 7 Jaroslav Reznik 2015-03-03 17:17:18 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 22 development cycle.
Changing version to '22'.

More information and reason for this action is here:
https://fedoraproject.org/wiki/Fedora_Program_Management/HouseKeeping/Fedora22

Comment 8 Fedora Update System 2015-03-06 22:08:55 UTC
selinux-policy-3.13.1-116.fc22 has been submitted as an update for Fedora 22.
https://admin.fedoraproject.org/updates/selinux-policy-3.13.1-116.fc22

Comment 9 Fedora Update System 2015-03-09 08:37:51 UTC
Package selinux-policy-3.13.1-116.fc22:
* should fix your issue,
* was pushed to the Fedora 22 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing selinux-policy-3.13.1-116.fc22'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2015-3508/selinux-policy-3.13.1-116.fc22
then log in and leave karma (feedback).

Comment 10 Fedora Update System 2015-03-10 02:59:03 UTC
selinux-policy-3.13.1-116.fc22 has been pushed to the Fedora 22 stable repository.  If problems still persist, please make note of it in this bug report.


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