Articles of selinux

LogRotate和Apache的SELinux权限

与目录结构: /www/live/website1/app/ /www/live/website1/files/ /www/live/website1/logs/ Apache至less需要以下访问权限: app: read-only access, but read-write is fine (files already chmod 0644) files: read-write access logs: read-write access 通过以下两个规则设置的地方: /usr/sbin/semanage fcontext -a -t httpd_sys_content_t "/www/live/.*/.*"; /usr/sbin/semanage fcontext -a -t httpd_log_t "/www/live/.*/logs(/.*)?"; /sbin/restorecon -vr "/www"; 哪些应用,似乎工作正常…但是LogRotate不开心。 LogRotateconfiguration目前是: /www/live/*/logs/*access_log /www/live/*/logs/*access_log_443 { weekly rotate 52 missingok notifempty nodateext sharedscripts postrotate /usr/sbin/apachectl graceful > /dev/null […]

如何禁用SELinux的Apache httpd只在我的Fedora 14?

通过以下链接,我可以将SELinux完全从Fedora 14中closures。但是我不知道如何才能禁用SELinux,仅用于httpd守护进程? 我没有安装system-config-selinux,并且由于公司防火墙策略,我必须从pkgs.orgsearchRPM才能安装任何软件包。 那么有没有办法把这个问题搞清楚? 编辑: Summary: SELinux is preventing /opt/ibm/cognos/c10/cgi-bin/cognos.cgi "execute" access to /opt/ibm/cognos/c10/cgi-bin/libIBJStreamsDLL.so. Detailed Description: SELinux denied access requested by /opt/ibm/cognos/c10/cgi-bin/cognos.cgi. /opt/ibm/cognos/c10/cgi-bin/cognos.cgi is mislabeled. /opt/ibm/cognos/c10/cgi-bin/cognos.cgi default SELinux type is bin_t, but its current type is bin_t. Changing this file back to the default type, may fix your problem. If you believe this is a […]

如何configurationSELinux以允许特定服务与Avahi进行通信?

我有一个运行在Fedora 20机器上的服务,当它开始尝试向Avahi注册服务时。 如果我的服务是在SELinux处于宽容模式时启动的,但是在SELinux强制执行时服务将不会注册。 我知道SELinux中的httpd_dbus_avahi布尔值。 这完美地允许Apache注册服务,但是我一直无法find关于如何允许其他特定服务与Avahi进行通信的许多信息。 更具体地说,我试图允许tvheadend向Avahi注册其HTSP服务,但我也很好奇如何允许任何特定的服务与Avahi进行通信,而不被SELinux阻止。 我不想closuresSELinux,也不想让进程与Avahi沟通。 编辑:添加所有SELinux和有关tvheadend的服务单位信息 — SELinux的— audit.log消息 在执行semodule -DB并重新启动tvheadend服务之后。 以下是审计日志中显示的所有消息。 最后的消息似乎是问题,但我不知道该怎么做… type=SERVICE_STOP msg=audit(1393282994.012:512): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg=' comm="tvheadend" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success' type=SERVICE_START msg=audit(1393283083.635:513): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg=' comm="tvheadend" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success' type=USER_AVC msg=audit(1393283084.291:514): pid=752 uid=81 auid=4294967295 ses=4294967295 subj=system_u:system_r:system_dbusd_t:s0-s0:c0.c1023 msg='avc: denied { send_msg } […]

CentOS – semanage – 添加自定义端口失败

我最近把我的一个应用服务器升​​级到了CentOS 6(.2),当我可以解决以下问题的时候,它已经准备好用于生产了。 每当我尝试通过semanage的方式添加一个自定义http端口,我不断收到以下错误信息: libsemanage.semanage_exec_prog: Child process /sbin/setfiles did not exit cleanly. libsemanage.semanage_install_active: setfiles returned error code -1. libsemanage.semanage_exec_prog: Child process /sbin/setfiles did not exit cleanly. libsemanage.semanage_install_active: setfiles returned error code -1. /usr/sbin/semanage: Could not commit semanage transaction 我试图运行的命令: semanage port -a -t http_port_t -p tcp 27960 当前内核: 2.6.32-220.4.1.el6.x86_64 #1 SMP Tue Jan 24 02:13:44 GMT […]

Fedora 16:“权限被拒绝:文件权限拒绝服务器访问”

我正在进行一个新的Fedora 16安装,我试图让Apache启动并运行。 我非常熟悉Linux和CentOS,但是我对Fedora和SELinux有很less的经验(不pipe是什么)。 首先,在安装Apache之后,我甚至看不到示例网页。 我做了一些search,并最终通过编辑iptables来解决这个问题。 sudo iptables -I INPUT 1 -p tcp –dport 80 -j ACCEPT sudo iptables-save 我继续前进,并开始删除Web根目录中的一些文件,确保权限设置正确。 $ ls -Rlhp /var/www/html/ /var/www/html/: total 8.0K drwxr-xr-x. 2 apache root 4.0K Apr 20 22:47 files/ /var/www/html/files: total 25M -rw-r–r–. 1 apache users 25M Apr 20 22:47 SRR022918.errors.tar.gz 但是当我导航到相应的URL( my.server.edu/files/SRR022918.errors.tar.gz ),我得到了403权限被拒绝的错误。 我检查了Apache错误日志,发现这个消息。 [Fri Apr 20 23:09:55 […]

setenforce:SELinux被禁用

我在CentOS 5机器上,并尝试安装vsftpd。 我想使用setsebool -P ftp_home_dir on来configurationftp_home_dir setsebool -P ftp_home_dir on但它说: setsebool: SELinux is disabled. 我尝试使用setenforce启用它仍然说: setenforce: SELinux is disabled 然后我试着: semodule -n -B 它说: semodule: SELinux policy is not managed or store cannot be accessed. 我的configuration文件: # This file controls the state of SELinux on the system. # SELINUX= can take one of these three […]

SSH – 1s挂在“进入交互式会话”(不DNS;可能与SELinux相关)

我在CentOS 6.7上遇到了一个问题,那里的SSHlogin比这个networking上的任何非6.7机器(例如7.2,5.11)多一个。 在客户端运行debugging显示“进入交互式会话”挂起。 我正在使用基于此testing的命令是使用SSH密钥从我的笔记本电脑的time ssh <host> true 。 我已经检查/修改的两件事是UseDNS和GSSAPIAuthentication ,并且都被禁用。 我在一个不同的端口上启动了一个单独的守护进程并进行了debugging,并且发现了短暂挂起的位置: debug1: SELinux support enabled debug3: ssh_selinux_setup_exec_context: setting execution context {1s hang} debug3: ssh_selinux_setup_exec_context: done SELinux被设置为“宽容”。 我不知道为什么它会打扰“设置上下文”。 有没有办法让这两个相处得更好,而不是完全禁用SELinux? 我意识到1s并不多,但是我使用这台特定的机器作为一个SSH网关,向拥有IP白名单的主机(这是一个静态的IP机器),并且它在一天中加起来。 运行strace后,挂起更细一些: 22:16:05.445032 open("/selinux/user", O_RDWR|O_LARGEFILE) = 4 <0.000090> 22:16:05.445235 write(4, "unconfined_u:system_r:sshd_t:s0-s0:c0.c1023 unconfined_u", 56) = 56 <0.334742> 22:16:05.780128 read(4, "18\0unconfined_u:system_r:prelink_mask_t:s0-s0:c0.c1023\0unconfined_u:system_r:unconfined_mount_t:s0-s0:c0.c1023\0unconfined_u:system_r:abrt_helper_t:s0-s0:c0.c1023\0unconfined_u:system_r:oddjob_mkhomedir_t:s0-s0:c0.c1023\0unconfined_u:system_r:unconfined_notrans_t:s0-s0:c0.c1023\0unconfined_u:system_r:unconfined_execmem_t:s0-s0:c0.c1023\0unconfined_u:system_r:unconfined_java_t:s0-s0:c0.c1023\0unconfined_u:system_r:unconfined_mono_t:s0-s0:c0.c1023\0unconfined_u:system_r:chkpwd_t:s0-s0:c0.c1023\0unconfined_u:system_r:passwd_t:s0-s0:c0.c1023\0unconfined_u:system_r:updpwd_t:s0-s0:c0.c1023\0unconfined_u:system_r:mount_t:s0-s0:c0.c1023\0unconfined_u:system_r:rssh_t:s0-s0:c0.c1023\0unconfined_u:system_r:xauth_t:s0-s0:c0.c1023\0unconfined_u:system_r:unconfined_t:s0-s0:c0.c1023\0unconfined_u:system_r:openshift_t:s0-s0:c0.c1023\0unconfined_u:unconfined_r:oddjob_mkhomedir_t:s0-s0:c0.c1023\0unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023\0", 4095) = 929 <0.000079> 写入/selinux/user需要350毫秒。 更新1 – 我尝试过的事情 […]

在SELinux中pipe理自定义端口的最佳方式

在RHEL 6.2上,我们使用主机上的httpd作为另一台主机上的Tomcat的前端代理,并且我们还configuration了mod_status,以便在非标准端口上侦听,以向监视工具提供状态信息。 因此,我们需要httpd来1)build立networking连接,2)在非标准端口上侦听。 默认的目标策略(目前处于允许模式)只允许httpd侦听已定义的端口列表( semanage port -l | grep http_port_t ),并且不允许httpd进行出站networking连接。 aureport -a显示httpd试图绑定到自定义状态端口时,以及何时尝试连接到另一个主机上的AJP端口时的AVC拒绝。 我find了两个解决scheme,但一个似乎太宽松了,另一个太脆弱(即在政策升级时可能会中断)。 “广泛”的解决scheme 我使用audit2allow生成本地策略源,然后checkmodule编译它, semodule_package生成一个策略包, semanage开始执行它。 然后我重新启动了httpd,并确认没有生成AVC拒绝。 audit2allow生成的本地策略使用以下授权: 允许httpd_t port_t:tcp_socket {name_bind name_connect}; 它允许httpd绑定到任何端口(不只是在http_port_t中列出的端口),并连接到任何端口。 这种方法的亲是,它包含在本地政策,并不会被覆盖下一个yum update 。 意思是它给予比必要的更广泛的许可; httpd可以绑定并连接到任何端口。 “窄”解决scheme 绑定的替代方法是使用以下命令将我们的自定义端口添加到http_port_t列表中: semanage port -a -t http_port_t -p tcp(自定义端口号) 我知道我可以使用semanage port -l | grep http_port_t查看semanage port -l | grep http_port_t semanage port -l | grep […]

用于php-fpm套接字的SElinux标签

我试图设置php-fpm的多个实例,通过运行在centos 6.5上的apache 2.2来运行多个版本的php。 在未来的某个时候,这将会在一个共享的宿主环境中结束,所以我需要最紧密的安全。 因此,我试图避免完全禁用selinux,并试图尽可能缩小策略。 我对selinux比较新(我们现有的服务器只是禁用了它)。 我在这个话题上做了大量的阅读,但逻辑仍然逃避了我(正如我确信这个问题所表明的那样)。 当调用一个php脚本apache产生这个错误: [Sun May 18 10:46:17 2014] [error] [client 192.168.163.1] (13)Permission denied: FastCGI: failed to connect to server "/fcgi-bin-php5-fpm-i10000_test-1.testtest.org": connect() failed [Sun May 18 10:46:17 2014] [error] [client 192.168.163.1] FastCGI: incomplete headers (0 bytes) received from server "/fcgi-bin-php5-fpm-i10000_test-1.testtest.org" 包含php-fpm套接字的目录如下所示: drwxr-xr-x. root root system_u:object_r:var_run_t:s0 . drwxr-xr-x. root root system_u:object_r:var_run_t:s0 .. […]

如何处理SELinux中的大量用户?

前一阵子,我们开始在我们的Linux服务器上针对Active Directoryvalidation用户身份。 就实际的authentication部分而言,事情是很好的。 然而,其中一个副作用是Linux认为(正确地说)它有几千(〜15-20k)个用户。 我们已经看到好几个与SELinux相关的问题(其中之一是https://serverfault.com/questions/236419/usr-bin-install-hangs-apparently-due-to-selinux )。 其他一些问题包括: dmesg反复报道restorcon被杀人凶手杀死 在某些服务器上启动需要很长时间 – 这发生在内核加载之后,显然是在读取卷组的同时,还会在运行restorecon启动脚本时发生。 yum更新挂起(类似于我的SELinux / GNU“安装”问题关于mmap / munmap) 我们在宽容模式下看到了SELinux的这些问题。 当我们完全禁用SELinux时,它们就会消失。 禁用SELinux是一个选项。 我也在研究如何限制AD使用OU或组来呈现给Linux的用户数量。 但是我的书呆子总是想知道更多。 所以这是一个相当广泛的问题 – 但是任何人都有与大量用户交streamSELinux的build议? 我对SELinux不是特别熟悉 – 但这可能是学习的机会。