4.4. Managing access to non-standard shared directories for unprivileged SELinux users
You can configure access to a non-standard shared directory for the generic unprivileged SELinux user user_u by finding and mapping the corresponding SELinux file type. The user_u user has the default role user_r and the default domain user_t.
Prerequisites
-
The
selinux-policy-docandsetools-consolepackages are installed on your system.
Procedure
Open the
user_selinux(8)man page in your terminal:$ man user_selinuxIn the
MANAGED FILESsection, find an attribute or a type that corresponds with your scenario. For example, theuser_home_typeattribute.Optional: To list all types assigned to an attribute, use the
seinfocommand with the-xand-aoptions, for example:$ seinfo -x -a user_home_type Type Attributes: 1 attribute user_home_type; … chrome_sandbox_home_t config_home_t cvs_home_t data_home_t dbus_home_t fetchmail_home_t gconf_home_t git_user_content_t …After you identify a candidate for the corresponding type, the
data_home_ttype in this example, check its SELinux mapping:$ semanage fcontext -l | grep data_home_t … /root/\.local/share(/.*)? all files system_u:object_r:data_home_t:s0 …Map the corresponding type to a directory that you want to make accessible for
user_u, for example,/shared-data:$ semanage fcontext -a -t data_home_t '/shared-data(/.*)?'
Verification
Check the mapping of the directory you configured:
# semanage fcontext -l | grep "shared-data" /shared-data(/.*)? all files system_u:object_r:data_home_t:s0-
Log in as a Linux user mapped to the
user_uSELinux user, and verify you can access the directory.