selinux:selinux_policy_module
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
selinux:selinux_policy_module [2016/07/14 15:08] – created peter | selinux:selinux_policy_module [2019/12/04 20:23] (current) – removed peter | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== SELinux - SELinux Policy Module ====== | ||
- | |||
- | A SELinux policy module is built by following steps: | ||
- | |||
- | * Generate a set of policy rules: audit2allow | ||
- | * Compile: checkmodule | ||
- | * Build: semodule_package | ||
- | |||
- | See http:// | ||
- | |||
- | |||
- | |||
- | Assuming that I have a postgreylocal.te file with the following content: | ||
- | |||
- | < | ||
- | module postgreylocal 1.0; | ||
- | require { | ||
- | type postfix_smtpd_t; | ||
- | type postfix_spool_t; | ||
- | type initrc_t; | ||
- | class sock_file write; | ||
- | class unix_stream_socket connectto; | ||
- | } | ||
- | # | ||
- | allow postfix_smtpd_t initrc_t: | ||
- | allow postfix_smtpd_t postfix_spool_t: | ||
- | </ | ||
- | |||
- | |||
- | The postgreylocal.pp policy module will be created with: | ||
- | |||
- | <code bash> | ||
- | # checkmodule -M -m -o postgreylocal.mod postgreylocal.te | ||
- | # semodule_package -m postgreylocal.mod -o postgreylocal.pp | ||
- | </ | ||
- | |||
- | |||
- | To unpack (disassemble) this policy module, you need a tool which is called **semodule_unpackage** to extract the .mod file and then use **dismod** to disassemble the binary module to textual representation. | ||
- | |||
- | |||
- | On my Gentoo, the following packages need to be installed: | ||
- | |||
- | [I] sys-apps/ | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | |||
- | [I] sys-apps/ | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | |||
- | [I] sys-libs/ | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | |||
- | |||
- | Firstly, extract the module from .pp file: | ||
- | |||
- | <code bash> | ||
- | semodule_unpackage postgreylocal.pp postgreylocal.mod | ||
- | </ | ||
- | |||
- | and secondly, disassemble with dismod: | ||
- | |||
- | <code bash> | ||
- | # cd checkpolicy-2.1.0/ | ||
- | # ls | ||
- | dismod.c | ||
- | # make | ||
- | cc -g -Wall -O2 -pipe -I/ | ||
- | dispol.c: In function ‘main’: | ||
- | dispol.c: | ||
- | dispol.c: | ||
- | dispol.c: | ||
- | dispol.c: | ||
- | cc | ||
- | cc -g -Wall -O2 -pipe -I/ | ||
- | dismod.c: In function ‘main’: | ||
- | dismod.c: | ||
- | dismod.c: | ||
- | dismod.c: In function ‘link_module’: | ||
- | dismod.c: | ||
- | cc | ||
- | # ls | ||
- | dismod | ||
- | </ | ||
- | |||
- | |||
- | |||
- | <code bash> | ||
- | ./dismod postgreylocal.pp | ||
- | Reading policy... | ||
- | libsepol.policydb_index_others: | ||
- | libsepol.policydb_index_others: | ||
- | libsepol.policydb_index_others: | ||
- | libsepol.policydb_index_others: | ||
- | libsepol.policydb_index_others: | ||
- | libsepol.policydb_index_others: | ||
- | Binary policy module file loaded. | ||
- | Module name: postgreylocal | ||
- | Module version: 1.0 | ||
- | |||
- | |||
- | Select a command: | ||
- | 1) display unconditional AVTAB | ||
- | 2) display conditional AVTAB | ||
- | 3) display users | ||
- | 4) display bools | ||
- | 5) display roles | ||
- | 6) display types, attributes, and aliases | ||
- | 7) display role transitions | ||
- | 8) display role allows | ||
- | 9) Display policycon | ||
- | 0) Display initial SIDs | ||
- | |||
- | a) Display avrule requirements | ||
- | b) Display avrule declarations | ||
- | c) Display policy capabilities | ||
- | l) Link in a module | ||
- | u) Display the unknown handling setting | ||
- | F) Display filename_trans rules | ||
- | |||
- | f) set output file | ||
- | m) display menu | ||
- | q) quit | ||
- | </ | ||
- | |||
- | |||
- | < | ||
- | Command (' | ||
- | unconditional avtab: | ||
- | --- begin avrule block --- | ||
- | decl 1: | ||
- | allow [postfix_smtpd_t] [initrc_t] : [unix_stream_socket] { connectto }; | ||
- | allow [postfix_smtpd_t] [postfix_spool_t] : [sock_file] { write }; | ||
- | |||
- | Command (' | ||
- | avrule block requirements: | ||
- | --- begin avrule block --- | ||
- | decl 1: | ||
- | commons: < | ||
- | classes: sock_file{ | ||
- | roles : < | ||
- | types : postfix_smtpd_t postfix_spool_t initrc_t | ||
- | users : < | ||
- | bools : < | ||
- | levels : < | ||
- | cats : < | ||
- | |||
- | Command (' | ||
- | </ | ||
- | |||
- | ===== Comments ===== | ||
- | |||
- | On Fedora it is named, | ||
- | |||
selinux/selinux_policy_module.1468508881.txt.gz · Last modified: 2020/07/15 09:30 (external edit)