设为首页 收藏本站
查看: 1144|回复: 0

[经验分享] redhat linux 6中setroubleshoot 与 audit 关系

[复制链接]

尚未签到

发表于 2018-5-11 12:35:15 | 显示全部楼层 |阅读模式
  最近在看Linux selinux 对于setroubleshoot与audit不是十分理解。找到如下官方解释
  https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html-single/Security-Enhanced_Linux/index.html#sect-Security-Enhanced_Linux-Working_with_SELinux-Which_Log_File_is_Used
  根据说明,在redhat 6中,retroubleshoot不再作为一个单独的服务,而是分为两个进程,同时,只要在开机加载过程中,如果使用了selinux,安装了retroubleshoot,那么就会自动启动两个进程:seapplet与sedispatch。作用如下:
  sedispatch runs as part of the audit subsystem, and via dbus, sends a message when an AVC denial occurs, which will go straight to setroubleshootd if it is already running, or it will start setroubleshootd if it is not running. seapplet is a tool which runs in the system's toolbar, waiting for dbus messages in setroubleshootd, and will launch the notification bubble, allowing the user to review the denial.
  根据上面所说,做如下测试。
  首先启动selinux,安装setroubleshoot
  然后查看状态
[root@localhost ~]# getenforce

  Enforcing
[root@localhost ~]# service auditd status

  auditd (pid 1222) is running...
  可以看到现在selinux与auditd都是启动状态,打开两个终端,然后分别查看messages与audit.log
  现在要做的实验是使用ftp服务器,说下实验流程。当安装ftp之后,创建新用户,然后在一个客户端登录该用户。正常情况下,当使用正确用户名与密码登录之后,ftp默认登入位置为当前用户的家目录。可是在selinux中有设置,是不允许客户进入家目录,这时登录成功之后,审计就会在日志中写入,而setroubleshoot则会抓去日志,进行分析,然后给用户一个解决方案。下面来验证这个过程
  由于开始时我安装的操作系统是最小化安装。所以需要进行如下操作
[root@localhost ~]# yum -y install vsftpd

[root@localhost ~]# yum -y install setroubleshoot*

[root@localhost ~]# yum -y groupinstall "X Window System"

[root@localhost ~]# yum -y groupinstall "KDE Desktop"

  注意:在上面安装过程中,在安装setroubleshoot之后,使用ps aux | grep seapplet,发现没有此进程不需要担心。seapplest与sedispatch在安装X11与桌面管理器KDE之后重新启动就会出现。个人感觉应该是setroubleshoot必须有桌面支持。OK,继续看。
[root@localhost ~]# ps aux | grep sedispatch | grep -v grep

  root 1236 0.0 0.0 21200 1140 ? S< 11:28 0:00 /usr/sbin/sedispatch
[root@localhost ~]# ps aux | grep seapplet | grep -v grep

  root 2494 0.0 0.3 217800 7208 ? S 12:43 0:00 /usr/bin/seapplet
  步骤一:安装vsftpd 安装步骤略过,安装结束之后直接启动vsftpd,不需要做任何更改
  步骤二:创建新用户 步骤略过
  步骤三:开始监控setroubleshoot日志----messages 与auditd日志-----audit.log,建议使用tailf
  步骤四:在客户端使用ftp登录,输入刚刚建立的用户名与密码,是正确的。
  步骤五:查看是否日志有变动。看如下截图
DSC0000.jpg

  操作之前
DSC0001.jpg

  操作之后,大家可以根据日志信息来进行分析,我用的是KDE桌面
DSC0002.jpg

  大家可以看到,根据信息,明确能够了解出现问题的原因,正常情况下,会桌面上出现一个五角星标志
