Hands-on lab – SELinux type enforcement

In this lab, you'll install the Apache web server and the appropriate SELinux tools. You'll then view the effects of having the wrong SELinux type assigned to a web content file.

  1. Install Apache, along with all the required SELinux tools:
        sudo yum install httpd setroubleshoot setools 
policycoreutils policycoreutils-python
  1. Activate setroubleshoot by restarting the auditd service:
        sudo service auditd restart
  1. Enable and start the Apache service and open port 80 on the firewall:
        sudo systemctl enable --now httpd
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reload
  1. In the /var/www/html directory, create an index.html file with the following contents:
        <html>
<head>
<title>SELinux Test Page</title>
</head>
<body>
This is a test of SELinux.
</body>
</html>
  1. View the SELinux information about the index.html file:
        ls -Z index.html
  1. In your host machine's web browser, navigate to the IP address of the CentOS virtual machine. You should be able to view the page.
  2. Induce an SELinux violation by changing the type of the index.html file to something that's incorrect:
        sudo chcon -t tmp_t index.html
ls -Z index.html
  1. Go back to your host machine's web browser, and reload the document. You should now see a Forbidden message.
  2. Use restorecon to change the file back to its correct type:
        sudo restorecon index.html
  1. Reload the page in your host machine's web browser. You should now be able to view the page.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.9.141