SELinux refpolicy详解(7)

接前一篇文章:SELinux refpolicy详解(6)

三、refpolicy内容详解

1. README

文件路径:refpolicy源码根目录/README。

文件内容如下:

1) Reference Policy make targets:General Make targets:install-src		Install the policy sources into/etc/selinux/NAME/src/policy, where NAME is defined inthe Makefile.  If not defined, the TYPE, as defined inthe Makefile, is used.  The default NAME is refpolicy.A pre-existing source policy will be moved to/etc/selinux/NAME/src/policy.bak.conf			Regenerate policy.xml, and update/create modules.confand booleans.conf.  This should be done after addingor removing modules, or after running the bare target.If the configuration files exist, their settings willbe preserved.  This must be ran on policy sources thatare checked out from the CVS repository before they canbe used.clean			Delete all temporary files, compiled policies,and file_contexts.  Configuration files are left intact.bare			Do the clean make target and also delete configurationfiles, web page documentation, and policy.xml.html			Regenerate policy.xml and create web page documentationin the doc/html directory.Make targets specific to modular (loadable modules) policies:base			Compile and package the base module.  This is thedefault target for modular policies.modules			Compile and package all Reference Policy modulesconfigured to be built as loadable modules.MODULENAME.pp		Compile and package the MODULENAME Reference Policymodule.all			Compile and package the base module and all ReferencePolicy modules configured to be built as loadablemodules.install			Compile, package, and install the base module andReference Policy modules configured to be built asloadable modules.load			Compile, package, and install the base module andReference Policy modules configured to be built asloadable modules, then insert them into the modulestore.validate		Validate if the configured modules can successfullylink and expand.install-headers		Install the policy headers into /usr/share/selinux/NAME.The headers are sufficient for building a policymodule locally, without requiring the completeReference Policy sources.  The build.conf settingsfor this policy configuration should be set beforeusing this target.build-interface-db	Build the policy interface database with'sepolgen-ifgen'.  This database is required forreference style policy generation by'audit2allow --reference'.Make targets specific to monolithic policies:policy			Compile a policy locally for development and testing.This is the default target for monolithic policies.install			Compile and install the policy and file contexts.load			Compile and install the policy and file contexts, thenload the policy.enableaudit		Remove all dontaudit rules from policy.conf.relabel			Relabel the filesystem.checklabels		Check the labels on the filesystem, and report whena file would be relabeled, but do not change its label.restorelabels		Relabel the filesystem and report each file that isrelabeled.2) Reference Policy Build Options (build.conf)TYPE			String.  Available options are standard, mls, and mcs.For a type enforcement only system, set standard.This optionally enables multi-level security (MLS) ormulti-category security (MCS) features.  This optioncontrols enable_mls, and enable_mcs policy blocks.NAME			String (optional).  Sets the name of the policy; theNAME is used when installing files to e.g.,/etc/selinux/NAME and /usr/share/selinux/NAME.  If notset, the policy type (TYPE) is used.DISTRO			String (optional).  Enable distribution-specific policy.Available options are redhat, gentoo, and debian.This option controls distro_redhat, distro_gentoo, anddistro_debian build option policy blocks.MONOLITHIC		Boolean.  If set, a monolithic policy is built,otherwise a modular policy is built.DIRECT_INITRC		Boolean.  If set, sysadm will be allowed to directlyrun init scripts, instead of requiring the run_inittool.  This is a build option instead of a tunable sincerole transitions do not work in conditional policy.This option controls direct_sysadm_daemon policyblocks.OUTPUT_POLICY		Integer.  Set the version of the policy created whenbuilding a monolithic policy.  This option has no effecton modular policy.UNK_PERMS		String.  Set the kernel behavior for handling ofpermissions defined in the kernel but missing from thepolicy.  The permissions can either be allowed (allow),denied (deny), or the policy loading can be rejected(reject).UBAC			Boolean.  If set, the SELinux user will be usedadditionally for approximate role separation.SYSTEMD			Boolean.  If set, systemd will be assumed to be the initprocess provider.MLS_SENS		Integer.  Set the number of sensitivities in the MLSpolicy.  Ignored on standard and MCS policies.MLS_CATS		Integer.  Set the number of categories in the MLSpolicy.  Ignored on standard and MCS policies.MCS_CATS		Integer.  Set the number of categories in the MCSpolicy.  Ignored on standard and MLS policies.QUIET			Boolean.  If set, the build system will only displaystatus messages and error messages.  This option has noeffect on policy.WERROR			Boolean.  If set, the build system will treat warningsas errors.  If any warnings are encountered, the buildwill fail.3) Reference Policy Files and Directories
All directories relative to the root of the Reference Policy sources directory.Makefile		General rules for building the policy.Rules.modular		Makefile rules specific to building loadable modulepolicies.Rules.monolithic	Makefile rules specific to building monolithic policies.build.conf		Options which influence the building of the policy,such as the policy type and distribution.config/appconfig-*	Application configuration files for all configurationsof the Reference Policy (targeted/strict with or withoutMLS or MCS).  These are used by SELinux-aware programs.config/local.users	The file read by load policy for adding SELinux usersto the policy on the fly.doc/html/*		This contains the contents of the in-policy XMLdocumentation, presented in web page form.doc/policy.dtd		The doc/policy.xml file is validated against this DTD.doc/policy.xml		This file is generated/updated by the conf and html maketargets.  It contains the complete XML documentationincluded in the policy.doc/templates/*		Templates used for documentation web pages.policy/booleans.conf	This file is generated/updated by the conf make target.It contains the booleans in the policy, and theirdefault values.  If tunables are implemented asbooleans, tunables will also be included.  This filewill be installed as the /etc/selinux/NAME/booleansfile.policy/constraints	This file defines additional constraints on permissionsin the form of boolean expressions that must besatisfied in order for specified permissions to begranted.  These constraints are used to further refinethe type enforcement rules and the role allow rules.Typically, these constraints are used to restrictchanges in user identity or role to certain domains.policy/global_booleans	This file defines all booleans that have a global scope,their default value, and documentation.policy/global_tunables	This file defines all tunables that have a global scope,their default value, and documentation.policy/flask/initial_sids  This file has declarations for each initial SID.policy/flask/security_classes  This file has declarations for each security class.policy/flask/access_vectors  This file defines the access vectors.  Commonprefixes for access vectors may be defined at thebeginning of the file.  After the common prefixes aredefined, an access vector may be defined for eachsecurity class.policy/mcs		The multi-category security (MCS) configuration.policy/mls		The multi-level security (MLS) configuration.policy/modules/*	Each directory represents a layer in Reference Policyall of the modules are contained in one of these layers.policy/modules.conf	This file contains a listing of available modules, andhow they will be used when building Reference Policy. Toprevent a module from  being used, set the module to"off".  For monolithic policies, modules set to "base"and "module" will be included in the policy.  Formodular policies, modules set to "base"	will be includedin the base module; those set to "module" will becompiled as individual loadable	modules.policy/support/*	Support macros.policy/users		This file defines the users included in the policy.support/*		Tools used in the build process.4) Building policy modules using Reference Policy headers:The system must first have the Reference Policy headers installed, typically
by the distribution.  Otherwise, the headers can be installed using the
install-headers target from the full Reference Policy sources.To set up a directory to build a local module, one must simply place a .te
file in a directory.  A sample Makefile to use in the directory is the
Makefile.example in the doc directory.  This may be installed in
/usr/share/doc, under the directory for the distribution's policy.
Alternatively, the primary Makefile in the headers directory (typically
/usr/share/selinux/NAME/Makefile) can be called directly, using make's -f
option.Larger projects can set up a structure of layers, just as in Reference
Policy, by creating policy/modules/LAYERNAME directories.  Each layer also
must have a metadata.xml file which is an XML file with a summary tag and
optional desc (long description) tag.  This should describe the purpose of
the layer.Metadata.xml example:<summary>ABC modules for the XYZ components.</summary>Make targets for modules built from headers:MODULENAME.pp		Compile and package the MODULENAME local module.all			Compile and package the modules in the currentdirectory.load			Compile and package the modules in the currentdirectory, then insert them into the module store.refresh			Attempts to reinsert all modules that are currentlyin the module store from the local and system modulepackages.xml			Build a policy.xml from the XML included with thebase policy headers and any XML in the modules inthe current directory.

上一回讲解了README文件的第三部分,本回将讲解第四部分即最后一部分。

(4)Building policy modules using Reference Policy headers(使用参考策略头构建策略模块)

系统必须首先安装参考策略头,通常由发布版安装否则,可以使用来自完整参考策略源的install-headers target(目标)来安装头

要建立(设置)一个目录来构建本地模块,只需在目录中放置一个.te文件即可。在该目录下使用的示例Makefile是doc目录中的Makefile.example。

它可以安装在/usr/share/doc中,位于分发策略的目录下。或者,headers目录中的主Makefile(通常是/usr/share/selinux/NAME/Makefile)可以使用make -f选项直接调用。

较大的项目可以通过创建policy/modules/LAYERNAME目录来设置层结构,就像在参考策略中一样。每个层还必须有一个metadata.xml文件,该文件是一个带有摘要标记和可选的desc(长描述)标记的xml文件。其应该描述图层的用途。

Metadata.xml示例:

<summary>ABC modules for the XYZ components.</summary>

基于头构建模块的make target(目标)

  • MODULENAME.pp

编译并打包MODULENAME本地模块。

  • all

编译并打包当前目录下的模块。

  • load

编译并打包当前目录下的模块,然后将它们插入到模块存储(module store)中。

  • refresh

尝试从本地和系统模块包中重新插入模块存储区中当前的所有模块。

  • xml

根据基本策略头中包含的xml和当前目录中模块中的任何xml,构建policy.xml。

至此,README文件就讲解完了。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/189453.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【Skynet 入门实战练习】分布式 ID | 雪花算法 | 缓存设计 | LRU算法 | 数据库

文章目录 前言雪花算法LRU 算法缓存模块数据库测试逻辑 前言 本节实现了 分布式 ID 生成系统&#xff0c;采用雪花算法实现唯一 ID&#xff1b;实现缓存架构&#xff0c;采用 LRU &#xff08;最近最少使用&#xff09;算法。 雪花算法 分布式 ID 生成算法的有很多种&#x…

Redis——某马点评day01——短信登录

项目介绍 导入黑马点评项目 项目架构 基于Session实现登录 基本流程 实现发送短信验证码功能 controller层中 /*** 发送手机验证码*/PostMapping("code")public Result sendCode(RequestParam("phone") String phone, HttpSession session) {// 发送短信…

mysql8.0 提取json数据转为行

仅适用于mysql8.0&#xff0c;之前的版本不支持JSON_TABLE函数 数据结构: idnamejsonarr1张三[{"daystr": "2023-12-01","score": "53"},{"daystr": "2023-12-02","score": "78"}]2李四[{&q…

B站缓存视频M4S合并MP4(js + ffmpeg )

文章目录 B站缓存视频转MP4&#xff08;js ffmpeg &#xff09;1、说明 2、ffmpeg2.1 下载地址2.2 配置环境变量2.3 测试2.4 转换MP4命令 3、处理程序 B站缓存视频转MP4&#xff08;js ffmpeg &#xff09; 注意&#xff1a;这样的方式只用于个人之间不同设备的离线观看。请…

spring boot mybatis TypeHandler 看源码如何初始化及调用

目录 概述使用TypeHandler使用方式在 select | update | insert 中加入 配置文件中指定 源码分析配置文件指定Mapper 执行query如何转换 结束 概述 阅读此文 可以达到 spring boot mybatis TypeHandler 源码如何初始化及如何调用的。 spring boot 版本为 2.7.17&#xff0c;my…

SQL Server 2016(创建数据表)

1、需求描述。 在名为“class”的数据库中创建表&#xff0c;表名称为“course”&#xff0c;其中要包含序号、课程、课程编号、学分、任课教师、上课地点、开始时间、结束时间、备注等列。 设置各个字段的数据类型。其中&#xff0c;"序号"列为标识列&#xff0c;从…

4-Docker命令之docker kill

1.docker kill介绍 docker kill命令是用来杀掉一个或多个正在运行中的容器。 2.docker kill用法 docker kill [参数] container [container......] [root@centos79 ~]# docker kill --helpUsage: docker kill [OPTIONS] CONTAINER [CONTAINER...]Kill one or more running…

分享几个可以免费使用GPT工具

1. 国产可以使用GPT3.5和4.0的网站&#xff0c;每日有免费的使用额度&#xff0c;响应速度&#xff0c;注册时不用使用手机号&#xff0c;等个人信息&#xff0c;注重用户隐私&#xff0c;好评&#xff01; 一个好用的ChatGPT系统 &#xff0c;可以免费使用3.5 和 4.0https://…

3台4核16G机器搭建K8S集群

在三台具有4核16GB内存的机器上安装Kubernetes&#xff08;K8s&#xff09;集群涉及到几个关键步骤。我们将一个机器设为主节点&#xff08;Master&#xff09;和两个工作节点&#xff08;Worker&#xff09;。以下是详细步骤&#xff1a; 1. 系统环境准备&#xff08;在所有机…

企业如何做好合规管理?

近年来“合规”作为一个热点话题&#xff0c;频繁出现在公众视野&#xff0c;已然成为企业管理发展的大趋势。国家相继出台的各项合规管理标准预示着我国的企业合规管理正逐步从头部央企向民营企业扩展。因此&#xff0c;各大企业将合规管理作为了企业管理的首要任务。 随着中…

Mysql 行转列,把逗号分隔的字段拆分成多行

目录 效果如下源数据变更后的数据 方法第一种示例SQL和业务结合在一起使用 第二种示例SQL和业务结合在一起使用 结论 效果如下 源数据 变更后的数据 方法 第一种 先执行下面的SQL&#xff0c;看不看能不能执行&#xff0c;如果有结果&#xff0c;代表数据库版本是可以的&…

C语言:写一个函数,输入一个十六进制数,输出相应的十进制数

分析&#xff1a; 当用户运行该程序时&#xff0c;程序会提示用户输入一个十六进制数。用户需要在命令行中输入一个有效的十六进制数&#xff0c;例如&#xff1a;"1A3F"。 接下来&#xff0c;程序调用了名为 xbed 的函数&#xff0c;并将用户输入的十六进制数作…

_WorldSpaceLightPos0的含义 UNITY SHADER

_WorldSpaceLightPos0 为当前平行光的方向&#xff0c;方向是从光源到照射的方向。 因此&#xff0c;如果要算发现和平行光之间的夹角&#xff0c; 则需要首先将归一化的_WorldSpaceLightPos0去负数。这样才能继续去计算。 也就是&#xff1a; fixed3 reflectdirnormalize…

php获取时间和MongoDB保存时间不一致

最近遇到了问题&#xff0c;php获取的时间和在MongoDB中查看的时间差了8小时&#xff0c;原因是&#xff1a; PHP 与 MongoDB 的默认时区设置不同&#xff1a; PHP 默认可能使用服务器的本地时区&#xff0c;或者是在 PHP 配置文件&#xff08;php.ini&#xff09;中设置的时…

激光SLAM:Faster-Lio 算法编译与测试

激光SLAM&#xff1a;Faster-Lio 算法编译与测试 前言编译测试离线测试在线测试 前言 Faster-LIO是基于FastLIO2开发的。FastLIO2是开源LIO中比较优秀的一个&#xff0c;前端用了增量的kdtree&#xff08;ikd-tree&#xff09;&#xff0c;后端用了迭代ESKF&#xff08;IEKF&a…

VS2022 配置Qt编译环境 | winows安装Qt5.14.2 | VS2017和Qt5配置成功指南

Visual Studio 2022安装教程完文本内容较多,请耐心看完,挺有收获的,要自己多尝试哦。 文章目录 # 插件安装 如果你想用VS2022来创建QT项目,那么你首先要学会下面的操作,创建一个空白解决方案,在扩展搜索qt,并且下载两个插件(带有绿√的就是)。这里其实是一个坑:VS20…

H5 实现麦克风

要在 HTML5 中使用麦克风&#xff0c;可以使用 Web Audio API 和 getUserMedia() 方法。以下是一个简单的示例&#xff1a; <!DOCTYPE html> <html> <head><meta charset"UTF-8"><title>使用麦克风</title> </head> <…

智慧校园:打造未来教育新时代

智慧校园&#xff1a;打造未来教育新时代 智慧校园是指利用先进的信息技术手段&#xff0c;通过云计算、大数据分析、人工智能等技术来提升教育教学质量和管理效率的一种模式。随着科技的不断发展&#xff0c;智慧校园正成为教育领域的热门话题。本文将深入探讨智慧校园的定义、…

leetCode 90.子集 II + 回溯算法 + 图解 + 笔记

给你一个整数数组 nums &#xff0c;其中可能包含重复元素&#xff0c;请你返回该数组所有可能的子集&#xff08;幂集&#xff09;。 解集 不能 包含重复的子集。返回的解集中&#xff0c;子集可以按 任意顺序 排列 示例 1&#xff1a; 输入&#xff1a;nums [1,2,2] 输出…

如何优雅的进行业务分层

1.什么是应用分层 说起应用分层&#xff0c;大部分人都会认为这个不是很简单嘛 就controller&#xff0c;service, mapper三层。 看起来简单&#xff0c;很多人其实并没有把他们职责划分开&#xff0c;在很多代码中&#xff0c;controller做的逻辑比service还多,service往往当…