SlideShare une entreprise Scribd logo
1  sur  7
Télécharger pour lire hors ligne
777
Customizing SELinux Policy
46.1. Introduction
In earlier releases of Red Hat Enterprise Linux it was necessary to install the selinux-policy-
targeted-sources packages and then to create a local.te file in the /etc/selinux/
targeted/src/policy/domains/misc directory. You could use the audit2allow utility to
translate the AVC messages into allow rules, and then rebuild and reload the policy.
The problem with this was that every time a new policy package was released it would have to
execute the Makefile in order to try to keep the local policy.
In Red Hat Enterprise Linux 5, this process has been completely revised. The "sources" rpm packages
have been completely removed, and policy packages are treated more like the kernel. To look
at the sources used to build the policy, you need to install the source rpm, selinux-policy-
XYZ.src.rpm. A further package, selinux-policy-devel, has also been added, which provides
further customization functionality.
46.1.1. Modular Policy
Red Hat Enterprise Linux introduces the concept of modular policy. This allows vendors to ship
SELinux policy separately from the operating system policy. It also allows administrators to make local
changes to policy without worrying about the next policy install. The most important command that was
added was semodule.
semodule is the tool used to manage SELinux policy modules, including installing, upgrading, listing
and removing modules. You can also use semodule to force a rebuild of policy from the module
store and/or to force a reload of policy without performing any other transaction. semodule acts
on module packages created by semodule_package. Conventionally, these files have a .pp suffix
(policy package), although this is not mandated in any way.
46.1.1.1. Listing Policy Modules
To list the policy modules on a system, use the semodule -l command:
[root@host2a ~]# semodule -l
amavis 1.1.0
ccs 1.0.0
clamav 1.1.0
dcc 1.1.0
evolution 1.1.0
iscsid 1.0.0
mozilla 1.1.0
mplayer 1.1.0
nagios 1.1.0
oddjob 1.0.1
pcscd 1.0.0
pyzor 1.1.0
razor 1.1.0
ricci 1.0.0
smart mon 1.1.0
778
Capítulo 46. Customizing SELinux Policy
Note
This command does not list the base policy module, which is also installed.
The /usr/share/selinux/targeted/ directory contains a number of policy
package (*.pp) files. These files are included in the selinux-policy rpm and are
used to build the policy file.
46.2. Building a Local Policy Module
The following section uses an actual example to demonstrate building a local policy module to address
an issue with the current policy. This issue involves the ypbind init script, which executes the
setsebool command, which in turn tries to use the terminal. This is generating the following denial:
type=AVC msg=audit(1164222416.269:22): avc: denied { use } for pid=1940 comm="setsebool"
name="0" dev=devpts ino=2 
scontext=system_u:system_r:semanage_t:s0 tc onte xt=syste m_u:syste m_r:init_t:s0 tc lass=fd
Even though everything still works correctly (that is, it is not preventing any applications form running
as intended), it does interrupt the normal work flow of the user. Creating a local policy module
addresses this issue.
46.2.1. Using audit2allow to Build a Local Policy Module
The audit2allow utility now has the ability to build policy modules. Use the following command to
build a policy module based on specific contents of the audit.log file:
ausearch -m AVC --comm setsebool | audit2allow -M mysemanage
The audit2allow utility has built a type enforcement file (mysemanage.te). It then executed
the check module command to compile a module file (mysemanage.mod). Lastly, it uses
the semodule_package command to create a policy package (mysemanage.pp). The
semodule_package command combines different policy files (usually just the module and potentially
a file context file) into a policy package.
46.2.2. Analyzing the Type Enforcement (TE) File
Use the cat command to inspect the contents of the TE file:
[root@host2a ~]# cat mysemanag.te
module mysemanage 1.0;
require {
cla ss fd use ;
type init_t;
type semanage_t;
role syste m_r;
};
allow semanage_t init_t:fd use;
779
Loading the Policy Package
The TE file is comprised of three sections. The first section is the module command, which identifies
the module name and version. The module name must be unique. If you create an semanage module
using the name of a pre-existing module, the system would try to replace the existing module package
with the newly-created version. The last part of the module line is the version. semodule can update
module packages and checks the update version against the currently installed version.
The next block of the TE file is the require block. This informs the policy loader which types, classes
and roles are required in the system policy before this module can be installed. If any of these fields
are undefined, the semodule command will fail.
Lastly are the allow rules. In this example, you could modify this line to dontaudit, because
semodule does not need to access the file descriptor.
46.2.3. Loading the Policy Package
The last step in the process of creating a local policy module is to load the policy package into the
kernel.
Use the semodule command to load the policy package:
[root@host2a ~]# semodule -i mysemana ge.pp
This command recompiles the policy file and regenerates the file context file. The changes are
permanent and will survive a reboot. You can also copy the policy package file (mysemanage.pp) to
other machines and install it using semodule.
The audit2allow command outputs the commands it executed to create the policy package so that
you can edit the TE file. This means you can add new rules as required or change the allow rule to
dontaudit. You could then recompile and repackage the policy package to be installed again.
There is no limit to the number of policy packages, so you could create one for each local modification
you want to make. Alternatively, you could continue to edit a single package, but you need to ensure
that the "require" statements match all of the allow rules.
780
781
Referencias
Las siguientes referencias apuntan a información adicional que es relevante a SELinux y Red Hat
Enterprise Linux pero que va más allá del propósito de este manual. Tenga en cuenta que debido
al rápido desarrollo de SELinux, este material podría ser aplicable únicamente a un lanzamiento
específico de Red Hat Enterprise Linux.
Libros
SELinux by Example
Mayer, MacMillan, and Caplan
Prentice Hall, 2007
Tutoriales y ayuda
Understanding and Customizing the Apache HTTP SELinux Policy
http://docs.fedoraproject.org/selinux-apache-fc3/
Tutorials and talks from Russell Coker
http://www.coker.com.au/selinux/talks/ibmtu-2004/
Generic Writing SELinux policy HOWTO
https://sourceforge.net/docman/display_doc.php?docid=21959[amp ]group_id=21266
1
Red Hat Knowledgebase
http://kbase.redhat.com/
Información general
Sitio web principal de NSA SELinux
http://www.nsa.gov/research/selinux/index.shtml
NSA SELinux, Preguntas frecuentes
http://www.nsa.gov/research/selinux/faqs.shtml
Fedora SELinux, Preguntas frecuentes
http://docs.fedoraproject.org/selinux-faq/
SELinux NSA's Open Source Security Enhanced Linux
http://www.oreilly.com/catalog/selinux/
Tecnologías
An Overview of Object Classes and Permissions
http://www.tresys.com/selinux/obj_perms_help.html
Integrating Flexible Support for Security Policies into the Linux Operating System (una historia de la
implementación de Flask en Linux, artículo en inglés)
http://www.nsa.gov/research/_files/selinux/papers/freenix01/freenix01.shtml
1
https://sourceforge.net/docman/display_doc.php?docid=21959[amp ]group_id=21266
Capítulo 47. Referencias
782
Implementing SELinux as a Linux Security Module
http://www.nsa.gov/research/selinux/index.shtmlpapers/module-abs.cfm
A Security Policy Configuration for the Security-Enhanced Linux
http://www.nsa.gov/research/_files/selinux/papers/policy/policy.shtml
Comunidad
Página de la comunidad SELinux
http://selinux.sourceforge.net
IRC
irc.freenode.net, #rhel-selinux
Capítulo 47. Referencias
783
Historia
Quick history of Flask
http://www.cs.utah.edu/flux/fluke/html/flask.html
Full background on Fluke
http://www.cs.utah.edu/flux/fluke/html/index.html

