selinux m4语言语法

m4宏定义

SELinux使用m4宏语言写可重用的策略规则。m4宏定义提供了易用的操作组合,它本身不属于SELinux策略语言的。m4宏语言的用法可查找m4宏语言用户手册http://cm.bell-labs.com/    7thEdMan/vol2/m4。

下面列出Apache HTTP 宏定义文件$SELINUX_SRC/macros/program/apache_macros.te的前面一些内容:

define(`apache_domain', `         #定义宏apache_domain,后面从符号“`”到“’”是它的定义内容

undefine(`apache_single_user')  #取消宏定义apache_single_user

ifdef(`single_userdomain', `    #如果定义了宏single_userdomain

  ifelse($1, sys, `', `            #如果参数$1为sys,则返回空,否则定义宏apache_single_user

    define(`apache_single_user')

  ')dnl end if                  # dnl表示它之后的字符为注释

')dnl end ifdef single_userdomain

ifdef(`apache_single_user', `                               #如果定义了apache_single_user

typealias $1_home_t alias httpd_$1_content_t;       #定义类型别名

typealias $1_home_t alias httpd_$1_htaccess_t;

typealias $1_home_t alias httpd_$1_script_exec_t;

typealias $1_home_t alias httpd_$1_script_ro_t;

typealias $1_home_t alias httpd_$1_script_rw_t;

typealias $1_home_t alias httpd_$1_script_ra_t;

file_type_auto_trans(httpd_$1_script_t, tmp_t, $1_tmp_t)  #调用类型转换宏

', `

#这是网页的类型

type httpd_$1_content_t, file_type, homedirfile, sysadmfile;

ifelse($1, sys, `          #如果参数$1为sys,则进行类型别名定义

typealias httpd_sys_content_t alias httpd_sysadm_content_t;

')

......                     #省略了其他规则的定义

')

宏定义apache_domain的使用方法如下:

apache_domain(sys)

宏定义apache_domain调用时,其内容中的$1将用sys替换,例如:

type httpd_$1_htaccess_t, file_type, sysadmfile;

上面一行语句将变为下面一行语句:

type httpd_sys_htaccess_t, file_type, sysadmfile;

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值