SELinux and httpd

5月 7th, 2006 Comments Off

SELinux 對 httpd 預設的一些 Types:

httpd_sys_content_t
httpd_sys_script_exec_t
httpd_sys_script_ro_t
httpd_sys_script_rw_t
httpd_sys_script_ra_t
httpd_unconfined_script_exec_t
httpd_user_script_exec_t

跟 httpd 相關的一些 booleans 的設定:

允許執行 cgi:

setsebool -P httpd_enable_cgi 1

允許存取使用者的 $HOME 目錄:

setsebool -P httpd_enable_homedirs 1
chcon -R -t httpd_sys_content_t ~user/public_html

允許存取 the controling terminal

setsebool -P httpd_tty_comm 1

不區分 file controls based on context, 設成 0 時 one httpd service can not interfere with another

setsebool -P httpd_unified 0

關掉 internel scripting (PHP),這樣 php 就無法運作了

setsebool -P httpd_builtin_scripting 0

允許 httpd scripts 連到外面的網路

setsebool -P httpd_can_network_connect 1

停用 suexec transition

setsebool -P httpd_suexec_disable_trans 1

停用 SELinux 對 httpd daemon 的保護

setsebool -P httpd_disable_trans 1

SELinux and named

5月 7th, 2006 Comments Off

我把我手邊的有支援 SELinux 機器的 SELinux enabled 並設成 enforcing
然後卻發現我的 DDNS 更新失效了
因此只好找男人問問看

裡面提到,若你把 SELinux policy for named 啟用的話,那就不需要再使用 chroot 的環境了 (SELinux 比 chroot 更安全)
另外,預設 SElinux policy 不允許 named 寫入任何的 master zone database files,所以 DDNS updates or zone transfers 就會失敗

因此,要讓 DDNS updates or zone transfers 能夠運作,就需要改兩個地方:
1.設定 named_write_master_zones

$ setsebool -P named_write_master_zones 1

2.修改 /etc/sysconfig/named

ENABLE_ZONE_WRITE=yes

這樣改完後,就大功告成了

了解 SELinux – Security Context

5月 7th, 2006 Comments Off

Security Context 的四個 Components

1st Component: Users

三種常見的 Users:
user_u – 使用者登入系統後的預設 SELinux User
system_u – 在開機過程中啟動的程序(processes)的預設 User
root – 使用 root 登入時的 SELinux User
在 targeted policy 中 Users 並不是很重要的,在 MLS 跟 Strict policy 中比較重要
所有預設的 SELinux Users 都以 “_u” 結尾,root 除外
比較新的版本(如 FC5)新增了一個 seusers 的對應檔來對應 Linux Users 到 SELinux Users

2nd Component: Roles

Roles 只有跟 processes(如 /usr/sbin/httpd /usr/sbin/ntpd 等) or domains(如 apache dhcpd mailman 等) 有關
檔案(file)的 roles 通常是 object_r
程序(process)的 roles 通常是 system_r or sysadm_r
Roles 通常用來把 security types 群組化,所以你可以在 policy 中指定哪些 roles 可以執行哪些 types
Roles 是 RBAC(Roles Based Access Control) 的基礎
RBAC 在 targeted policy 中並未使用,但在 MLS 跟 Strict policy 中比較重要
MLS Policy 也包含 sysadm_r, staff_r, and secadm_r
Roles 預設是以 “_r” 結尾

3rd Component: Types

例如 /usr/sbin/httpd 就標示著 “httpd_exec_t” 的 type
這是 SElinux security context 中最重要的欄位
是 SELinux Type Enforcement 的心臟
Types 預設是以 “_t” 結尾

4th Component: MLS Component

MLS 在 FC5 才開始支援,RHEL4 or FC4 還不支援
MLS 欄位可以包含 “:” 語法像這樣 “s0-s15:c1,c2″
SELinux 提供了 libsetrans 來將 s0:c1,c2 轉成如 PatientRecord,CompanyConfidential 給使用者看(setrans.conf)

SELinux Key Componants: Applications

Linux Core Utilities

可使用 -Z option
如:

id -Z
ls -Z
ps -eZ

Find

如:

find /etc -context '*net_conf_t'

mv/cp/install

mv 會保留原來的 context, cp 則不同, install 則會根據 install policy 來設定適當的 file_context

Confined Domains

Red Hat Enterprise Linux 4/Fedora Core 3 Targeted Policy

apache, dhcpd, mailman, mysqld, named, ntpd, pegasus, portmap, postgresql, snmpd, squid, syslogd, winbind

Fedora Core 4 Targeted Policy

acct, amanda, apmd, arpwatch, auditd, bluetooth, checkpolicy, canna, cardmgr, chkpwd, comsat, consoletype, cpucontrol, cpuspeed, cups, cvs, cyrus, dbskkd, dmidecode, dbusd, dhcpc, dictd, dovecot, fingerd, firstboot, fsadm, ftpd, getty, hald, hostname, hotplug, howl, hwclock, kudzu, ifconfig, innd, kerberos, klogd, ktalkd, ldconfig, load_policy, login, lpd, modutil, mta, netutils, networkmanager, passwd, ping, postfix, pppd, privoxy, radius, radvd, restorecon, rlogind, nfs/rpcd, rshd, rsync, rsync, saslauthd, samba, setfiles, slapd, spamd, stunnel, tftpd, udev, updfstab, uucpd, webalizer, ypbind, ypserv, zebra

Red Hat Enterprise Linux 5/ Fedora Core 5 Targeted Policy

Introduction of Reference Policy
Introduction of Multi Level Security Policy
Introduction of Multi Category Security
New Targets: logrotate, loadkeys, bootloader, lvm, vbetool, cron, sendmail, irqbalance, ldap

後記:
我才剛在看 RHEL4 的 SELinux 及 Policy 而已,現在 FC5 用的 SELinux 版本及 Policy 卻又不同了
RHEL4, FC4 等用的都是 Targeted Policy 而 FC5 則增加了 MLS/MCS 的支援

寶貝日記 – Lio 的貓掌

5月 7th, 2006 Comments Off

貓掌
Lio

真好睡
Lio

FireStats icon Powered by FireStats