Contenu connexe

Similaire à 46 customizing se linux policy

Deploy Application Files with Git
Deploy Application Files with GitDeploy Application Files with Git
Deploy Application Files with GitAlec Clews
 
Managing Perl Installations: A SysAdmin's View
Managing Perl Installations: A SysAdmin's ViewManaging Perl Installations: A SysAdmin's View
Managing Perl Installations: A SysAdmin's ViewBaden Hughes
 
Unix Automation using centralized configuration management tool
Unix Automation using centralized configuration management toolUnix Automation using centralized configuration management tool
Unix Automation using centralized configuration management toolTorrid Networks Private Limited
 
Unix Automation using centralized configuration management tool
Unix Automation using centralized configuration management toolUnix Automation using centralized configuration management tool
Unix Automation using centralized configuration management toolTorrid Networks Private Limited
 
Upgrading to MySQL 8.0 webinar slides November 27th, 2019
Upgrading to MySQL 8.0 webinar slides November 27th, 2019Upgrading to MySQL 8.0 webinar slides November 27th, 2019
Upgrading to MySQL 8.0 webinar slides November 27th, 2019Dave Stokes
 
CMSIS_RTOS_Tutorial.pdf
CMSIS_RTOS_Tutorial.pdfCMSIS_RTOS_Tutorial.pdf
CMSIS_RTOS_Tutorial.pdfchau44
 
