【问题标题】:SEBool Persistent ValuesSEBool 持久值
【发布时间】:2020-02-07 17:11:01
【问题描述】:

我正在学习如何使用 setseboolgetsebool

我知道我可以通过命令 setsebool 设置 bool 打开和关闭,例如:

setsebool httpd_can_network_connect_db on

我还可以使用以下方法检查当前值:

getsebool httpd_can_network_connect_db

我还可以使用以下方法使更改持久化:

setsebool -P httpd_can_network_connect_db on

我在网上找不到的是:如何检查服务器重新启动后实际加载的当前持久值(当前未应用)?

【问题讨论】:

    标签: linux selinux


    【解决方案1】:

    使用semanage 检查布尔值:

    # semanage boolean -l
    SELinux boolean               State   Default  Description
    ...
    httpd_can_network_connect_db  (off  , off)     Allow httpd to can network connect db
    

    State 列为您提供当前的实时状态。 Default 列为您提供在引导时从策略加载的值:

    # setsebool httpd_can_network_connect_db on
    # getsebool httpd_can_network_connect_db
    httpd_can_network_connect_db on --> on
    # semanage boolean -l | grep httpd_can_network_connect_db
    httpd_can_network_connect_db  (on   ,  off) Allow httpd to can network connect db
    

    当使用 setsebool-P 使布尔更改持久化时,这会更新策略:

    # setsebool -P httpd_can_network_connect_db on
    # semanage boolean -l | grep httpd_can_network_connect_db
    httpd_can_network_connect_db  (on   ,   on) Allow httpd to can network connect db
    

    setsebool的源码可以看出,持久化是使用semanage的API实现的:Reference

    【讨论】:

      猜你喜欢
      • 2019-04-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-20
      • 1970-01-01
      • 1970-01-01
      • 2017-01-15
      • 2020-12-05
      相关资源
      最近更新 更多