|
½´ÆÛÀ¯Àú ÄÚ¸®¾Æ¿¡¼ ÆÛ¿Ô½À´Ï´Ù. SELinux °¢Á¾ ¸®´ª½º°ü·Ã Æ®·¯ºí½´ÆÃÀ» ó¸®ÇÏ´Ùº¸¸é °øºÎÇØ¾ßÇҰ͵éÀÌ Âü ¸¹´Ù. ¿äÁò ÀÚÁÖ °Å·ÐµÇ´Â ¹®Á¦°¡ SELinux °ü·ÃµÈ ¹®Á¦µéÀε¥, SELinux ¶ó¸é ¾ÆÁ÷ ¸øµé¾îº» »ç¶÷ÀÌ ²Ï ¸¹ÀÌ ÀÖÀ»°ÍÀÌ´Ù. SELinuxÀÇ ³»ºÎÀûÀÎ ±¸Çö¿ø¸® °°Àº ºÎºÐÀº ÀÌ ¹®¼¿¡ ´Ù·ç°íÀÚ ÇÏ´Â ³»¿ëÀÌ ¾Æ´Ï´Ù. SELinuxÀÇ ¾ÆÅ°ÅØÃ³³ª Äڵ忡 ´ëÇÑ ºÎºÐÀ» ´õ ¸¹ÀÌ ¾Ë±âÀ§Çؼ´Â IBMÀÇ ±â¼ú¹®¼(http://www-128.ibm.com/developerworks/kr/library/l-selinux/index.html) À» Âü°íÇϰųª NSAÀÇ È¨ÆäÀÌÁö(http://www.nsa.gov/selinux/)µî¸¦ Âü°íÇϱ⠹ٶõ´Ù. ÇÊÀÚ´Â ´ÜÁö ¿©·¯ºÐÀÌ ½Ã½ºÅÛÀ» °ü¸®ÇÏ¸é¼ »õ·Ó°Ô ¸¸³ª°ÔµÇ´Â SELinux¿¡ °ü·ÃµÈ ¹®Á¦¸¦ À̹®¼¸¦ ÅëÇØ¼ ÇØ°áÇÒ¼ö Àֱ⸦ ¹Ù¶ö»ÓÀÌ´Ù. ÀÛ¼ºÀÚ : ±èÇüä Â÷·Ê 1. SELInux(Security-Enhanced Linux) ¶õ? 1 2. SELinux Á¤Ã¥À̶õ ¹«¾ùÀΰ¡? 1 3. SELinux ¼³Ä¡¿©ºÎ È®ÀÎ 2 4. SELinux ±âº»¼³Á¤ - /etc/sysconfig/selinux 4 5. SELinux ¼ºñ½º ¼³Á¤ - setenforce 5 6. SELinux ¼ºñ½º ¼³Á¤ - chcon 5 7. SELinux ¼ºñ½º ¼³Á¤ - setsebool 5 8. »ç¿ëÁßÀÎ Á¤Ã¥À» ±³Ã¼ÇÏ´Â ¹æ¹ýÀº? 6 9. SELinux LOG 7 10. Audit2allow 8 11. avc: denied 8 12. Âü°í¹®Çå ¶Ç´Â URL 8 SELinux ¶õ ¹Ì ±¹°¡ º¸¾È±¹ (U.S. National Security Agency)¸® ¿ÀǼҽºÄ¿¹Â´ÏƼ¿¡ ¸±¸®ÁîÇÑ LinuxÀÇ º¸¾È °È ¹öÀü(ÄÚµå Æ÷ÇÔ)À¸·Î¼ ¸®´ª½º º¸¾È ¸ðµâ ±¸Á¶Ã¼(Linux Security Modules(LSM) framework)¸¦ ÀÌ¿ëÇÏ¿© ¸®´ª½º Ä¿³Î¿¡ Àǹ« Á¢±Ù Á¦¾î(Mandatory Access Control - MAC)¸¦ ±¸ÇöÇÏ´Â °ÍÀÌ´Ù. Fedora Core3ºÎÅÍ ±âº»À¸·Î Àû¿ëµÇ±â ½ÃÀÛÇÏ¿´°í, ÇöÀç ´ëºÎºÐÀÇ ÃֽЏ®´ª½º ¹èÆ÷ÆÇ¿¡¼ Áö¿øµÇ°íÀÖ´Ù. SELinux¿¡ ´ëÇÑ ÀÌÇØ¸¦ µ½±âÀ§Çؼ DAC, MAC¸¦ Àá±ñ À̾߱â ÇØº¸ÀÚ. Ç¥ÁØ ¸®´ª½º º¸¾ÈÀº Discretionary Access Control - DAC ¸ðµ¨À» µû¸¥´Ù. DAC ¸ðµ¨¿¡¼, ÆÄÀϰú ÀÚ¿ø¿¡ ´ëÇÑ °áÁ¤±ÇÀº ¿ÀÁ÷ ÇØ´ç °´Ã¼(objects)ÀÇ »ç¿ëÀÚ(user id)¿¡°Ô ÀÖ°í ¼ÒÀ¯±Ç(ownership)¿¡ µû¶ó ÀÌ·ïÁø´Ù. °¢ »ç¿ëÀÚ¿Í ±× »ç¿ëÀÚ¿¡ ÀÇÇØ ½ÇÇàµÈ ÇÁ·Î±×·¥Àº Àڱ⿡°Ô ÇÒ´çµÈ °´Ã¼¿¡ ´ëÇØ ÀüÀûÀ¸·Î ÀÚÀ¯Àç·®±ÇÀ» °®´Â´Ù. ÀÌ·¯ÇÑ »óȲ¿¡¼´Â, ¾ÇÀÇ ÀÖ´Â ÀÏ¹Ý È¤Àº ·çÆ® »ç¿ëÀÚ(¿¹·Î, setuid¿Í setgid)°¡ ½ÇÇà½ÃŲ °áÇÔÀÌ ÀÖ´Â ¼ÒÇÁÆ®¿þ¾î¸¦ ÅëÇØ ÁÖ¾îÁø °´Ã¼·Î ¿øÇÏ´Â ¾î¶°ÇÑ ÀÏÀ» ÇØµµ ¸·¾Æ³¾ ¹æ¹ýÀÌ ¾øÀ¸¸ç º¸¾È Á¤Ã¥À» ½Ã½ºÅÛ Àüü¿¡ °ÉÃÄ ½ÃÇàµÇµµ·Ï ÇÒ ¹æ¹ýÀÌ ¾ø´Ù. ¹Ý¸é¿¡ SELinuxÇÏ¿¡¼ MAC´Â ¸ðµç ÁÖü(subjects - »ç¿ëÀÚ, ÇÁ·Î±×·¥, ÇÁ·Î¼¼½º)¿Í °´Ã¼(ÆÄÀÏ, µð¹ÙÀ̽º)¿¡ ´ëÇØ¼ ±¹ºÎÀûÀ¸·Î Çã°¡(granular permissions)ÇØ ÁÙ ¼ö ÀÖ´Ù. ÀÀ¿ëÇÁ·Î±×·¥¿¡¼ ºÒÇÊ¿äÇÑ ºÎºÐÀº Á¦¿ÜÇÏ°í ¿ÀÁ÷ ÇÊ¿äÇÑ ±â´É¿¡ ´ëÇØ¼¸¸ »ç¿ë ±ÇÇÑÀ» ¾ÈÀüÇÏ°Ô ºÎ¿©Çϴ°ÍÀÌ °¡´ÉÇÏ´Ù. SELinux´Â ¸ðµç ÁÖü (»ç¿ëÀÚ, ÇÁ·Î±×·¥, ÇÁ·Î¼¼½º) ¹× °´Ã¼ (ÆÄÀϰú ÀåÄ¡)¿¡ °¢°¢ ´Ù¸¥ ±ÇÇÑÀ» ºÎ¿©ÇÒ ¼ö ÀÖ°Ô ÇØÁÝ´Ï´Ù. µû¶ó¼ »ç¿ëÀÚ´Â ÇÑ ÀÀ¿ë ÇÁ·Î±×·¥¿¡°Ô ±× ÇÁ·Î±×·¥ÀÌ Á¦´ë·Î ÀÛµ¿Çϴµ¥ ÇÊ¿äÇÑ ±ÇÇѸ¸ ¾ÈÀüÇÏ°Ô ºÎ¿©ÇÒ ¼ö ÀÖ´Ù. SELinux Á¤Ã¥Àº »ç¿ëÀÚ, ÇÁ·Î±×·¥, ÇÁ·Î¼¼½º ±×¸®°í À̵éÀÇ µ¿ÀÛ ´ë»óÀÎ ÆÄÀϰú µð¹ÙÀ̽º¸¦ Æ÷ÇÔÇÑ ½Ã½ºÅÛ Àüü, Áï, ¸ðµç ÁÖü¿Í °´Ã¼¿¡ ´ëÇÑ Á¢±Ù Çã°¡(access permissions)¸¦ Æ÷ÇÔÇÑ ÆÐŰÁö¸¦ À̾߱âÇÑ´Ù. Æäµµ¶ó¿¡¼ »ç¿ë°¡´ÉÇÑ Á¤Ã¥ ÆÐŰÁö´Â strict , targeted µÎ°¡Áö°¡ ÀÖ´Ù. Æäµµ¶óÄھ¼ SELinux Á¤Ã¥À¸·Î strict policy ¸¦ Àû¿ëÇÔÀ¸·Î ÀÎÇØ¼ ´Ù¾çÇÑ »ç¿ëÀÚµéÀÌ ¸¹Àº ¹®Á¦Á¡À» ÀÏÀ¸Å´À¸·Î ÀÎÇØ¼(ÀϹݻç¿ëÀÚµéÀÌ SELinux¸¦ »ç¿ëÇϱâ À§Çؼ´Â ¼öÁسôÀº Àü¹®±â¼úÀÌ ÇÊ¿äÇÏ´Ù) ÇöÀç RHEL4 ¿¡¼´Â º¸´Ù ¿ÏÈµÈ Á¤Ã¥ÆÐŰÁö targeted poicy °¡ ¼³Ä¡½Ã ±âº»À¸·Î Á¦°øµÈ´Ù. targeted policy´Â ÀÚÁÖ ¹®Á¦½ÃµÇ´Â ºÎºÐµé¸¸ ¿ì¼±ÀûÀ¸·Î Àû¿ë½Ã۰í, ³ª¸ÓÁö´Â Ç¥ÁØ ¸®´ª½º º¸¾È°ú µ¿ÀÏÇÏ°Ô ¿î¿µµÇµµ·Ï Àû¿ëÇÑ Á¤Ã¥ÀÌ´Ù. ÇöÀç, targeted policy ¿¡¼´Â dhcpd, httpd(apache.te), named, nscd, ntpd, portmap, snmpd, squid ±×¸®°í syslogd µ¥¸ó¿¡ ´ëÇØ¼ °ü¸®ÇÑ´Ù. ÀÌ µ¥¸óµé¿¡ ´ëÇÑ Á¤Ã¥ ÆÄÀÏÀº /etc/selinux/targeted/src/policy/domains/program¿¡¼ ãÀ» ¼ö ÀÖ´Ù. SELinux ¸¦ »ç¿ëÇϰí ÀÖ´ÂÁö¸¦ È®ÀÎÇÏ´Â ¹æ¹ýÀº º¸¾È¹®¸ÆÀ» È®ÀÎÇÏ´Â ¹æ¹ýÀ¸·Î ¾Ë ¼ö ÀÖ´Ù. ÆÄÀÏ, »ç¿ëÀÚ, ÇÁ·Î¼¼½ºµîÀÇ ¹®¸ÆÀ» È®ÀÎÇÒ ¶§´Â -Z ¶ó´Â »õ ¿É¼ÇÀ» ÀÌ¿ëÇØ¼ È®ÀÎÇÒ ¼ö ÀÖ´Ù. ls -lZ /etc/selinux -rw-r--r-- root root system_u:object_r:selinux_config_t config drwxr-xr-x root root system_u:object_r:selinux_config_t targeted -Z¿É¼ÇÀ» ÀÌ¿ëÇØ¼ º¸¾È¹®¸ÆÀ» º¸¿©Áִµ¥ ÀÌ °á°ú¸¦ ÅëÇØ¼ "system_u" »ç¿ëÀÚ, "object_r" ¿ªÇÒ, "selinux_config_t" ŸÀÔÀ» È®ÀÎÇÒ¼ö ÀÖ´Ù. ÀÌ·± ¹®¸ÆÀ¸·Î SELinuxÀÇ Á¤Ã¥¿¡ ºñ±³Çؼ Çã¿ëÇϰųª °ÅºÎÇÏ°Ô µÇ¹Ç·Î ¹®¸ÆÀÌ È®Àΰ¡´ÉÇÏ´Ù¸é SELinux ¸¦ »ç¿ëÁßÀÎ °ÍÀÌ´Ù.. ÆÄÀÏ À̿ܿ¡ ÇÁ·Î¼¼½º¿Í »ç¿ëÀÚ¿¡µµ °¢°¢ ¾Æ·¡Ã³·³ º¸¾È¹®¸ÆÀ» È®ÀÎÇÒ¼ö ÀÖ´Ù root@example# ps axZ | grep squid user_u:system_r:squid_t 3912 ? Ss 0:00 squid -D user_u:system_r:squid_t 3915 ? S 9:10 (squid) -D user_u:system_r:squid_t 3916 ? Ss 0:01 (unlinkd) root@example# id uid=0(root) gid=0(root)groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel) context=root:system_r:unconfined_t RedHat ÀÇ SELinux ÆÐŰÁö °æ¿ì¿¡´Â sestatus -v ¶ó´Â ¸í·ÉÀ» ÀÌ¿ëÇØ¼ ÇöÀç SELinuxÀÇ »ç¿ë»óŸ¦ ¾Æ·¡¿Í °°ÀÌ È®ÀÎÇÒ¼ö ÀÖ´Ù. [root@ns selinux]# sestatus -v SELinux status: enabled SELinuxfs mount: /selinux Current mode: enforcing Mode from config file: enforcing Policy version: 18 Policy from config file:targeted Policy booleans: allow_ypbind active dhcpd_disable_trans inactive httpd_disable_trans active httpd_enable_cgi active httpd_enable_homedirs active httpd_ssi_exec active httpd_tty_comm inactive httpd_unified active mysqld_disable_trans inactive named_disable_trans active named_write_master_zonesactive nscd_disable_trans active ntpd_disable_trans inactive portmap_disable_trans inactive postgresql_disable_transinactive snmpd_disable_trans inactive squid_disable_trans inactive syslogd_disable_trans inactive winbind_disable_trans inactive ypbind_disable_trans inactive Process contexts: Current context: root:system_r:unconfined_t Init context: user_u:system_r:unconfined_t /sbin/mingetty user_u:system_r:unconfined_t /usr/sbin/sshd user_u:system_r:unconfined_t File contexts: Controlling term: root:object_r:devpts_t /etc/passwd root:object_r:etc_t /etc/shadow system_u:object_r:shadow_t /bin/bash system_u:object_r:shell_exec_t /bin/login system_u:object_r:bin_t /bin/sh system_u:object_r:bin_t -> system_u:object_r:shell_exec_t /sbin/agetty system_u:object_r:sbin_t /sbin/init system_u:object_r:init_exec_t /sbin/mingetty system_u:object_r:sbin_t /usr/sbin/sshd system_u:object_r:sbin_t /lib/libc.so.6 system_u:object_r:lib_t -> system_u:object_r:shlib_t /lib/ld-linux.so.2 system_u:object_r:lib_t -> system_u:object_r:ld_so_t [root@ns selinux]# ¹èÆ÷ÆÇ¸¶´Ù ¼ºñ½º ¼³Á¤¹æ¹ýÀº Â÷À̰¡ ÀÖ´Ù. ÇÊÀÚ°¡ Å×½ºÆ®ÇÑ ·¹µåÇÞ°ú Æäµµ¶ó ¹èÆ÷ÆÇ¿¡¼´Â /etc/sysconfig/selinux ÆÄÀÏ¿¡¼ SELinux ÀÇ »ç¿ë°¡´ÉÇÑ ¸ðµå¸¦ ¼³Á¤ÇÑ´Ù. /etc/sysconfig/selinux ÆÄÀÏÀÇ ³»¿ë # 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 # SELINUXTYPE= type of policy in use. Possible values are: # targeted - Only targeted network daemons are protected. # strict - Full SELinux protection. SELINUXTYPE=targeted ÀÌ ÆÄÀÏ¿¡´Â µÎºÎºÐÀÇ ¼³Á¤ÀÌ Àִµ¥ SELINUX ÀÇ »óÅÂ(enforcing, permissive, disabled)¸¦ ¼³Á¤ÇÏ´Â ºÎºÐ°ú Ȱ¼ºÈ½Ãų º¸¾ÈÁ¤Ã¥(strict ¶Ç´Â targeted Áß Çϳª)À» °áÁ¤ÇÏ´Â SELINUXTYPE À̶ó´Â ºÎºÐÀÌ ÀÖ´Ù. disabled ? SELinux º¸¾È Á¦¾î¸¦ »ç¿ëÇÏÁö ¾ÊÀ¸·Á¸é disalbed ¿É¼ÇÀ» ¼±ÅÃÇÑ´Ù. disalbed ¼³Á¤Àº º¸¾È Á¦¾î ±â´ÉÀ» ²ô°í ½Ã½ºÅÛÀÌ º¸¾È Á¤Ã¥À» »ç¿ëÇÏÁö ¾Êµµ·Ï ¼³Á¤ÇÑ´Ù. permissive ? À̰ÍÀ» ¼±ÅÃÇÏ¸é ¼ºñ½º °ÅºÎ ¸Þ½ÃÁö¸¦ Å뺸¹ÞÀ» ¼ö ÀÖ´Ù. permissive »óÅ·Π¼³Á¤Çϸé ÀÚ·á¿Í ÇÁ·Î±×·¥¿¡ À̸§À» ÇÒ´çÇÑ ÈÄ ·Î±×¸¦ ±â·ÏÇÏÁö¸¸ º¸¾È Á¤Ã¥À» »ç¿ëÇÏÁö´Â ¾Ê´Â´Ù. permissive »óÅ´ SELinux¸¦ óÀ½ Á¢ÇÏ´Â °æ¿ì óÀ½ºÎÅÍ ÀÌ ±â´ÉÀ» ¿ÏÀüÈ÷ Ȱ¼ºÈÇÏÁö ¾Ê°í ¿ì¼± ÀÌ Á¤Ã¥À» »ç¿ëÇØ¼ ÀÏ¹Ý ½Ã½ºÅÛ ÀÛ¾÷½Ã ¾î¶°ÇÑ ¿µÇâÀ» ¹ÌÄ¡´ÂÁö ¾Ë¾Æº¸·Á´Â °æ¿ì ÁÁÀº ½ÃÀÛÁ¡ÀÌ µÉ ¼ö ÀÖ´Ù. ±×·¯³ª °æ°í ¿É¼ÇÀ» ¼±Åýà °¡²û¾¿ º¸¾È°æ°í ´ë»óÀÌ ¾Æ´Ñ °ÍÀ» °æ°í ´ë»óÀ¸·Î ŽÁöÇÏ´Â ¿À·ù(false positive)³ª °æ°í ´ë»óÀÎ °ÍÀ» ŽÁöÇÏÁö ¾Ê´Â ¿À·ù(false negative)°¡ ¹ß»ýÇÒ °¡´É¼ºµµ ÀÖÀ¸´Ï ÁÖÀǰ¡ ÇÊ¿äÇÏ´Ù. enforcing ? SELinux¸¦ ¿ÏÀüÈ÷ Ȱ¼ºÈÇϽ÷Á¸é enforcing ¿É¼ÇÀ» ¼±ÅÃÇÏÀÚ. enforcing ¿É¼ÇÀ» ¼±ÅÃÇϸé Ãß°¡ ½Ã½ºÅÛ º¸¾ÈÀ» À§ÇØ ¸ðµç º¸¾È Á¤Ã¥ (¿¹, Çã°¡°¡ ¾ø´Â »ç¿ëÀÚ°¡ ƯÁ¤ÇÑ ÆÄÀÏÀ̳ª ÇÁ·Î±×·¥¿¡ Á¢±ÙÇÏ´Â °ÍÀ» °ÅºÎÇϱâ)À» »ç¿ëÇÑ´Ù. SELinux°¡ ¿ÏÀüÈ÷ ½ÇÇàµÇ¾îµµ ¾Æ¹«·± ÁöÀåÀ» ¹ÞÁö¾Ê°í ÀϹÝÀûÀÎ ½Ã½ºÅÛ ÀÛ¾÷À» ¼öÇàÇÒ ¼ö ÀÖ´Ù°í ÀÚ½ÅÇϽðæ¿ì ÀÌ ¿É¼ÇÀ» ¼±ÅÃÇÑ´Ù.
sentenforce ¸í·ÉÀº sysadm_r ±ÇÇÑÀ» °®°í ¼öÇàÇØ¾ß ÇÑ´Ù; ±×·¯±â À§ÇØ, newrole ¸í·ÉÀ» »ç¿ëÇϰųª, ¾Æ´Ï¸é, su -¸¦ »ç¿ëÇÏ¿© root ·Î »ç¿ëÀÚ ÀüȯÀ» Çϸé, ÀÚµ¿À¸·Î sysadm_r ±ÇÇÑÀ» ¾òÀ» ¼ö ÀÖ´Ù. SELinux ÀÇ º¸¾È¹®¸ÆÀ» º¯°æÇØ¾ß ÇÏ´Â °æ¿ì¿¡´Â chcon À̶ó´Â ¸í·ÉÀ» »ç¿ëÇÒ¼ö ÀÖ´Ù. ¾ÆÆÄÄ¡¸¦ »ç¿ëÁß¿¡ ºÐ¸íÈ÷ µð·ºÅ丮¸¦ »ý¼ºÇߴµ¥µµ ¿¡·¯°¡ ³´Ù¸é ¾Æ·¡Ã³·³ http_user_content_t ¸¦ ÇØ´ç DocumentRoot ¿¡ Àû¿ëÇØÁÜÀ¸·Î ÇØ°áÇØ ÁÙ¼öÀÖ´Ù. chcon -R -t httpd_user_content_t /home/»ç¿ëÀÚ°èÁ¤/public_html
dhcpd_disable_trans=0 httpd_disable_trans=1 httpd_enable_cgi=1 httpd_enable_homedirs=1 httpd_ssi_exec=1 httpd_tty_comm=0 httpd_unified=1 mysqld_disable_trans=0 named_disable_trans=1 named_write_master_zones=1 nscd_disable_trans=1 ntpd_disable_trans=0 portmap_disable_trans=0 postgresql_disable_trans=0 snmpd_disable_trans=0 squid_disable_trans=0 syslogd_disable_trans=0 winbind_disable_trans=0 ypbind_disable_trans=0 RHEL4ÀÇ °æ¿ì Àüȯ°¡´ÉÇÑ ½Ã½ºÅÛÀÇ SELinux ¼³Á¤°ªµéÀ» ³ªÅ¸³»´Â ÆÄÀÏÀº /etc/selinux/targeted/booleans ÆÄÀÏÀÌ´Ù. ÆÄÀϾÈÀÇ °¢ Ç׸ñÀº system-config-securitylevel À̶ó´Â ¾îÇø®ÄÉÀ̼ÇÀ̳ª setsebool À̶ó´Â ¸í·ÉÀ» ÀÌ¿ëÇØ¼ º¯°æ½Ãų¼ö ÀÖÀ¸¸ç setsebools À» ÀÌ¿ëÇÏ´Â °æ¿ì -P ¿É¼ÇÀ» »ç¿ëÇÏÁö ¾ÊÀ¸¸é ¼³Á¤ÆÄÀÏÀº º¯°æµÇÁö ¾Ê°í ÇöÀçÀÇ ¼³Á¤¸¸ ¹Ù²îÁö¸¸ -P ¿É¼ÇÀ» °°ÀÌ »ç¿ëÇϸé /etc/selinux/targeted/booleans ÆÄÀÏÀÇ ³»¿ë±îÁö °°ÀÌ º¯°æµÇ¾î ½Ã½ºÅÛ ¸®ºÎÆÃÈÄ¿¡µµ Àû¿ëµÈ´Ù Á¤Ã¥ ±³Ã¼´Â °¡º±°Ô ÃëÇÒ »ç¾ÈÀÌ ¾Æ´Ï´Ù. ¿¬±¸ ¸ñÀûÀ¸·Î ½ÃÇè Àåºñ(test machine)¿¡¼ »õ Á¤Ã¥À» ½ÃµµÇÏ´Â ÀÌ¿Ü, »ý»ê ½Ã½ºÅÛ(production system)¿¡¼´Â ´Ù¸¥ Á¤Ã¥À¸·Î ±³Ã¼Çϱâ Àü¿¡ ÇöȲÀ» ½É°¢ÇÏ°Ô °í·ÁÇØ¾ß ÇÑ´Ù. ±³Ã¼ ÀÛ¾÷Àº °£´ÜÇÏ´Ù. ÀÌ´Â ¸Å¿ì ¾ÈÀüÇÑ ¹æ¹ýÀÌÁö¸¸, ¿ì¼± ½ÃÇè ½Ã½ºÅÛ¿¡¼ ÀÏÂ÷ ½ÃµµÇØ º¸´Â °ÍÀÌ ¹Ù¶÷Á÷ÇÏ´Ù. ÇÑ °¡Áö ¹æ¹ýÀº system-config-securitylevelÀ» »ç¿ëÇÏ¿© Á¤Ã¥À» ¹Ù²Ù°í Àç¸í¸í(relabel)Çϵµ·Ï ÆÄÀÏ ½Ã½ºÅÛÀ» ¼³Á¤ÇÏ´Â °ÍÀÌ´Ù. ¼öÀÛ¾÷ ÀýÂ÷´Â ´ÙÀ½°ú °°´Ù: 1. /etc/selinux/configÀ» ÆíÁýÇϰí SELINUXTYPE=policynameÀ¸·Î Á¤Ã¥ À¯ÇüÀ» ¹Ù²Û´Ù. 2. ÀçºÎÆÃÇÏ¿© µ¹¾Æ¿Ã ¼ö ÀÖ´Â Áö È®ÀÎÇϱâÀ§ÇØ, SELINUX=permissive¸ðµå·Î ¼³Á¤ÇÑ´Ù. ÀÌ·¸°Ô Çϸé, SELinux´Â Á¤È®ÇÑ Á¤Ã¥ÇÏ¿¡¼ °¡µ¿µÉ °ÍÀÌÁö¸¸, ¸¸ÀÏ ºÎÁ¤È®ÇÑ ÆÄÀÏ ¹®¸Æ ¸í¸í(labeling)°ú °°Àº ¹®Á¦°¡ ÀÖÀ¸¸é ·Î±×ÀÎÇϵµ·Ï ÇÒ °ÍÀÌ´Ù. 3. sysadm_r ¿ªÇÒÀ» °®Ãá root·Î ÆÄÀÏ ½Ã½ºÅÛÀ» Àç¸í¸íÇÑ´Ù(relabel): id -Z root:sysadm_r:sysadm_t fixfiles relabel ¿É¼Ç -l /path/to/logfileÀ» »ç¿ëÇÏ¿© Ç¥ÁØ Ãâ·ÂÀ¸·Î ·Î±×¸¦ º¼ ¼ö ÀÖ°í, ¿É¼Ç -o /path/to/fileÀ» »ç¿ëÇÏ¿© °ËÅä(checked)µÇ°Å³ª Àç¸í¸í(relabel ed)µÈ ¸ðµç ÆÄÀÏ ¸®½ºÆ®¸¦ ÀúÀåÇÒ ¼ö ÀÖ´Ù. 4. ½Ã½ºÅÛÀ» ÀçºÎÆÃÇÑ´Ù. »õ Á¤Ã¥ÇÏ¿¡¼ÀÇ Àç½ÃÀÛÀº ¸ðµç ½Ã½ºÅÛ ÇÁ·Î¼¼½º°¡ ÀûÀýÇÑ ¹®¸Æ¿¡¼ ½ÃÀ۵ǰí Á¤Ã¥ º¯°æÀ¸·Î ÀÎÇÑ ¸ðµç ¹®Á¦°¡ µå·¯³ª°Ô ÇÑ´Ù. 5. sestatus -v ¸í·ÉÀ¸·Î ¹ßÈ¿µÈ º¯°æ»çÇ×À» È®ÀÎÇÑ´Ù. Permissive ¸ðµå·Î °¡µ¿µÈ »õ ½Ã½ºÅÛ¿¡¼, avc: denied ¸Þ½ÃÁö¸¦ /var/log/messages¿¡¼ È®ÀÎÇÑ´Ù. À̵éÀº »õ Á¤Ã¥ÇÏ¿¡ ¹®Á¦¾øÀÌ ½Ã½ºÅÛÀÌ °¡µ¿µÇµµ·Ï ÇØ°áÇØ¾ß ÇÒ ¹®Á¦µéÀ» Ç¥½ÃÇØ ÁØ´Ù. 6. »õ Á¤Ã¥ÇÏ¿¡¼ ½Ã½ºÅÛÀÌ ¸¸Á·½º·´°Ô µ¹¾Æ°¥ ¶§, SELINUX=enforcing À¸·Î ¹Ù²ã ½ÇÇà ±ÇÇÑÀ» ºÎ¿©ÇÑ´Ù. ½Ç½Ã°£¿¡ enforcingÀ» Ȱ¼ºÈ ½Ã۱â À§ÇØ ÀçºÎÆÃÇϰųª setenforce 1 À» ½ÇÇàÇÑ´Ù. SELinux ÀÇ ·Î±×´Â /var/log/messages ÆÄÀÏ¿¡ ¾Æ·¡Ã³·³ ³ªÅ¸³´Ù kernel: audit(1114070701.193:0): avc: denied { read } for pid=24216 exe=/usr/libexec/mysqld name=mysql dev=cciss/c0d0p6 ino=16408 scontext=user_u:system_r:mysqld_t tcontext=root:object_r:var_lib_t tclass=dir ÀÌ ·Î±×´Â ¾Æ·¡¿Í °°ÀÌ ÇØ¼®ÇÒ¼ö ÀÖ´Ù. - Àб⠿äûÀÌ °ÅºÎµÇ¾ú´Ù. - PID 24216À» °¡Áø ÇÁ·Î¼¼½º°¡ read¸¦ ½ÃµµÇÑ´Ù - ÇØ´çÇÁ·Î¼¼½º´Â /usr/libexec/mysqld ÀÌ´Ù - /dev/cciss/c0d0p6 ¿¡¼ ÀÛµ¿µÇ°í ÀÖ´Ù - inode ´Â 16408ÀÌ´Ù. - ÇÁ·Î¼¼½ºÀÇ SELinux ¹®¸ÆÀº user_u:system_r:mysqld_t ÀÌ´Ù. - tcontext=root:object_r:var_lib_t : ÀÌÆÄÀÏÀÌ Àб⸦ ½ÃµµÇÏ´Â ÆÄÀÏÀº var_lib_t ŸÀÔÀÇ root ¼ÒÀ¯ÆÄÀÏÀÌ´Ù SELinux LOG °¢ Ç׸ñÀÇ ÀÇ¹Ì audit(timestamp) -- This field states that it's an audit message from SELinux and that it was logged at timestamp time (in seconds since Jan. 1st, 1970). avc -- This message was from the SELinux access vector cache. Pretty much every message you are likely to see is from this cache. denied | accepted -- This field indicates whether the action was denied or accepted. You may see logs of accepted messages in some cases (like reloading the policy). { read | write | unlink | ... } -- This field shows the type of action that was attempted, such as reading a file, writing, unlinking, loading policy, etc. for pid= -- This is the process ID that attempted the action. exe= -- This is the path to the executable that started the process. name= -- This is the name of the target on which the action was attempted. dev= -- This is the device on which the target file is located. ino= -- This is the inode of the target of the action. scontext= -- This is the process's security context. This contains user, role, and type. tcontext= -- This is the security context of the target of this action, for example, the file, directory, etc. tclass= -- This is the class of the target object, such as directory, file, device node, or something else. Á¤Ã¥ ÀÛ¼ºÀÚ¿¡°Ô À¯¿ëÇÑ µµ±¸´Â /usr/bin/audit2allow Àε¥ À̰ÍÀº /var/log/messagesÀÇ avc ¸Þ½ÃÁö¸¦ SELinux¿¡ ÀÇÇØ »ç¿ëµÉ ¼ö ÀÖ´Â ±ÔÄ¢À¸·Î ¹ø¿ªÇØÁØ´Ù. »ç¿ëÀÌ ºÒ°¡´ÉÇÏ´Ù¸é policycoreutils ÆÐŰÁö¿¡ ¼ÓÇØÀÖÀ¸¹Ç·Î yum install policycoreutils ó·³ ¼³Ä¡ °¡´ÉÇÏ´Ù. audit2allow¸í·ÉÀº ¼¼°¡Áö ¹æ¹ýÀ¸·Î ÀÔ·ÂÀ» ¹ÞÀ» ¼ö ÀÖ´Ù. ±âº»Àº Ç¥ÁØÀÔ·Â (stdin)ÀÌ´Ù. -i ¿É¼ÇÀ» »ç¿ëÇϸé /var/log/messages ·ÎºÎÅÍ ÀÔ·ÂÀ» ÀÐÀ» ¼ö ÀÖ°í -d¿É¼ÇÀ» »ç¿ëÇϸé dmesg Ãâ·ÂÀ¸·ÎºÎÅÍ ÀÔ·ÂÀ» ÀÐÀ» ¼ö ÀÖ´Ù. ÀÌ ¸Þ½ÃÁö´Â ÇöÀç ½ÇÇàµÈ SELinux Á¤Ã¥ÀÌ ±× ÀÀ¿ëÇÁ·Î±×·¥ÀÇ µ¿ÀÛÀ» Çã¶ôÇÏÁö ¾Ê±â ¶§¹®ÀÌ´Ù. ÀÌ·¯ÇÑ ÀÏ¿¡´Â ¿©·¯ °¡Áö »çÀ¯°¡ Á¸ÀçÇÑ´Ù. ù°, ÀÀ¿ëÇÁ·Î±×·¥ÀÌ Á¢±ÙÇÏ·Á´Â ÆÄÀÏÁß Çϳª°¡ À߸ø ¸í¸íµÇ¾îÀÖÀ» ¼ö ÀÖ´Ù. ¸¸ÀÏ AVC ¸Þ½ÃÁö°¡ ƯÁ¤ ÆÄÀÏÀ» ÂüÁ¶ÇÑ´Ù¸é, ls -alZ /path/to/file À» ¼öÇàÇÏ¿© ÇöÀç ÂüÁ¶ÇÏ´Â ÆÄÀϸí(current label)À» Á¶»çÇØ º¸¶ó. ¸¸ÀÏ ±×°ÍÀÌ À߸øµÇ¾î º¸À̸é, restorecon -v /path/to/file À» ½ÃµµÇغ¸¶ó. ¸¸ÀÏ ÆÄÀϰú °ü·ÃµÈ ¸Å¿ì ¸¹ Àº °ÅºÎ(denials) »óȲÀÌ Á¸ÀçÇϸé, fixfiles relabel À» ¼öÇàÇϰųª, ¹Ýº¹ÀûÀ¸·Î µð·ºÅ丮 °æ·Î¸¦ Àç¸í¸íÇϱâ À§Çؼ -R¿É¼Ç°ú ÇÔ²² restorecon À» ¼öÇàÇÏ°í ½ÍÀ» ¼ö ÀÖ´Ù. ´Ù¸¥ ¶§¿¡´Â, °ÅºÎ(denials) Çö»óÀº Á¤Ã¥¿¡ ÀÇÇØ °ÅºÎµÇµµ·Ï ÇÁ·Î±×·¥¿¡ ¼³Á¤À» ¹Ù²ã¼ ¹ß»ýµÉ ¼ö ÀÖ´Ù. ¿¹¸¦ µé¸é, ¸¸ÀÏ Apache¸¦ 8800Æ÷Æ®·Î ¹Ù²Ù¸é, º¸¾È Á¤Ã¥, apache.te,µµ °ü·ÃÇÏ¿© ¹Ù²ã¾ß ÇÒ Çʿ䰡 »ý±ä´Ù. Á¤Ã¥ ÀÛ¼º¿¡ °üÇÑ »ó¼¼ÇÑ Á¤º¸°¡ ÇÊ¿äÇϸé, ¿ÜºÎ¿¬°á ¸®½ºÆ®(External Link List)¸¦ º¸¶ó. The Un-Official SELinux FAQ -- http://www.crypt.gen.nz/selinux/faq.html SELinux link zoo -- http://www.crypt.gen.nz/selinux/links.html Ubuntu Linux SELinux pages -- https://www.ubuntulinux.org/wiki/SELinux 2005.8 Sys Admin Magazine -- http://www.samag.com/documents/s=9820/sam0508a/0508a.htm NSA SELinux FAQ ? http://www.nsa.gov/selinux/info/faq.cfm SELinux community page ? http://selinux.sourceforge.net/ UnOfficial FAQ ? http://www.crypt.gen.nz/selinux/faq.html Writing SE Linux policy HOWTO ? https://sourceforge.net/docman/display_doc.php?docid=21959&group_id=21266 Getting Started with SE Linux HOWTO: the new SE Linux (Debian) ? https://sourceforge.net/docman/display_doc.php?docid=20372&group_id=21266 |