Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
SELinux System Administration
SELinux System Administration

SELinux System Administration: With a command of SELinux you can enjoy watertight security on your Linux servers. This guide shows you how through examples taken from real-life situations, giving you a good grounding in all the available features.

eBook
€14.99 €21.99
Paperback
€26.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

SELinux System Administration

Chapter 2. Understanding SELinux Decisions and Logging

Once SELinux is enabled on a system, it starts its access control functionality as described in the previous chapter. This however might have some unwanted side effects, so in this chapter, we will:

  • Switch between SELinux in full enforcement mode (host-based intrusion prevention) versus its permissive, logging-only mode (host-based intrusion detection)

  • Use various methods to toggle the SELinux state (enabled or disabled, permissive or enforcing)

  • Disable SELinux protections for a single domain rather than the entire system

  • Learn to interpret the SELinux log events that describe to us what activities that SELinux has prevented

We finish with an overview of common methods for analyzing these logging events in day-to-day operations.

Disabling SELinux


Perhaps a weird chapter to begin with, but disabling SELinux is a commonly requested activity. Some vendors do not support their application to be running on a platform that has SELinux enabled. Luckily, this number is reducing.

SELinux supports three major states that it can be in: disabled, permissive, and enforcing. These states are by default set in the /etc/selinux/config file, through the SELINUX variable as follows:

$ grep ^SELINUX= /etc/selinux/config
SELINUX=enforcing

When the system init triggers loading the SELinux policy, the code checks the state that the administrator has configured. The states are described as follows:

  • If the state is disabled, then the SELinux code disables further support, making the system boot without activating SELinux.

  • If the state is permissive, then SELinux is active but will not enforce its policy on the system. Instead, any violations against the policy will be reported but remain allowed.

  • If the state is enforcing, then SELinux is...

SELinux on, SELinux off


We can toggle the SELinux state through the /etc/selinux/config file and reboot the system to have the changes being reflected. But this is not the only way.

Switching to permissive (or enforcing) temporarily

On most SELinux enabled systems, we can call the setenforce command to switch the system between permissive (0) and enforcing (1) mode. This takes effect immediately, allowing us to easily identify if SELinux is preventing access or not.

