Booleans and ports: setsebool, semanage port
Sign in to read this lesson
The contexts are right, but httpd still cannot connect to the database, or a service will not start on port 8090. These are SELinux's two other switches — booleans (the policy's ready-made on/off switches) and port types. In this lesson we learn to read and change both correctly.
What you will learn
- A boolean is a ready-made option in the policy:
getsebool -a | grep httpd,semanage boolean -lwith descriptions. setsebool -P httpd_can_network_connect_db on— without-Pthe change is lost on reboot.- Each service can bind only to ports of its own port type:
semanage port -l | grep http_port_t. - A new port:
semanage port -a -t http_port_t -p tcp 8090; do not forget to open it in firewalld too. - Typical booleans:
httpd_can_network_connect,httpd_can_network_connect_db,httpd_enable_homedirs,samba_enable_home_dirs,use_nfs_home_dirs.
The lesson has 5 key points, an explanation and 5 questions. It opens with a package.