DSC0003.jpg

  下面大家来看看上面两个日志是否有区别:
  audit.log
  type=AVC msg=audit(1377664273.274:36): avc: denied { search } for pid=2117 comm=&quot;vsftpd&quot; name=&quot;/&quot; dev=dm-2 ino=2 scontext=unconfined_u:system_r:ftpd_t:s0-s0:c0.c1023 tcontext=system_u:object_r:home_root_t:s0 tclass=dir
  type=SYSCALL msg=audit(1377664273.274:36): arch=c000003e syscall=80 success=no exit=-13 a0=7fe0a273afe0 a1=1f4 a2=0 a3=7fffa8c137e0 items=0 ppid=2112 pid=2117 auid=0 uid=0 gid=0 euid=500 suid=500 fsuid=500 egid=500 sgid=500 fsgid=500 tty=(none) ses=1 comm=&quot;vsftpd&quot; exe=&quot;/usr/sbin/vsftpd&quot; subj=unconfined_u:system_r:ftpd_t:s0-s0:c0.c1023 key=(null)
  可以看到 type=AVC标志。而再来看setroubleshoot
  Aug 28 12:39:26 localhost setroubleshoot: SELinux is preventing /usr/sbin/vsftpd from search access on the directory /home. For complete SELinux messages. run sealert -l 30972dbc-350e-4f82-9044-a8ffafd9e31c
  在setroubleshoot中,能够看到前面localhost主机名之后的setroubleshoot,证明是由setroubleshoot来整理写入。根据上面红色字体部分,我们执行一下看看结果
  SELinux is preventing /usr/sbin/vsftpd from search access on the directory /home.
  ***** Plugin catchall_boolean (47.5 confidence) suggests *******************
  If you want to allow ftp servers to login to local users and read/write all files on the system, governed by DAC.
  Then you must tell SELinux about this by enabling the 'allow_ftpd_full_access'boolean.
  Do
  setsebool -P allow_ftpd_full_access 1
  ***** Plugin catchall_boolean (47.5 confidence) suggests *******************
  If you want to allow ftp to read and write files in the user home directories
  Then you must tell SELinux about this by enabling the 'ftp_home_dir'boolean.
  Do
  setsebool -P ftp_home_dir 1
  ***** Plugin catchall (6.38 confidence) suggests ***************************
  If you believe that vsftpd should be allowed search access on the home directory by default.
  Then you should report this as a bug.
  You can generate a local policy module to allow this access.
  Do
  allow this access for now by executing:
  # grep vsftpd /var/log/audit/audit.log | audit2allow -M mypol
  # semodule -i mypol.pp
  相信根据上面的英文说明就应该能够知道该如何做,也会知道出现错误的原因。
  下面继续进行下一个实验,关闭auditd服务
[root@localhost ~]# service auditd stop

  Stopping auditd: [ OK ]
DSC0004.jpg

  接下来我们看看开始提到的setroubleshoot两个进程情况
[root@localhost ~]# ps aux |grep sedispatch | grep -v grep

[root@localhost ~]# ps aux |grep seapplet | grep -v grep

  root 2494 0.0 0.3 217800 7208 ? S 12:43 0:00 /usr/bin/seapplet
  从上面可以看出,随着auditd的停止,sedispatch也停掉。现在有seapplet继续监管。此时在客户端登录ftp查看情况
DSC0005.jpg

  上方日志输出中,可以看出,当auditd停掉,那么审计任务结束,而此时selinux已经开始接管。因为日志后面能够看到另外一个信息标志avc,只是现在无法定论此时日志究竟由何种工具进行监控
  上述实验得到如下信息:
  setroubleshoot在redhat 6之后,确实已经不再作为一种服务来进行安装,而是默认直接嵌入至kernel,两进程如下:seapplet与sedispatch。而seapplet是与selinux进行通讯,sedispatch则是因为auditd服务而启动。
  日志得到过程中,首先由kernel运行应用程序,当有错误时,报出,此时由audit拿到,然后写入audit.log,这时setroubleshoot在audit中得到日志,进行分析,然后给出解决方法。
  但是在最后,当把auditd服务停掉之后,依旧能够得到错误信息。根据官方解释,此时应该是由selinux得到报出。可是此时setroubleshoot却无任何提示。此处希望有人能够指点。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-458701-1-1.html 上篇帖子: Redhat Linux 5.4 yum 源安装 下篇帖子: redhat/centos使用service控制启动与关闭
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表