5.11.3. Creating a User With a Specific MLS Range
Follow these steps to create a new Linux user with a specific MLS range:
- Add a new Linux user via the
useradd
command and map the new Linux user to an existing SELinux user (in this case,user_u
):useradd -Z user_u john
~]# useradd -Z user_u john
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Assign the newly-created Linux user a password:
passwd john
~]# passwd john
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Run the
semanage login -l
command to view the mapping between SELinux and Linux users. The output should be as follows:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Define a specific range for user
john
:semanage login --modify --seuser user_u --range s2:c100 john
~]# semanage login --modify --seuser user_u --range s2:c100 john
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Run the
semanage login -l
command to view the mapping between SELinux and Linux users. Note that the userjohn
now has a specific MLS range defined:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - To correct the label on john's home directory (if needed), run the following command:
chcon -R -l s2:c100 /home/john
~]# chcon -R -l s2:c100 /home/john
Copy to Clipboard Copied! Toggle word wrap Toggle overflow