SELinux

NSA(膠喝遵遵九篆絮)冴Linux祉ャc筝冴≦宍罘(祉ャOS絎茖罘)
Linux篁Distributionс≪吾ャ若с

荵冴荐絎後莇腟狗hВс祉Linux茹h泣ゃх≦鴻ィ絅障c

ョ膂≧荐絎若сSELinux Policy Editor(seedit)膈緇篏帥医翫

SELinux Policy Editor綣泣ゃ

SELinux篁ュ篁h;祉ャOS篁ヤ絎茖絖

  • AppArmor
  • TOMOYO Linux
  • LIDS

2010綛11憜kernel若吾SELinuxAppArmor帥

SELinux激

SELinuxс狗ウ綽茲違激若障

  • strict(罔羣)
    • 若吟若祉鴻篏ウ若膊∞篋荐怨篏腟吟
  • targeted(strict狗膩)
    • Webmail膈綣掩с絖醇с蕭泣若鴻若≪潟狗篁ュ狗
  • mls(strictウ荵篋)
    • strict荀綺綽絮ゆ狗菴遵

罔羣с激若у篏Distribution違с
憜激若у篏腆肴翫sestatus潟潟х∈茯с障

<帥mls≪祉篋冴障с祉ャc筝荀障
翫若違ゃ潟с倶ャ醇с障с篆<<鴻冴鴻♂cс

SELinux篏≪若

SELinux篏≪若篁ヤ3帥若潟絖障

  • enforcing
  • permissive
  • disabled

enforcing絎SELinux狗茵倶
permissiveSELinux篏絎狗茵篏違阪倶
disabledSELinux≦鴻倶

enforcing篁ュ≪若с篏狗茵сpermissive≪若т絎篏違
冴ャ激若篏enforcing≪若帥絎紮c羌障

医阪auditd綽荀障сSELinux篏睡篋絎auditd莎桁鴻莎桁

# /etc/init.d/auditd start
# chkconfig auditd on

絎篏睡号

篁ヤCentOS 5.5с荅宴с

SELinux鴻

# setenforce 1

私荐潟潟篏≪若筝紊眼с羂悟紊眼翫篁ヤ<ゃ膩障

  • /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - SELinux is fully disabled.
SELINUX=permissive

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - SELinux is fully disabled.
SELINUX=enforcing   # 紊

SELinux≦(permissive≪若)

# setenforce 0

私荐潟潟篏≪若筝紊眼с羂悟紊眼翫篁ヤ<ゃ膩障

  • /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - SELinux is fully disabled.
SELINUX=enforcing

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - SELinux is fully disabled.
SELINUX=permissive  # 紊

SELinux絎≦鴻翫SELinux=disabled

<ゃc荐絎祉ャc潟潟鴻茵腓冴

# ls -Z <祉ャc潟潟鴻茵腓冴<ゃ/c>
  • 絎茵箴
# ls -Z /var/log/messages

-rw-------  root root system_u:object_r:var_log_t:s0   /var/log/messages

<ゃ荐絎祉ャc潟潟鴻筝荀с茵腓冴

# semanage fcontext -l
  • 絎茵箴
# semanage fcontext -l

SELinux fcontext                                   type               Context

/.*                                                       all files               system_u:object_r:default_t:s0 
/xen(/.*)?                                            all files               system_u:object_r:xen_image_t:s0 
/mnt(/[^/]*)                                        symbolic link     system_u:object_r:mnt_t:s0 
/mnt(/[^/]*)?                                      directory            system_u:o
---
激т札筝

祉ャc潟潟鴻荐絎菴遵

# semanage fcontext -a -t <菴遵祉ャc潟潟鴻帥ゃ> '<<ゃ/c(罩h頫憜)>'
  • 絎茵箴
# semanage fcontext -a -t httpd_sys_script_rw_t '/var/www/wiki/(attach|backup|cache|diff|wiki)(/.*)?'

罩e幻腟篋翫脂≪篏茵腓冴

<帥潟潟с絎荐絎с緇菴違restorecon潟潟絎茵綽荀

絎茵箴潟潟

篁ヤc筝apache<ゃ篏/ゃ罔篁筝
障篁緇篏<ゃ絲障apache篏/ゃ罔篁筝

  • /var/www/wiki/attach
  • /var/www/wiki/backup
  • /var/www/wiki/cache
  • /var/www/wiki/diff
  • /var/www/wiki/wiki

荐絎羝帥祉ャc潟潟鴻茯粋昭帥荐絎

# restorecon -RF '<荐絎>'
  • 絎茵箴
# restorecon -RF '/var/www/wiki'

罩e幻腟篋翫脂≪篏茵腓冴

絎茵箴潟潟

/var/www/wiki(c)筝絖<ゃ/c祉ャc潟潟鴻荐絎
激с潟-R篁絽亥荐絎紊眼-F篁綣桁句荐絎紊眼茵

祉ャc潟潟鴻荐絎

# semanage fcontext -d -t <ゃ祉ャc潟潟鴻帥ゃ> '<<ゃ/c(罩h頫憜)>'

罩e幻腟篋翫脂≪篏茵腓冴

紫憜荐絎semanage fcontext -lц;腓冴

booleanゃ筝荀ц;腓

# getsebool -a
  • 絎茵箴
# getsebool -a

NetworkManager_disable_trans --> off
aisexec_disable_trans --> off
allow_console_login --> off
---
激т札筝

booleanゃ
罔羣ц┃絎祉ャc潟潟鴻潟若帥
箴samba若吟若若c≪祉鴻篁ヤ潟潟絎茵域祉ャc潟潟鴻荐絎≪祉劫純
膣違荐絎筝荀т梢遺梢ウ絲荐絎翫

# setsebool -P samba_enable_home_dirs on

booleanゃ荐絎紊

# setsebool -P <紊眼boolean> <on|off>
  • 絎茵箴
# setsebool -P httpd_can_network_connect on

絎茵箴潟潟

apache若腟宴уャ泣ゃ膈若帥緇篏荐怨
(ウ絲荐tcp socket荐怨)
激с潟-P篁翫莎桁緇荐絎祉c障с筝荐怨翫篁ュ篁

SELinux≪祉号違茵腓冴

# ausearch -m AVC

/var/log/audit/audit.log茯粋昭帥SELinux≫違遵冴阪


  膩 腟 綏 ≪ 羞私 茲茖 紊 若   域 筝荀 茯罎膣 腟贋     腟贋違RSS
Last-modified: 2010-12-07 () 02:34:29