Book Image

SELinux System Administration - Second Edition

By : Sven Vermeulen
Book Image

SELinux System Administration - Second Edition

By: Sven Vermeulen

Overview of this book

Do you have the crucial job of protecting your private and company systems from malicious attacks and undefined application behavior? Are you looking to secure your Linux systems with improved access controls? Look no further, intrepid administrator! This book will show you how to enhance your system’s secure state across Linux distributions, helping you keep application vulnerabilities at bay. This book covers the core SELinux concepts and shows you how to leverage SELinux to improve the protection measures of a Linux system. You will learn the SELinux fundamentals and all of SELinux’s configuration handles including conditional policies, constraints, policy types, and audit capabilities. These topics are paired with genuine examples of situations and issues you may come across as an administrator. In addition, you will learn how to further harden the virtualization offering of both libvirt (sVirt) and Docker through SELinux. By the end of the book you will know how SELinux works and how you can tune it to meet your needs.
Table of Contents (16 chapters)
SELinux System Administration - Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface

The context of a process


As everything in SELinux works with labels, even processes are assigned a label, also known as the domain.

Getting a process context

We saw that the Apache web server runs in the httpd_t domain, which can be seen with the ps -eZ command, as follows:

# ps -eZ | grep httpd 
system_u:system_r:httpd_t:s0 2270 ?        00:00:00 httpd 

There are a number of other ways to obtain the process context as well. Although the method with ps is the most obvious, these other methods can prove useful in scripted approaches or through monitoring services.

A first approach is to read the /proc/<pid>/attr/current pseudo-file, which we've already encountered previously in the book. It displays a process' current security context:

# pidof httpd 
1952 1951 1950 1949 1948 1947 
# cat /proc/1952/attr/current 
system_u:system_r:httpd_t:s0 

To receive a somewhat more human-readable output, use the secon command for the given process ID (PID):

# secon --pid...