我有以下内容
audit.log
type=AVC msg=audit(1484787464.870:381223): avc: denied { execute } for pid=10683 comm="pipe" name="tmp.pl" dev=xvde ino=30503 scontext=unconfined_u:system_r:postfix_pipe_t:s0 tcontext=unconfined_u:object_r:usr_t:s0 tclass=file
type=SYSCALL msg=audit(1484787464.870:381223): arch=c000003e syscall=59 success=no exit=-13 a0=7f12efd23ca0 a1=7f12efd23c60 a2=7f12efd23de0 a3=7ffd0f0802f0 items=0 ppid=10681 pid=10683 auid=0 uid=497 gid=12 euid=497 suid=497 fsuid=497 egid=12 sgid=12 fsgid=12 tty=(none) ses=4439 comm="pipe" exe="/usr/libexec/postfix/pipe" subj=unconfined_u:system_r:postfix_pipe_t:s0 key=(null)
maillog
Jan 19 00:57:45 ip-99-99-99-99 pipe[10685]: fatal: pipe_command: execvp /usr/local/mail-captcha/tmp.pl: Permission denied
Jan 19 00:57:45 ip-99-99-99-99 postfix/pipe[10681]: B559C2026D: to=<[email protected]>, relay=mailcaptcha, delay=2727, delays=2726/0.5/0/0.57, dsn=4.3.0, status=deferred (temporary failure. Command output: pipe: fatal: pipe_command: execvp /usr/local/mail-captcha/tmp.pl: Permission denied )
master.cf
mailcaptcha unix - n n - - pipe
flags=FR user=vmail argv=/usr/bin/perl /usr/local/mail-captcha/tmp.pl ${sender} ${recipient}
# ls -Z tmp.pl
-rwxr-xr-x. vmail vmail unconfined_u:object_r:usr_t:s0 tmp.pl
# postqueue -p
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
B559C2026D 625 Thu Jan 19 00:12:18 [email protected]
(temporary failure. Command output: pipe: fatal: pipe_command: execvp /usr/local/mail-captcha/tmp.pl: Permission denied)
[email protected]
# chcon -t postfix_pipe_t tmp.pl
chcon: failed to change context of `tmp.pl' to `unconfined_u:object_r:postfix_pipe_t:s0': Permission denied
# semanage fcontext -a -t mailcaptcha_t '/usr/local/mail-captcha(/.*)?'
/usr/sbin/semanage: Type mailcaptcha_t is invalid, must be a file or device type
似乎一切都会正常,如果不是因为 SELinux。如何为该文件和项目创建新的安全上下文?我看到了这个 (http://fedoraproject.org/wiki/PackagingDrafts/SELinux#Creating_new_types),但我不理解每一行,而且它所做的似乎远不止创建一个简单的上下文。
CentOS 版本 6.8(最终版)