首页 > 解决方案 > SELinux - 如何调用我的自定义界面?

问题描述

我写了一个包含新类型定义(.te)和接口方法(.if)的新策略:

.te 文件:

policy_module(dummy, 1.0.0)

type dummy_t;

files_type(dummy_t)

.if 文件:

## <summary>
##  Do Bla bla
## </summary>
## <param name="domain">
##  <summary>
##  Domain allowed to read files.
##  </summary>
## </param>

interface(`dummy_int',`
    gen_require(`
        type dummy_t;
      ')

    allow $1 dummy_t:file read;
')

现在我正在编写一个新策略并想调用 dummy_int 宏:

.te 文件:

policy_module(callinterface, 1.0.0)

type callinterface_t;

dummy_int(callinterface_t)

但是 - 编译此策略会生成以下错误:

[root@localhost callinterface]# make -f /usr/share/selinux/devel/Makefile 
Compiling targeted callinterface module
callinterface.te:5:ERROR 'syntax error' at token 'dummy_int' on line 3329:

dummy_int(callinterface_t)
/usr/bin/checkmodule:  error(s) encountered while parsing configuration
make: *** [/usr/share/selinux/devel/include/Makefile:157: tmp/callinterface.mod] Error 1

“虚拟”策略已正确编译和安装。

我究竟做错了什么?如何让编译器知道这个宏?

我尝试使用 ifndef 语句包装宏实现,如下所述: fedoraproject.org/wiki/SELinux/IndependentPolicy

向后兼容性部分下 - 没有变化。

谢谢

标签: linuxlinux-kernelselinuxlibselinuxlinux-security-module

解决方案


知道了。接口文件应存储在 /usr/share/selinux/mcs/include/* 或 /usr/share/selinux/devel/include/* 中(取决于 Linux 发行版)。

创建我们自己的界面

当我将 .if 复制到此文件夹中时,该策略已成功编译。


推荐阅读