Red Hat Enterprise Linux 7 Selinux User's and Administrator's Guide
Total Page:16
File Type:pdf, Size:1020Kb
Red Hat Enterprise Linux 7 SELinux User's and Administrator's Guide Basic and advanced configuration of Security-Enhanced Linux (SELinux) Barbora Ančincová Tomáš Čapek Red Hat Enterprise Linux 7 SELinux User's and Administrator's Guide Basic and advanced configuration of Security-Enhanced Linux (SELinux) Barbora Ančincová Red Hat Customer Content Services [email protected] Tomáš Čapek Red Hat Customer Content Services [email protected] Legal Notice Copyright © 2015 Red Hat, Inc. This document is licensed by Red Hat under the Creative Commons Attribution-ShareAlike 3.0 Unported License. If you distribute this document, or a modified version of it, you must provide attribution to Red Hat, Inc. and provide a link to the original. If the document is modified, all Red Hat trademarks must be removed. Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law. Red Hat, Red Hat Enterprise Linux, the Shadowman logo, JBoss, MetaMatrix, Fedora, the Infinity Logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries. Linux ® is the registered trademark of Linus Torvalds in the United States and other countries. Java ® is a registered trademark of Oracle and/or its affiliates. XFS ® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries. MySQL ® is a registered trademark of MySQL AB in the United States, the European Union and other countries. Node.js ® is an official trademark of Joyent. Red Hat Software Collections is not formally related to or endorsed by the official Joyent Node.js open source or commercial project. The OpenStack ® Word Mark and OpenStack Logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community. All other trademarks are the property of their respective owners. Abstract This book consists of two parts: SELinux and Managing Confined Services. The former describes the basics and principles upon which SELinux functions, the latter is more focused on practical tasks to set up and configure various services. T able of Cont ent s Table of Contents .P .a .r t. .I .. S. E. .L .i n. u. x. 4. .C .h .a .p . t.e .r . 1. .. I.n .t .r o. .d .u .c .t .i o. n. 5. 1.1. Benefits o f running SELinux 6 1.2. Examp les 6 1.3. SELinux Architecture 7 1.4. SELinux States and Mo d es 7 1.5. What Is New in Red Hat Enterp rise Linux 7 8 .C .h .a .p . t.e .r . 2. .. S. E. .L .i n. u. x. .C . o. n. t. e. x. t. s. 1. 2. 2.1. Do main Transitio ns 13 2.2. SELinux Co ntexts fo r Pro cesses 14 2.3. SELinux Co ntexts fo r Users 15 .C .h .a .p . t.e .r . 3. .. T. a. r. g. e. t. e. d. .P .o . l.i c. y. 1. 6. 3.1. Co nfined Pro cesses 16 3.2. Unco nfined Pro cesses 18 3.3. Co nfined and Unco nfined Users 21 .C .h .a .p . t.e .r . 4. .. W. .o .r .k i.n . g. .w . i.t h. S. E. L. i.n . u. x. 2. 6. 4.1. SELinux Packag es 26 4.2. Which Lo g File is Used 27 4.3. Main Co nfig uratio n File 28 4.4. Permanent Chang es in SELinux States and Mo d es 28 4.5. Bo o leans 31 4.6 . SELinux Co ntexts – Lab eling Files 34 4.7. The file_t and d efault_t Typ es 40 4.8 . Mo unting File Systems 40 4.9 . Maintaining SELinux Lab els 43 4.10 . Info rmatio n Gathering To o ls 51 4.11. Multi-Level Security (MLS) 53 4.12. File Name Transitio n 59 4.13. Disab le p trace() 6 0 4.14. Thumb nail Pro tectio n 6 1 .C .h .a .p . t.e .r . 5. .. T. h. .e . s. e. p. o. l.i c. y. .S . u. i.t .e . 6. 2. 5.1. The sep o licy Pytho n Bind ing s 6 2 5.2. Generating SELinux Po licy Mo d ules: sep o licy g enerate 6 2 5.3. Und erstand ing Do main Transitio ns: sep o licy transitio n 6 3 5.4. Generating Manual Pag es: sep o licy manp ag e 6 4 .C .h .a .p . t.e .r . 6. .. C. o. .n .f i.n . i.n .g . U. .s .e .r s. 6. 5. 6 .1. Linux and SELinux User Map p ing s 6 5 6 .2. Co nfining New Linux Users: userad d 6 5 6 .3. Co nfining Existing Linux Users: semanag e lo g in 6 6 6 .4. Chang ing the Default Map p ing 6 8 6 .5. xg uest: Kio sk Mo d e 6 8 6 .6 . Bo o leans fo r Users Executing Ap p licatio ns 6 9 .C .h .a .p . t.e .r . 7. .. s. V. i.r .t . 7. 1. No n-Virtualized Enviro nment 71 Virtualized Enviro nment 71 7.1. Security and Virtualizatio n 72 7.2. sVirt Lab eling 72 1 SELinux User's and Administ rat or's Guide 7.2. sVirt Lab eling 72 .C .h .a .p . t.e .r . 8. .. S. e. c. u. .r e. .L .i n. u. .x . C. o. n. .t a. i.n . e. r.s . 7. 4. .C .h .a .p . t.e .r . 9. .. S. E. .L .i n. u. x. .s .y .s .t .e .m . d. .A . c. c. e. s. s. .C .o .n . t.r .o .l . 7. 5. 9 .1. SELinux Access Permissio ns fo r Services 75 9 .2. SELinux and jo urnald 77 .C .h .a .p . t.e .r . 1. 0. .. T. .r o. .u .b .l e. s. h. .o .o .t .i n. g. ..