【问题标题】:SELinux Policy Creation Error regarding Memory and Context Structure关于内存和上下文结构的 SELinux 策略创建错误
【发布时间】:2019-11-13 18:02:00
【问题描述】:

我正在使用 RHEL 7。我在这里存储了另一台机器的日志文件。 我使用以下命令创建策略:

grep -inr "denied" audit.log* | audit2allow -M Policy_File_Name

使用此命令,我能够为许多日志文件创建策略。但在某些情况下我遇到了这个错误:

Traceback (most recent call last):
  File "/usr/bin/audit2allow", line 365, in <module>
    app.main()
  File "/usr/bin/audit2allow", line 352, in main
    self.__process_input()
  File "/usr/bin/audit2allow", line 180, in __process_input
    self.__avs = self.__parser.to_access()
  File "/usr/lib64/python2.7/site-packages/sepolgen/audit.py", line 591, in to_access
    avc.path = self.__restore_path(avc.name, avc.ino)
  File "/usr/lib64/python2.7/site-packages/sepolgen/audit.py", line 531, in __restore_path
    universal_newlines=True)
  File "/usr/lib64/python2.7/subprocess.py", line 568, in check_output
    process = Popen(stdout=PIPE, *popenargs, **kwargs)
  File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/usr/lib64/python2.7/subprocess.py", line 1224, in _execute_child
    self.pid = os.fork()
OSError: [Errno 12] Cannot allocate memory

我很少遇到这个错误:

libsepol.context_from_record: type celery_t is not defined
libsepol.context_from_record: could not create context structure
libsepol.context_from_string: could not create context structure
libsepol.sepol_context_to_sid: could not convert system_u:system_r:celery_t:s0 to sid

这里的 'celery_t' 会根据目标上下文发生变化。

系统状况:

[root@selinux-policy-creation abhisheklog]# free -h
           total       used        free      shared  buff/cache   available
 Mem:      31G         261M        27G        8.4M        3.1G         30GB
 Swap:      0B          0B          0B

请提供原因和解决方法。谢谢。

【问题讨论】:

  • 你在这里运行的是直接的 python 脚本或一些网络服务器?
  • @TarunLalwani 我在审计日志文件的位置使用提到的命令。另一个系统的日志存储在我的系统中。这里没有python或web服务器的作用。

标签: memory operating-system redhat policy selinux


【解决方案1】:

此类错误消息意味着文件系统中存在无效的 SE 模块,这些模块可能是以前的错误卸载脚本遗留下来的。手动删除这些文件通常会摆脱这些错误消息;但在这种情况下,它似乎是相反的。虽然存在这样的孤立 SE 模块,但这可能会导致虚假错误消息 - 因此我什至不太确定“无法分配内存”消息。有感觉,这可能与python2-celery 有关(celery_t 类型似乎来自哪里)。问题是 celery_t 类型进入了审计日志,但运行 audit2allow 的机器不知道。

python2-celery-4.2.1-3.el7.noarch : Distributed Task Queue
Repo        : epel
Matched from:
Filename    : /usr/bin/celery

首先要尝试的可能是:

sudo yum install python2-celery

这可能会恢复丢失的类型celery_t。我的意思是,如果这个日志文件来自另一台机器,这台机器可能安装了python2-celery - 而运行audit2allow 的机器可能根本没有它。希望这是有道理的。

【讨论】:

  • 是的,就是这样。但是现在,我手动制作了策略“.te”文件并将它们编译为“.pp”。感谢您的回答
猜你喜欢
  • 2015-07-14
  • 2020-03-16
  • 1970-01-01
  • 1970-01-01
  • 2013-04-19
  • 1970-01-01
  • 2019-09-14
  • 2014-12-03
  • 2016-05-31
相关资源
最近更新 更多