SELinux-Booleans(布尔值)参数详解与案例演示

开发人员编写SELinux目标策略来定义目标应用程序允许的行为

开发人员可以在SELinux策略中包含可选的应用程序行为当特定系统允许该行为时,可以启用该策略。

SELinux布尔值 用来 启用或禁用SELinux策略的可选行为

常用有关命令:getsebool、setsebool、semanage。

getsebool:查询SElinux策略内各项规则的布尔值

使用方法

getsebool -a :展示所以SElinux布尔值

[student@workstation ~]$ getsebool -a
abrt_anon_write --> off
abrt_handle_event --> off
abrt_upload_watch_anon_write --> on
antivirus_can_scan_system --> off
antivirus_use_jit --> off
auditadm_exec_content --> on
authlogin_nsswitch_use_ldap --> off
authlogin_radius --> off
authlogin_yubikey --> off
awstats_purge_apache_log_files --> off
boinc_execmem --> on
cdrecord_read_content --> off
........
zebra_write_config --> off
zoneminder_anon_write --> off
zoneminder_run_sudo --> off

getsebool 服务策略:展示有服务策略的SE布尔值

例如httpd服务的策略中的【httpd_enable_homedirs】,如果启动,远程用户可以直接访问服务机的http主目录

setsebool:设置SElinux布尔值

是用来修改SElinux策略内各项规则的布尔值。setsebool命令和getsebool命令是SELinux修改和查询布尔值的一套工具组。

setsebool [-P] 布尔值=[0|1]

e.
setsebool -P allow_ftpd_anon_write=1    #允许vsftp匿名用户写入权限
setsebool -P ftp_home_dir 1             #ftp用户可以访问自己的家目录

semanage boolean:管理SElinux布尔值

semanage boolean -l 查看所有

[student@workstation ~]$ semanage boolean -l
ValueError: SELinux policy is not managed or store cannot be accessed.
[student@workstation ~]$ sudo semanage boolean -l
[sudo] password for student: 
SELinux boolean                State  Default Description

abrt_anon_write                (off  ,  off)  Allow abrt to anon write
abrt_handle_event              (off  ,  off)  Allow abrt to handle event
abrt_upload_watch_anon_write   (on   ,   on)  Allow abrt to upload watch anon write
antivirus_can_scan_system      (off  ,  off)  Allow antivirus to can scan system
antivirus_use_jit              (off  ,  off)  Allow antivirus to use jit
auditadm_exec_content          (on   ,   on)  Allow auditadm to exec content
authlogin_nsswitch_use_ldap    (off  ,  off)  Allow authlogin to nsswitch use ldap
authlogin_radius               (off  ,  off)  Allow authlogin to radius
authlogin_yubikey              (off  ,  off)  Allow authlogin to yubikey
awstats_purge_apache_log_files (off  ,  off)  Allow awstats to purge apache log files
boinc_execmem                  (on   ,   on)  Allow boinc to execmem
cdrecord_read_content          (off  ,  off)  Allow cdrecord to read content
cluster_can_network_connect    (off  ,  off)  Allow cluster to can network connect
cluster_manage_all_files       (off  ,  off)  Allow cluster to manage all files

semanage boolean -l -C 查看与缺省值不同的(改过的)

[student@workstation ~]$ sudo semanage boolean -l -C
SELinux boolean              State Default Description

httpd_enable_homedirs        (on    ,    on)    Allow httpd to enable homedirs

http服务案例

1.在服务器a启动httpd服务

systemctl enable --now httpd

2.检查httpd_enable_homedirs布尔值

[student@workstation ~]$ getsebool -a | grep home
...
httpd_enable_homedirs --> off
...

3.其他主机访问服务器a主目录:由于权限问题会访问失败

4.设置selinux的httpd_enable_homedirs布尔值为on

[root@servera ~]# setsebool -P httpd_enable_homedirs on
[root@servera ~]# getsebool httpd_enable_homedirs 
httpd_enable_homedirs --> on

5.再次尝试

  • 7
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: selinux-utils是一个开源软件包,提供了与SELinux(安全增强型Linux)相关的工具和库。 要找到selinux-utils源码,你可以遵循以下步骤: 1. 打开任何一个网页浏览器,进入一个搜索引擎,如Google、Baidu、Github等。 2. 在搜索引擎的搜索框中键入"selinux-utils源码"或"selinux-utils GitHub"。这将让搜索引擎帮你找到与selinux-utils相关的资源。 3. 在搜索结果中,通常会有指向源码存储库的链接。点击其中一个链接,比如Github的链接。 4. 进入源码存储库后,你可以找到selinux-utils的源代码文件。它们通常以.c或.cpp为扩展名。 5. 在源码存储库中,你还可以找到其他与selinux-utils相关的信息,如文档、问题跟踪和讨论。 请注意,selinux-utils源码可能在不同的代码托管平台(如GitHub、GitLab等)或者开发者的个人网站上。确保选择了可信的源,并使用适当的下载方式获取源码。 ### 回答2: selinux-utils 是一个用于管理 SELinux 的工具集,包含了一些常用的 SELinux 相关工具和库文件。 selinux-utils 的源代码可以在 SELinux 官方的代码库中找到。你可以通过以下方式获取 selinux-utils 的源码: 1. 从官方源获取:访问 SELinux 项目的官方网站(https://github.com/SELinuxProject/selinux-utils)。在该页面中,你可以找到 selinux-utils 的源码仓库链接。你可以使用 git 命令克隆整个仓库到本地,以获取 selinux-utils 的完整源码。 2. 使用包管理器获取:如果你在使用 Linux 发行版,你可以尝试使用包管理器来获取 selinux-utils 的源码。不同的发行版可能有不同的包管理器,可以通过在终端中运行适当的命令来查找 selinux-utils 的包,并使用包管理器获取其源码。 请注意,获取源码需要一定的技术知识和经验。如果你只是想使用 selinux-utils,而不是为了开发或修改它,你可以直接通过软件包管理器安装预编译的二进制文件,而无需获取或编译源码。 ### 回答3: selinux-utils 源码是 Security Enhanced Linux (SELinux) 的一部分,它包含了对 SELinux 系统的管理工具。在大部分标准的 Linux 发行版中,selinux-utils 源码通常是通过源代码包(source package)的形式提供的。在一般的 Linux 系统中,你可以通过以下步骤来获取 selinux-utils 源码: 1. 打开终端,以 root 用户或拥有管理员权限的用户身份登录。 2. 使用适用于你所使用的 Linux 发行版的包管理器,比如 apt、yum、dnf、zypper、pacman 等,执行以下命令: - 对于 Ubuntu 或 Debian 系统:sudo apt-get source selinux-utils - 对于 CentOS 或 Fedora 系统:sudo dnf download --source selinux-utils 或 sudo yumdownloader --source selinux-utils - 对于 openSUSE 系统:sudo zypper source-install selinux-utils - 对于 Arch Linux 系统:使用 AUR 或者自定义 PKGBUILD 构建 3. 上述命令将会下载 selinux-utils 源代码压缩包,并解压到当前目录中。 注意:具体的命令和过程可能会因你所使用的 Linux 发行版和版本而有所不同,上述命令只是提供了一些常见的示例。你也可以在 SELinux 官方网站(https://github.com/SELinuxProject/selinux-utils)上找到最新版本的 selinux-utils 源码,并根据官方文档提供的指引进行下载和编译。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值