Creating a new role
Roles are part of SELinux policies. In order to create a new role, it isn't possible to just invoke a few semanage
commands. Instead, an SELinux policy module will need to be created.
How to do it…
The SELinux policy needs to be updated in order to create a new role. The following steps can be used to do just that:
- Create a new policy module named after the role to be created, such as
pgsqladm
(for a PostgreSQL administration role). - In the policy module, call the
userdom_login_user_template
interface:userdom_login_user_template(pgsqladm)
- Assign the proper privileges to the
pgsqladm_r
role andpgsqladm_t
type:postgresql_admin(pgsqladm_t, pgsqladm_r)
- Edit the
default_type
file in/etc/selinux/mcs/contexts/
to makepgsqladm_t
the default ...
Get SELinux Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.