SELinux refpolicy详解(9)

本文详细解读了SELinuxrefpolicy源码中的build.conf文件,涉及PolicyType、PolicyName、Distribution等构建选项,以及DIRECT_INITRC、SYSTEMD、MONOLITHIC、UBAC等与系统集成和策略构建相关的配置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

三、refpolicy内容详解

上一回讲解了refpolicy源码根目录下的build.conf文件的前一部分内容。本回继续讲解其后一部分。

2. build.conf

文件路径:refpolicy源码根目录/build.conf。

文件内容如下:

########################################
#
# Policy build options
#
 
# Policy version
# By default, checkpolicy will create the highest
# version policy it supports.  Setting this will
# override the version.  This only has an
# effect for monolithic policies.
#OUTPUT_POLICY = 33
 
# Policy Type
# standard, mls, mcs
TYPE = standard
 
# Policy Name
# If set, this will be used as the policy
# name.  Otherwise the policy type will be
# used for the name.
NAME = refpolicy
 
# Distribution
# Some distributions have portions of policy
# for programs or configurations specific to the
# distribution.  Setting this will enable options
# for the distribution.
# redhat, gentoo, debian, suse, and rhel4 are current options.
# Fedora users should enable redhat.
#DISTRO = redhat
 
# Unknown Permissions Handling
# The behavior for handling permissions defined in the
# kernel but missing from the policy.  The permissions
# can either be allowed, denied, or the policy loading
# can be rejected.
# allow, deny, and reject are current options.
UNK_PERMS = deny
 
# Direct admin init
# Setting this will allow sysadm to directly
# run init scripts, instead of requiring run_init.
# This is a build option, as role transitions do
# not work in conditional policy.
DIRECT_INITRC = n
 
# Systemd
# Setting this will configure systemd as the init system.
SYSTEMD = n
 
# Build monolithic policy.  Putting y here
# will build a monolithic policy.
MONOLITHIC = n
 
# User-based access control (UBAC)
# Enable UBAC for role separations.
UBAC = y
 
# Custom build options.  This field enables custom
# build options.  Putting foo here will enable
# build option blocks named foo.  Options should be
# separated by spaces.
CUSTOM_BUILDOPT =
 
# Number of MLS Sensitivities
# The sensitivities will be s0 to s(MLS_SENS-1).
# Dominance will be in increasing numerical order
# with s0 being lowest.
MLS_SENS = 16
 
# Number of MLS Categories
# The categories will be c0 to c(MLS_CATS-1).
MLS_CATS = 1024
 
# Number of MCS Categories
# The categories will be c0 to c(MLS_CATS-1).
MCS_CATS = 1024
 
# Set this to y to only display status messages
# during build.
QUIET = n
 
# Set this to treat warnings as errors.
WERROR = n

策略构建选项:

  • DIRECT_INITRC

直接管理初始化。

设置此选项将允许sysadm直接运行init脚本,而不需要run_init。

这是一个构建选项,因为角色转换在条件策略中不起作用。

README中的讲解:

布尔(类型)。

如果设置(为y),sysadm将被允许直接运行init脚本,而不需要run_init工具。

这是一个构建选项,而不是可调的,因为角色转换在条件策略中不起作用。

此选项控制direct_sysadm_demon策略块。

注:此项在build.conf中默认设置为n。

对应代码片段:

# Direct admin init
# Setting this will allow sysadm to directly
# run init scripts, instead of requiring run_init.
# This is a build option, as role transitions do
# not work in conditional policy.
DIRECT_INITRC = n
  • SYSTEMD

Systemd。

设置此项将把systemd配置为init系统。

README中的讲解:

布尔(类型)。

如果设置,则systemd将被假定为init进程的提供者。

注:此项在build.conf中默认设置为n。

对应代码片段:

# Systemd
# Setting this will configure systemd as the init system.
SYSTEMD = n
  • MONOLITHIC

构建单一整体策略。

把y放在这里将建立一个单一整体的策略。

README中的讲解:

布尔(类型)。

如果设置(为y),则构建一个单一整体策略;否则(为n)构建一个模块化策略。

注:此项在build.conf中默认设置为n。

对应代码片段:

# Build monolithic policy.  Putting y here
# will build a monolithic policy.
MONOLITHIC = n
  • UBAC

基于用户的访问控制(UBAC)。

为角色分离启用UBAC。

README中的讲解:

布尔(类型)。

如果设置,SELinux用户将额外用于近似的角色分离。

注:此项在build.conf中默认设置为y。

 对应代码片段:

# User-based access control (UBAC)
# Enable UBAC for role separations.
UBAC = y
  • CUSTOM_BUILDOPT

自定义生成选项。

此字段启用自定义生成选项。

在此处放置foo将启用名为foo的构建选项块。选项应该用空格分隔。

README中的讲解:

无。

对应代码片段:

# Custom build options.  This field enables custom
# build options.  Putting foo here will enable
# build option blocks named foo.  Options should be
# separated by spaces.
CUSTOM_BUILDOPT =
  • MLS_SENS

MLS敏感度的数量。

灵敏度为s0到s(MLS_SENS-1)。

优势将以数字顺序递增,s0最低。

README中的讲解:

整数(类型)。

设置MLS策略中的敏感度数量。在standard和MCS策略忽略此项。

注:此项在build.conf中默认设置为16。

对应代码片段:

# Number of MLS Sensitivities
# The sensitivities will be s0 to s(MLS_SENS-1).
# Dominance will be in increasing numerical order
# with s0 being lowest.
MLS_SENS = 16
  • MLS_CATS

MLS类别的数量。

类别为c0到c(MLS_CATS-1)。

README中的讲解:

整数(类型)。

设置MLS策略中的类别数。在standard和MCS策略忽略此项。

注:此项在build.conf中默认设置为1024。

对应代码片段:

# Number of MLS Categories
# The categories will be c0 to c(MLS_CATS-1).
MLS_CATS = 1024
  • MCS_CATS

MCS类别的数量。

类别为c0到c(MCS_CATS-1)。

README中的讲解:

整数(类型)。

设置MCS策略中的类别数。在standard和MLS策略中忽略此项。

注:此项在build.conf中默认设置为1024。

对应代码片段:

# Number of MCS Categories
# The categories will be c0 to c(MLS_CATS-1).
MCS_CATS = 1024
  • QUIET

将此值设置为y可在构建期间仅显示状态消息。

README中的讲解:

布尔(类型)。

如果设置,则构建系统将仅显示状态消息和错误消息。此选项对策略没有影响。

注:此项在build.conf中默认设置为n。

对应代码片段:

# Set this to y to only display status messages
# during build.
QUIET = n
  • WERROR

若此项设置,则将警告视为错误。

README中的讲解:

布尔(类型)。

如果设置,则构建系统将把警告视为错误。如果遇到任何警告,则构建将失败。

注:此项在build.conf中默认设置为n。

对应代码片段:

# Set this to treat warnings as errors.
WERROR = n

至此,build.conf文件就全部讲解完了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

蓝天居士

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值