Running commands in a specified role with sudo
When a user has been assigned multiple roles, they usually work with their primary role (such as staff_r
) and only selectively execute commands with the other role. This can be accomplished through the sudo
command, as these commands usually also require a different Linux user (which can be root
or the postgresql
account for DBA tasks on the PostgreSQL database server).
How to do it…
In order to configure sudo
to perform the right role and type transition, execute the following steps:
- Open up the
sudoers
file throughvisudo
:~# visudo
- Define the commands that the user(s) are allowed to execute. For instance, to allow all users in the
dba
group to callinitdb
in thedbadm_r
role, define the commands as ...
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.