代码之家  ›  专栏  ›  技术社区  ›  EagleOne

SELinux:命令输出打印在串行上,但不打印在ssh上

  •  0
  • EagleOne  · 技术社区  · 4 年前

    我正在尝试在Poky Linux发行版上配置SELinux。

    我正在通过串行和ssh连接到主板。

    在ssh上启动ping和ifconfig时,板不会打印任何内容,而串行上的相同命令正在打印正确的命令。

    起初,ping被完全禁用,所以我不得不修补netutils-SELinux策略(现在可以正常工作)。

    命令 journalctl -xe | grep "denied" 对ping和ifconfig都不显示“拒绝”。

    如何解决此问题?或者我应该往哪里看?可能是/dev/pts错误?

    0 回复  |  直到 4 年前
        1
  •  0
  •   EagleOne    4 年前

    我想我找到了一些东西。

    之后

    semodule --disable_dontaudit --build
    

    如所述 here ,

    然后

    ~# journalctl -xe | grep "denied" | grep "ping"
    Aug 04 13:04:42  audit[2510]: AVC avc:  denied  { use } for  pid=2510 comm="ping" path="/dev/pts/0" dev="devpts" ino=3 scontext=root:sysadm_r:ping_t:s0 tcontext=system_u:system_r:init_t:s0-s15:c0.c1023 tclass=fd                                                                                                                      permissive=0
    Aug 04 13:04:42 audit[2510]: AVC avc:  denied  { use } for  pid=2510 comm="ping" path="/dev/pts/0" dev="devpts" ino=3 scontext=root:sysadm_r:ping_t:s0 tcontext=system_u:system_r:init_t:s0-s15:c0.c1023 tclass=fd                                                                                                                      permissive=0
    Aug 04 13:04:42  audit[2510]: AVC avc:  denied  { use } for  pid=2510 comm="ping" path="/dev/pts/0" dev="devpts" ino=3 scontext=root:sysadm_r:ping_t:s0 tcontext=system_u:system_r:init_t:s0-s15:c0.c1023 tclass=fd                                                                                                                      permissive=0
    Aug 04 13:04:42  audit[2510]: AVC avc:  denied  { rlimitinh } for  pid=2510 comm="ping" scontext=root:sysadm_r:sysadm_t:s0 tcontext=root:sysadm_r:ping_t:s0 tclass=process permissive=0
    Aug 04 13:04:42 audit[2510]: AVC avc:  denied  { siginh } for  pid=2510 comm="ping" scontext=root:sysadm_r:sysadm_t:s0 tcontext=root:sysadm_r:ping_t:s0 tclass=process permissive=0
    Aug 04 13:04:42  audit[2510]: AVC avc:  denied  { noatsecure } for  pid=2510 comm="ping" scontext=root:sysadm_r:sysadm_t:s0 tcontext=root:sysadm_r:ping_t:s0 tclass=process permissive=0
    Aug 04 13:04:49  audit[2511]: AVC avc:  denied  { use } for  pid=2511 comm="ping" path="/dev/pts/0" dev="devpts" ino=3 scontext=root:sysadm_r:ping_t:s0 tcontext=system_u:system_r:init_t:s0-s15:c0.c1023 tclass=fd                                                                                                                      permissive=0
    Aug 04 13:04:49  audit[2511]: AVC avc:  denied  { use } for  pid=2511 comm="ping" path="/dev/pts/0"dev="devpts" ino=3 scontext=root:sysadm_r:ping_t:s0 tcontext=system_u:system_r:init_t:s0-s15:c0.c1023 tclass=fd                                                                                                                      permissive=0
    Aug 04 13:04:49  audit[2511]: AVC avc:  denied  { use } for  pid=2511 comm="ping" path="/dev/pts/0" dev="devpts" ino=3 scontext=root:sysadm_r:ping_t:s0 tcontext=system_u:system_r:init_t:s0-s15:c0.c1023 tclass=fd                                                                                                                      permissive=0
    Aug 04 13:04:49  audit[2511]: AVC avc:  denied  { rlimitinh } for  pid=2511 comm="ping" scontext=root:sysadm_r:sysadm_t:s0 tcontext=root:sysadm_r:ping_t:s0 tclass=process permissive=0
    Aug 04 13:04:49  audit[2511]: AVC avc:  denied  { siginh } for  pid=2511 comm="ping" scontext=root:sysadm_r:sysadm_t:s0 tcontext=root:sysadm_r:ping_t:s0 tclass=process permissive=0
    Aug 04 13:04:49  audit[2511]: AVC avc:  denied  { noatsecure } for  pid=2511 comm="ping" scontext=root:sysadm_r:sysadm_t:s0 tcontext=root:sysadm_r:ping_t:s0 tclass=process permissive=0
    

    ~# cat /var/audit/audit.log | audit2allow -m fix_ping_ifconfig.te
    

    必须添加的行是

    policy/modules/admin/netutils.te
    
    +allow ping_t devpts_t:chr_file { getattr ioctl };
    +allow ping_t init_t:fd use;
    
    policy/modules/system/sysnetwork.te
    +allow ifconfig_t devpts_t:chr_file { read write getattr };
    

    所以这是一个 devpts 问题如所想,但解决过程被发现禁用 dountaudit 规则

    推荐文章