Bug 1656985

Summary: SELinux is preventing sss_cache from 'write' accesses on the file config.ldb.
Product: [Fedora] Fedora Reporter: Markus Linnala <markus.linnala>
Component: selinux-policyAssignee: Lukas Vrabec <lvrabec>
Status: CLOSED DUPLICATE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 29CC: dwalsh, lslebodn, lvrabec, mgrepl, plautrba, zpytela
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Unspecified   
Whiteboard: abrt_hash:56b516f14223cb16474369c81f21edd09168a70ec7dbc5c57437b5953bc2b714;VARIANT_ID=workstation;
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-12-07 13:20:47 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Markus Linnala 2018-12-06 19:32:54 UTC
Description of problem:
I created new F29 virtual machine, Fedora Workstation. After initial setup, mainly:

cd /etc/audit/rules.d/
cat > local.rules
-w /etc/shadow -p w

systemctl enable --now sshd
fixfiles onboot
vi /etc/sudoers
dnf install -y setroubleshoot{,-server} setools-console strace

I logged into console (Gnome) and then used gnome settings to create user. There were several AVC denied messages after that.

After some iterating it seems there is issue between account / group creation and sssd. To silence /allow all what is wanted during account/group creation I needed to add following module:

module my-useradd_t 1.0;

require {
        type groupadd_t;
        type sssd_public_t;
        type sssd_t;
        type sssd_var_lib_t;
        type sssd_var_run_t;
        type useradd_t;
        class dir { add_name write };
        class file { create getattr map open read write };
        class process signal;

#============= groupadd_t ==============
allow groupadd_t sssd_public_t:dir { add_name write };
allow groupadd_t sssd_public_t:file { create write };
allow groupadd_t sssd_t:process signal;
allow groupadd_t sssd_var_lib_t:file { map write };
allow groupadd_t sssd_var_run_t:file { getattr open read };

#============= useradd_t ==============
allow useradd_t sssd_public_t:dir { add_name write };
allow useradd_t sssd_public_t:file { create write };
allow useradd_t sssd_t:process signal;
allow useradd_t sssd_var_lib_t:file { map write };
allow useradd_t sssd_var_run_t:file { getattr open read };

I'm not sure if there is some better way to fix this issue.

This is repeatable when ever you create new used and when authselect has following (default) settings:

# authselect current
Profile ID: sssd
Enabled features:
- with-fingerprint
- with-silent-lastlog

I've seen this in other machines too but they had more setup before issue.
SELinux is preventing sss_cache from 'write' accesses on the file config.ldb.

*****  Plugin catchall (100. confidence) suggests   **************************

If you believe that sss_cache should be allowed write access on the config.ldb file by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
allow this access for now by executing:
# ausearch -c 'sss_cache' --raw | audit2allow -M my-ssscache
# semodule -X 300 -i my-ssscache.pp

Additional Information:
Source Context                system_u:system_r:passwd_t:s0
Target Context                system_u:object_r:sssd_var_lib_t:s0
Target Objects                config.ldb [ file ]
Source                        sss_cache
Source Path                   sss_cache
Port                          <Unknown>
Host                          (removed)
Source RPM Packages           
Target RPM Packages           
Policy RPM                    selinux-policy-3.14.2-42.fc29.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     (removed)
Platform                      Linux (removed) 4.19.6-300.fc29.x86_64 #1 SMP Sun
                              Dec 2 17:33:14 UTC 2018 x86_64 x86_64
Alert Count                   1
First Seen                    2018-12-06 21:24:55 EET
Last Seen                     2018-12-06 21:24:55 EET
Local ID                      54c6c383-ce1e-482e-9a5e-abb2392bdd90

Raw Audit Messages
type=AVC msg=audit(1544124295.109:300): avc:  denied  { write } for  pid=2320 comm="sss_cache" name="config.ldb" dev="dm-0" ino=134224 scontext=system_u:system_r:passwd_t:s0 tcontext=system_u:object_r:sssd_var_lib_t:s0 tclass=file permissive=0

Hash: sss_cache,passwd_t,sssd_var_lib_t,file,write

Version-Release number of selected component:

Additional info:
component:      selinux-policy
reporter:       libreport-2.9.6
hashmarkername: setroubleshoot
kernel:         4.19.6-300.fc29.x86_64
type:           libreport

Comment 1 Markus Linnala 2018-12-06 19:34:00 UTC
# rpm -q sssd

Comment 2 Lukas Slebodnik 2018-12-07 13:20:13 UTC
(In reply to Markus Linnala from comment #1)
> # rpm -q sssd
> sssd-2.0.0-4.fc29.x86_64

It has nothing to do with version of sssd.
It was cause by changes in shadow-utils which nowadays call sss_cache

Comment 3 Lukas Slebodnik 2018-12-07 13:20:47 UTC

*** This bug has been marked as a duplicate of bug 1640255 ***