SELinux refpolicy详解(8)

本文详细解读了SELinuxrefpolicy源码中的build.conf文件,介绍了其中包含的策略版本、类型、名称、发布版选项、未知权限处理等关键构建选项及其作用。

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

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

三、refpolicy内容详解

上一回(上几回)讲解完了refpolicy源码根目录下的README文件。本回继续讲解源码根目录下的其它文件。第二个来讲解在README文件中提到的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

build.conf文件比README文件短多了,只有85行,其中包括了很多选项参数。实际上之前在README中专门对于这个文件及其中的参数进行过讲解,参见SELinux refpolicy详解(5)

不过build.conf中对于各个选项也有自己的注释说明,那么我们就将两者对照着来看,权当是复习以加深印象了。

策略构建选项:

  • OUTPUT_POLICY

策略版本。

默认情况下,checkpolicy将创建其支持的最高版本策略。设置此项将覆盖版本。

此项只会对(单一)整体策略产生影响。

README中的讲解:

整数(类型)。

设置在构建单一整体策略时创建的策略的版本。

此选项对模块化策略没有影响。

注:此项在build.conf中默认设置为33,但是被封掉了。

对应代码片段:

# 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
  • TYPE

策略类型。

standard, mls, mcs。

README中的讲解:

字符串(类型)。

可用选项包括standard、mls和mcs。对于只有类型增强(type enforcemeng)的系统,设置为standard。

此选项可选地启用(使能)多级安全(MLS)或多类别安全(MCS)功能特性。此选项控制enable_mls和enable_mcs策略块。

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

对应代码片段:

# Policy Type
# standard, mls, mcs
TYPE = standard
  • NAME

策略名称。

如果设置了此选项,它将用作策略名称;否则,该名称将使用策略类型。

README中的讲解:

字符串(类型)。可选。

设置策略的名字。在将文件安装到诸如/etc/selinux/NAME和/usr/share/selinux/NAME时使用NAME。如果未设置,则使用策略类型(type)。

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

对应代码片段:

# Policy Name
# If set, this will be used as the policy
# name.  Otherwise the policy type will be
# used for the name.
NAME = refpolicy
  • DISTRO

发布版。

某些发行版具有特定于发行版的程序或配置的部分策略。设置此选项将启用发布版的(相应)选项。

redhat、gentoo、debian、suse和rhel4是当前的选项。Fedora用户应该启用redhat。

README中的讲解:

字符串(类型)。可选。

启用特定于发布版的策略。可用的选项有redhat、gentoo和debian。

此选项控制distro_redhat、distro_gentoo和distro_debian构建选项策略块。

注:此项在build.conf中默认设置为default,但是被封掉了。

对应代码片段:

# 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
  • UNK_PERMS

未知权限处理。

处理在内核中定义但策略中缺少的权限的行为。

许可可以是allowed(允许)、denied(拒绝)或the policy loading can be rejected(拒绝策略加载)。

allow、deny和reject是当前的选项。

README中的讲解:

字符串(类型)。

设置内核行为以处理在内核中定义但策略中所缺少的许可。

许可可以是允许(allow)、拒绝(deny),也可以是拒绝加载策略(reject)。

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

对应代码片段:

# 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

下一回中继续解析build.conf中的其它选项。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

蓝天居士

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

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

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

打赏作者

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

抵扣说明:

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

余额充值