Try it out. Switch to the permissive mode and validate (again using sestatus, that the SELinux state has indeed been changed immediately as follows:

# setenforce 0

The effect of setenforce is the same as writing the value into the /sys/fs/selinux/enforce (or /selinux/enforce) pseudo file:

# echo 0 > /sys/fs/selinux/enforce

The ability to switch between the permissive and enforcing mode can be of interest for policy developers or system administrators who are modifying the system to use SELinux properly. This SELinux feature is...

SELinux logging and auditing


When SELinux is enabled, it will log (almost) every permission check that was denied. When Linux auditing is enabled, these denials are logged by the audit daemon. If not, then the regular system logger will get the denials and store them in the system logs.

Such denial messages are described with the type AVC (Access Vector Cache) as we can see from the following example:

type=AVC msg=audit(1369306885.125:4702304): avc:  denied  { append } for  pid=1787 comm=72733A6D61696E20513A526567 name="oracle_audit.log" dev=dm-18 ino=65 scontext=system_u:system_r:syslogd_t:s0 tcontext=system_u:object_r:usr_t:s0 tclass=file

The AVC is part of the SELinux security subsystem in the Linux kernel that is responsible for checking and enforcing the SELinux rules. Any permission that needs to be checked is represented as an "access vector" and the cache is then consulted to see if that particular permission has been checked before or not. If it is, then the decision is taken from...

Summary


We saw how to enable and disable SELinux both on a complete system level as well as a per service level using various methods: kernel boot options, SELinux configuration file, or plain commands. One of the commands is the use of semanage permissive, which can disable SELinux protections for a single service.

Next, we saw where SELinux log its events and how to interpret them, which is one of the most important capabilities of an administrator when dealing with SELinux. To assist us with this interpretation, there are tools such as setroubleshoot, sealert, and audit2why.

In the next chapter, we will look at the first administrative task on SELinux systems: managing user accounts and their associated SELinux roles and security clearances towards the resources on the system.

Left arrow icon Right arrow icon

Key benefits

  • Use SELinux to further control network communications
  • Enhance your system's security through SELinux access controls
  • Set up SELinux roles, users and their sensitivity levels

Description

NSA Security-Enhanced Linux (SELinux) is a set of patches and added utilities to the Linux kernel to incorporate a strong, flexible, mandatory access control architecture into the major subsystems of the kernel. With its fine-grained yet flexible approach, it is no wonder Linux distributions are firing up SELinux as a default security measure. SELinux System Administration covers the majority of SELinux features through a mix of real-life scenarios, descriptions, and examples. Everything an administrator needs to further tune SELinux to suit their needs are present in this book. This book touches on various SELinux topics, guiding you through the configuration of SELinux contexts, definitions, and the assignment of SELinux roles, and finishes up with policy enhancements. All of SELinux's configuration handles, be they conditional policies, constraints, policy types, or audit capabilities, are covered in this book with genuine examples that administrators might come across. By the end, SELinux System Administration will have taught you how to configure your Linux system to be more secure, powered by a formidable mandatory access control.

Who is this book for?

Linux administrators will enjoy the various SELinux features that this book covers and the approach used to guide the admin into understanding how SELinux works. The book assumes that you have basic knowledge in Linux administration, especially Linux permission and user management.

What you will learn

  • Enable and disable features selectively or even enforce them to a granular level
  • Interpret SELinux logging to make security-conscious decisions
  • Assign new contexts and sensitivity labels to files and other resources
  • Work with mod_selinux to secure web applications
  • Use tools like sudo, runcon, and newrole to switch roles and run privileged commands in a safe environment
  • Use iptables to assign labels to network packets
  • Configure IPSec and NetLabel to transport SELinux contexts over the wire
  • Build your own SELinux policies using reference policy interfaces

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Sep 24, 2013
Length: 120 pages
Edition : 1st
Language : English
ISBN-13 : 9781783283170
Vendor :
Red Hat
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Sep 24, 2013
Length: 120 pages
Edition : 1st
Language : English
ISBN-13 : 9781783283170
Vendor :
Red Hat
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 105.97
SELinux Cookbook
€36.99
Web Penetration Testing with Kali Linux
€41.99
SELinux System Administration
€26.99
Total 105.97 Stars icon

Table of Contents

6 Chapters
Fundamental SELinux Concepts Chevron down icon Chevron up icon
Understanding SELinux Decisions and Logging Chevron down icon Chevron up icon
Managing User Logins Chevron down icon Chevron up icon
Process Domains and File-level Access Controls Chevron down icon Chevron up icon
Controlling Network Communications Chevron down icon Chevron up icon
Working with SELinux Policies Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.2
(9 Ratings)
5 star 44.4%
4 star 33.3%
3 star 22.2%
2 star 0%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Robert S. Apr 11, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Helped me solve issues immediately. Did not have much knowledge of SELinux, and with this book I was able to get my server working properly and efficiently quickly.
Amazon Verified review Amazon
Kindle Customer Dec 30, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This is a very nice introduction, for me, to SELinux. I have always ended up running my Linux system (basically a desktop) in "permissive" mode. The main reason is that I just wanted to get my work done and I kept getting "dings" from SELinux in Enforcing mode which where stopping me. This book took me only about 4 hours to read from cover to cover (OK, I didn't read the index). But it introduced me to enough of the concepts and commands in SELinux for me to be comfortable to try changing to "Enforcing" mode.
Amazon Verified review Amazon
Leupold, Sven Nov 27, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Excellent book if you're looking for an overview. Although the matter is not simple and easy to begin with, Sven Vermeulen's book guides you step by step into SELinux Administration. The command line examples in the text, help you to understand the basics and dive into even deeper.I would absolutly recommend this book to everybody who is willing to learn about SELinux and features. 5 stars!
Amazon Verified review Amazon
Adam J Miller Dec 01, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Wonderful resource for any Linux Systems Administrator digging into SELinux. This book covers multiple distributions and is written in an approachable way that isn't too dry or overly daunting. Definitely recommended for Admins/Ops looking to gain SELinux knowledge.
Amazon Verified review Amazon
Alberto Reis Aug 01, 2016
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Sven oferece uma abordagem bastante flexível para você implantar SELinux sem restringir a uma distribução especificamente. Este é o ponto forte deste livro, mostrar diversas ferramentas que você pode usar para uma mesma tarefa considerando um ambiente Linux heterogêneo. A experiência do autor lhe permite mostrar o que é mais apropriado usar, pois SELinux está por aí há algum tempo e distribuições implementam ferramentas convenientes para sua comunidade.Os exemplos utilizados ilustram o conceito e mecanismos apresentados, A leitura é interessante executando conforme o leitor avança entre os capítulos. Embora já tivesse lido o manual do administrador SELinux da distribuição que escolhi, achei que o texto trás uma introdução suficiente para iniciar por este livro.Cobre superficialmente o desenvolvimento de módulos do SELinux, apresenta uma comparação entre duas maneiras de especificar as políticas de segurança, modo "nativo" menos usual e através de referências para outros módulos com o uso de macros de uma API que ele não descreve neste livro.Recomendo este livro para administradores de sistemas, mas se você tem uma tarefa que exigirá o desenvolvimento de módulos do SELinux, então será necessário uma literatura adicional, caso tenha domínio sobre os conceitos apresentados no manual do administrador do SELinux da sua distribuição Linux, esta óbra é informativa e opcional.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.