2008-07-30 IBM Teach the Teacher (IBM T3), Red Hat Update for System z
2008-07-30 IBM Teach the Teacher (IBM T3), Red Hat Update for System z2008-07-30 IBM Teach the Teacher (IBM T3), Red Hat Update for System z
2008-07-30 IBM Teach the Teacher (IBM T3), Red Hat Update for System zShawn Wells
 
Odoo (Build module, Security, ORM)
Odoo (Build module, Security, ORM)Odoo (Build module, Security, ORM)
Odoo (Build module, Security, ORM)sroo galal
 
Cgroup resource mgmt_v1
Cgroup resource mgmt_v1Cgroup resource mgmt_v1
Cgroup resource mgmt_v1sprdd
 
Cgroup resource mgmt_v1
Cgroup resource mgmt_v1Cgroup resource mgmt_v1
Cgroup resource mgmt_v1sprdd
 
Exploit Frameworks
Exploit FrameworksExploit Frameworks
Exploit Frameworksphanleson
 
SELinux concept in rhel_Linux_today.pptx
SELinux concept in rhel_Linux_today.pptxSELinux concept in rhel_Linux_today.pptx
SELinux concept in rhel_Linux_today.pptxAbhradipChatterjee2
 
MKT 100Week 6 Assignment{Enter Student Name Here}{Enter Bu.docx
MKT 100Week 6 Assignment{Enter Student Name Here}{Enter Bu.docxMKT 100Week 6 Assignment{Enter Student Name Here}{Enter Bu.docx
MKT 100Week 6 Assignment{Enter Student Name Here}{Enter Bu.docxkendalfarrier
 

Similaire à 46 customizing se linux policy (20)

Deploy Application Files with Git
Deploy Application Files with GitDeploy Application Files with Git
Deploy Application Files with Git
 
Readme
ReadmeReadme
Readme
 
Managing Perl Installations: A SysAdmin's View
Managing Perl Installations: A SysAdmin's ViewManaging Perl Installations: A SysAdmin's View
Managing Perl Installations: A SysAdmin's View
 
SELinux Basic Usage
SELinux Basic UsageSELinux Basic Usage
SELinux Basic Usage
 
The Domino 10 RHEL 7 Primer
The Domino 10 RHEL 7 PrimerThe Domino 10 RHEL 7 Primer
The Domino 10 RHEL 7 Primer
 
Unix Automation using centralized configuration management tool
Unix Automation using centralized configuration management toolUnix Automation using centralized configuration management tool
Unix Automation using centralized configuration management tool
 
Unix Automation using centralized configuration management tool
Unix Automation using centralized configuration management toolUnix Automation using centralized configuration management tool
Unix Automation using centralized configuration management tool
 
Drupal Modules
Drupal ModulesDrupal Modules
Drupal Modules
 
Upgrading to MySQL 8.0 webinar slides November 27th, 2019
Upgrading to MySQL 8.0 webinar slides November 27th, 2019Upgrading to MySQL 8.0 webinar slides November 27th, 2019
Upgrading to MySQL 8.0 webinar slides November 27th, 2019
 
CMSIS_RTOS_Tutorial.pdf
CMSIS_RTOS_Tutorial.pdfCMSIS_RTOS_Tutorial.pdf
CMSIS_RTOS_Tutorial.pdf
 
2008-07-30 IBM Teach the Teacher (IBM T3), Red Hat Update for System z
2008-07-30 IBM Teach the Teacher (IBM T3), Red Hat Update for System z2008-07-30 IBM Teach the Teacher (IBM T3), Red Hat Update for System z
2008-07-30 IBM Teach the Teacher (IBM T3), Red Hat Update for System z
 
First steps on CentOs7
First steps on CentOs7First steps on CentOs7
First steps on CentOs7
 
Odoo (Build module, Security, ORM)
Odoo (Build module, Security, ORM)Odoo (Build module, Security, ORM)
Odoo (Build module, Security, ORM)
 
Puppet quick start guide
Puppet quick start guidePuppet quick start guide
Puppet quick start guide
 
AtoZ about TYPO3 v8 CMS
AtoZ about TYPO3 v8 CMSAtoZ about TYPO3 v8 CMS
AtoZ about TYPO3 v8 CMS
 
Cgroup resource mgmt_v1
Cgroup resource mgmt_v1Cgroup resource mgmt_v1
Cgroup resource mgmt_v1
 
Cgroup resource mgmt_v1
Cgroup resource mgmt_v1Cgroup resource mgmt_v1
Cgroup resource mgmt_v1
 
Exploit Frameworks
Exploit FrameworksExploit Frameworks
Exploit Frameworks
 
SELinux concept in rhel_Linux_today.pptx
SELinux concept in rhel_Linux_today.pptxSELinux concept in rhel_Linux_today.pptx
SELinux concept in rhel_Linux_today.pptx
 
MKT 100Week 6 Assignment{Enter Student Name Here}{Enter Bu.docx
MKT 100Week 6 Assignment{Enter Student Name Here}{Enter Bu.docxMKT 100Week 6 Assignment{Enter Student Name Here}{Enter Bu.docx
MKT 100Week 6 Assignment{Enter Student Name Here}{Enter Bu.docx
 

Plus de Aprende Viendo

44 seguridad y se linux
44  seguridad y se linux44  seguridad y se linux
44 seguridad y se linuxAprende Viendo
 
43 aseguramiento de su red
43  aseguramiento de su red43  aseguramiento de su red
43 aseguramiento de su redAprende Viendo
 
42 seguridad y autenticación
42  seguridad y autenticación42  seguridad y autenticación
42 seguridad y autenticaciónAprende Viendo
 
41 parámetros y módulos generales
41  parámetros y módulos generales41  parámetros y módulos generales
41 parámetros y módulos generalesAprende Viendo
 
40 configuración del kernel y dispositivos
40  configuración del kernel y dispositivos40  configuración del kernel y dispositivos
40 configuración del kernel y dispositivosAprende Viendo
 
38 reunir información del sistema
38  reunir información del sistema38  reunir información del sistema
38 reunir información del sistemaAprende Viendo
 
37 supervisión del sistema
37  supervisión del sistema37  supervisión del sistema
37 supervisión del sistemaAprende Viendo
 
36 archivos de registro
36  archivos de registro36  archivos de registro
36 archivos de registroAprende Viendo
 
34 configuración de la impresora
34  configuración de la impresora34  configuración de la impresora
34 configuración de la impresoraAprende Viendo
 
32 configuración del sistema x window
32  configuración del sistema x window32  configuración del sistema x window
32 configuración del sistema x windowAprende Viendo
 
31 el sistema x window
31  el sistema x window31  el sistema x window
31 el sistema x windowAprende Viendo
 
29 configuración de la fecha y hora
29  configuración de la fecha y hora29  configuración de la fecha y hora
29 configuración de la fecha y horaAprende Viendo
 
27 configuración del sistema
27  configuración del sistema27  configuración del sistema
27 configuración del sistemaAprende Viendo
 
28 el directorio sysconfig
28  el directorio sysconfig28  el directorio sysconfig
28 el directorio sysconfigAprende Viendo
 
25 protocolo ligero de acceso a directorios ldap
25  protocolo ligero de acceso a directorios ldap25  protocolo ligero de acceso a directorios ldap
25 protocolo ligero de acceso a directorios ldapAprende Viendo
 
24 correo electrónico
24  correo electrónico24  correo electrónico
24 correo electrónicoAprende Viendo
 

Plus de Aprende Viendo (20)

44 seguridad y se linux
44  seguridad y se linux44  seguridad y se linux
44 seguridad y se linux
 
43 aseguramiento de su red
43  aseguramiento de su red43  aseguramiento de su red
43 aseguramiento de su red
 
42 seguridad y autenticación
42  seguridad y autenticación42  seguridad y autenticación
42 seguridad y autenticación
 
41 parámetros y módulos generales
41  parámetros y módulos generales41  parámetros y módulos generales
41 parámetros y módulos generales
 
40 configuración del kernel y dispositivos
40  configuración del kernel y dispositivos40  configuración del kernel y dispositivos
40 configuración del kernel y dispositivos
 
39 o profile
39  o profile39  o profile
39 o profile
 
38 reunir información del sistema
38  reunir información del sistema38  reunir información del sistema
38 reunir información del sistema
 
37 supervisión del sistema
37  supervisión del sistema37  supervisión del sistema
37 supervisión del sistema
 
36 archivos de registro
36  archivos de registro36  archivos de registro
36 archivos de registro
 
35 automated tasks
35  automated tasks35  automated tasks
35 automated tasks
 
34 configuración de la impresora
34  configuración de la impresora34  configuración de la impresora
34 configuración de la impresora
 
33 usuarios y grupos
33  usuarios y grupos33  usuarios y grupos
33 usuarios y grupos
 
32 configuración del sistema x window
32  configuración del sistema x window32  configuración del sistema x window
32 configuración del sistema x window
 
31 el sistema x window
31  el sistema x window31  el sistema x window
31 el sistema x window
 
29 configuración de la fecha y hora
29  configuración de la fecha y hora29  configuración de la fecha y hora
29 configuración de la fecha y hora
 
27 configuración del sistema
27  configuración del sistema27  configuración del sistema
27 configuración del sistema
 
28 el directorio sysconfig
28  el directorio sysconfig28  el directorio sysconfig
28 el directorio sysconfig
 
25 protocolo ligero de acceso a directorios ldap
25  protocolo ligero de acceso a directorios ldap25  protocolo ligero de acceso a directorios ldap
25 protocolo ligero de acceso a directorios ldap
 
24 correo electrónico
24  correo electrónico24  correo electrónico
24 correo electrónico
 
22 apache http server
22  apache http server22  apache http server
22 apache http server
 

Dernier

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 

Dernier (20)

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 

46 customizing se linux policy

  • 1. 777 Customizing SELinux Policy 46.1. Introduction In earlier releases of Red Hat Enterprise Linux it was necessary to install the selinux-policy- targeted-sources packages and then to create a local.te file in the /etc/selinux/ targeted/src/policy/domains/misc directory. You could use the audit2allow utility to translate the AVC messages into allow rules, and then rebuild and reload the policy. The problem with this was that every time a new policy package was released it would have to execute the Makefile in order to try to keep the local policy. In Red Hat Enterprise Linux 5, this process has been completely revised. The "sources" rpm packages have been completely removed, and policy packages are treated more like the kernel. To look at the sources used to build the policy, you need to install the source rpm, selinux-policy- XYZ.src.rpm. A further package, selinux-policy-devel, has also been added, which provides further customization functionality. 46.1.1. Modular Policy Red Hat Enterprise Linux introduces the concept of modular policy. This allows vendors to ship SELinux policy separately from the operating system policy. It also allows administrators to make local changes to policy without worrying about the next policy install. The most important command that was added was semodule. semodule is the tool used to manage SELinux policy modules, including installing, upgrading, listing and removing modules. You can also use semodule to force a rebuild of policy from the module store and/or to force a reload of policy without performing any other transaction. semodule acts on module packages created by semodule_package. Conventionally, these files have a .pp suffix (policy package), although this is not mandated in any way. 46.1.1.1. Listing Policy Modules To list the policy modules on a system, use the semodule -l command: [root@host2a ~]# semodule -l amavis 1.1.0 ccs 1.0.0 clamav 1.1.0 dcc 1.1.0 evolution 1.1.0 iscsid 1.0.0 mozilla 1.1.0 mplayer 1.1.0 nagios 1.1.0 oddjob 1.0.1 pcscd 1.0.0 pyzor 1.1.0 razor 1.1.0 ricci 1.0.0 smart mon 1.1.0
  • 2. 778 Capítulo 46. Customizing SELinux Policy Note This command does not list the base policy module, which is also installed. The /usr/share/selinux/targeted/ directory contains a number of policy package (*.pp) files. These files are included in the selinux-policy rpm and are used to build the policy file. 46.2. Building a Local Policy Module The following section uses an actual example to demonstrate building a local policy module to address an issue with the current policy. This issue involves the ypbind init script, which executes the setsebool command, which in turn tries to use the terminal. This is generating the following denial: type=AVC msg=audit(1164222416.269:22): avc: denied { use } for pid=1940 comm="setsebool" name="0" dev=devpts ino=2 scontext=system_u:system_r:semanage_t:s0 tc onte xt=syste m_u:syste m_r:init_t:s0 tc lass=fd Even though everything still works correctly (that is, it is not preventing any applications form running as intended), it does interrupt the normal work flow of the user. Creating a local policy module addresses this issue. 46.2.1. Using audit2allow to Build a Local Policy Module The audit2allow utility now has the ability to build policy modules. Use the following command to build a policy module based on specific contents of the audit.log file: ausearch -m AVC --comm setsebool | audit2allow -M mysemanage The audit2allow utility has built a type enforcement file (mysemanage.te). It then executed the check module command to compile a module file (mysemanage.mod). Lastly, it uses the semodule_package command to create a policy package (mysemanage.pp). The semodule_package command combines different policy files (usually just the module and potentially a file context file) into a policy package. 46.2.2. Analyzing the Type Enforcement (TE) File Use the cat command to inspect the contents of the TE file: [root@host2a ~]# cat mysemanag.te module mysemanage 1.0; require { cla ss fd use ; type init_t; type semanage_t; role syste m_r; }; allow semanage_t init_t:fd use;
  • 3. 779 Loading the Policy Package The TE file is comprised of three sections. The first section is the module command, which identifies the module name and version. The module name must be unique. If you create an semanage module using the name of a pre-existing module, the system would try to replace the existing module package with the newly-created version. The last part of the module line is the version. semodule can update module packages and checks the update version against the currently installed version. The next block of the TE file is the require block. This informs the policy loader which types, classes and roles are required in the system policy before this module can be installed. If any of these fields are undefined, the semodule command will fail. Lastly are the allow rules. In this example, you could modify this line to dontaudit, because semodule does not need to access the file descriptor. 46.2.3. Loading the Policy Package The last step in the process of creating a local policy module is to load the policy package into the kernel. Use the semodule command to load the policy package: [root@host2a ~]# semodule -i mysemana ge.pp This command recompiles the policy file and regenerates the file context file. The changes are permanent and will survive a reboot. You can also copy the policy package file (mysemanage.pp) to other machines and install it using semodule. The audit2allow command outputs the commands it executed to create the policy package so that you can edit the TE file. This means you can add new rules as required or change the allow rule to dontaudit. You could then recompile and repackage the policy package to be installed again. There is no limit to the number of policy packages, so you could create one for each local modification you want to make. Alternatively, you could continue to edit a single package, but you need to ensure that the "require" statements match all of the allow rules.
  • 4. 780
  • 5. 781 Referencias Las siguientes referencias apuntan a información adicional que es relevante a SELinux y Red Hat Enterprise Linux pero que va más allá del propósito de este manual. Tenga en cuenta que debido al rápido desarrollo de SELinux, este material podría ser aplicable únicamente a un lanzamiento específico de Red Hat Enterprise Linux. Libros SELinux by Example Mayer, MacMillan, and Caplan Prentice Hall, 2007 Tutoriales y ayuda Understanding and Customizing the Apache HTTP SELinux Policy http://docs.fedoraproject.org/selinux-apache-fc3/ Tutorials and talks from Russell Coker http://www.coker.com.au/selinux/talks/ibmtu-2004/ Generic Writing SELinux policy HOWTO https://sourceforge.net/docman/display_doc.php?docid=21959[amp ]group_id=21266 1 Red Hat Knowledgebase http://kbase.redhat.com/ Información general Sitio web principal de NSA SELinux http://www.nsa.gov/research/selinux/index.shtml NSA SELinux, Preguntas frecuentes http://www.nsa.gov/research/selinux/faqs.shtml Fedora SELinux, Preguntas frecuentes http://docs.fedoraproject.org/selinux-faq/ SELinux NSA's Open Source Security Enhanced Linux http://www.oreilly.com/catalog/selinux/ Tecnologías An Overview of Object Classes and Permissions http://www.tresys.com/selinux/obj_perms_help.html Integrating Flexible Support for Security Policies into the Linux Operating System (una historia de la implementación de Flask en Linux, artículo en inglés) http://www.nsa.gov/research/_files/selinux/papers/freenix01/freenix01.shtml 1 https://sourceforge.net/docman/display_doc.php?docid=21959[amp ]group_id=21266
  • 6. Capítulo 47. Referencias 782 Implementing SELinux as a Linux Security Module http://www.nsa.gov/research/selinux/index.shtmlpapers/module-abs.cfm A Security Policy Configuration for the Security-Enhanced Linux http://www.nsa.gov/research/_files/selinux/papers/policy/policy.shtml Comunidad Página de la comunidad SELinux http://selinux.sourceforge.net IRC irc.freenode.net, #rhel-selinux
  • 7. Capítulo 47. Referencias 783 Historia Quick history of Flask http://www.cs.utah.edu/flux/fluke/html/flask.html Full background on Fluke http://www.cs.utah.edu/flux/fluke/html/index.html