了解 SELinux – Security Context

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 的支援

Comments are closed.

FireStats icon Powered by FireStats