Ce contenu n'est pas disponible dans la langue sélectionnée.
6.3. Confining Existing Linux Users: semanage login
If a Linux user is mapped to the SELinux
unconfined_u user (the default behavior), and you would like to change which SELinux user they are mapped to, use the semanage login command. The following example creates a new Linux user named newuser, then maps that Linux user to the SELinux user_u user:
Procedure 6.2. Mapping Linux Users to the SELinux Users
- As root, create a new Linux user (
newuser). Since this user uses the default mapping, it does not appear in thesemanage login -loutput:useradd newuser
~]# useradd newuserCopy to Clipboard Copied! Toggle word wrap Toggle overflow Copy to Clipboard Copied! Toggle word wrap Toggle overflow - To map the Linux
newuseruser to the SELinuxuser_uuser, enter the following command as root:semanage login -a -s user_u newuser
~]# semanage login -a -s user_u newuserCopy to Clipboard Copied! Toggle word wrap Toggle overflow The-aoption adds a new record, and the-soption specifies the SELinux user to map a Linux user to. The last argument,newuser, is the Linux user you want mapped to the specified SELinux user. - To view the mapping between the Linux
newuseruser anduser_u, use thesemanageutility again:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - As root, assign a password to the Linux
newuseruser:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Log out of your current session, and log in as the Linux
newuseruser. Enter the following command to view thenewuser's SELinux context:id -Z
~]$ id -Z user_u:user_r:user_t:s0Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Log out of the Linux
newuser's session, and log back in with your account. If you do not want the Linuxnewuseruser, enter the following command as root to remove it, along with its home directory:userdel -r newuser
~]# userdel -r newuserCopy to Clipboard Copied! Toggle word wrap Toggle overflow As root, remove the mapping between the Linuxnewuseruser anduser_u:semanage login -d newuser
~]# semanage login -d newuserCopy to Clipboard Copied! Toggle word wrap Toggle overflow Copy to Clipboard Copied! Toggle word wrap Toggle overflow