SELinux환경에서 NTFS-3G 파티션이 boot시에 자동으로 마운트 되지 않을 경우
CentOS 5에서 SELinux 모듈을 활성화 시켰는데 윈도우 파티션이 자동으로 마운트 되지 않는 문제점을 발견하여 해결한 과정입니다.
SELinux의 구조를 모르는 잘 상황에서 구글에서의 검색을 통해 문제를 해결했으므로 내용상 오류가 있을 수 있습니다.
/var/log/audit/audit.log 에서 내용을 확인할려고만 하다가 부팅화면 및 dmesg 명령에서 맨처음 내용을 확인한 것을 기억하고
혹시나해서 /var/log/messages 를 확인하니 로그가 남아있었다.
1. fstab 환경
[root@localhost ~]# cat /etc/fstab
/dev/VolGroup00/LogVol00 / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
devpts /dev/pts devpts gid=5,mode=620 0 0
tmpfs /dev/shm tmpfs defaults 0 0
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
/dev/VolGroup00/LogVol01 swap swap defaults 0 0
/dev/hda1 /mnt/winc ntfs-3g defaults,locale=ko_KR.UTF-8 0 0
/dev/hda5 /mnt/wind ntfs-3g defaults,locale=ko_KR.UTF-8 0 0
2. 에러 메시지 확인(/var/log/messages, /var/log/audit/audit.log)
[root@localhost ~]# egrep -i 'avc|fuse|ntf' /var/log/messages
Apr 19 18:52:17 localhost kernel: audit(1208602317.943:4): avc: denied { getattr } for pid=1656 comm="mount.ntfs-3g" path="/sbin/modprobe" dev=dm-0 ino=2392076 scontext=system_u:system_r:mount_t:s0 tcontext=system_u:object_r:insmod_exec_t:s0 tclass=file
Apr 19 18:52:17 localhost kernel: fuse init (API version 7.8)
Apr 19 18:52:17 localhost kernel: fuse distribution version: 2.7.2
Apr 19 18:52:17 localhost kernel: SELinux: initialized (dev hda1, type fuseblk), not configured for labeling
Apr 19 18:52:17 localhost kernel: audit(1208602319.288:5): avc: denied { mount } for pid=1656 comm="mount.ntfs-3g" name="/" dev=hda1 ino=1 scontext=system_u:system_r:mount_t:s0 tcontext=system_u:object_r:unlabeled_t:s0 tclass=filesystem
Apr 19 18:52:17 localhost kernel: SELinux: initialized (dev hda5, type fuseblk), not configured for labeling
Apr 19 18:52:17 localhost kernel: audit(1208602319.653:6): avc: denied { mount } for pid=1667 comm="mount.ntfs-3g" name="/" dev=hda5 ino=1 scontext=system_u:system_r:mount_t:s0 tcontext=system_u:object_r:unlabeled_t:s0 tclass=filesystem
Apr 19 19:04:31 localhost kernel: audit(1208603052.428:4): avc: denied { execute } for pid=1660 comm="mount.ntfs-3g" name="modprobe" dev=dm-0 ino=2392076 scontext=system_u:system_r:mount_t:s0 tcontext=system_u:object_r:insmod_exec_t:s0 tclass=file
3. SELinux의 audit log 에서 정보를 가져와 정책을 만들고 적용한다.
[root@localhost ~]# egrep -i 'avc|ntfs-3g' /var/log/messages | audit2allow -M ntfs3g
[root@localhost ~]# semodule -i ntfs3g.pp
4. 관련된(생성되거나 변경된) 파일 확인
[root@localhost ~]# ls /etc/selinux/targeted/modules/active/modules/
amavis.pp dcc.pp mozilla.pp nagios.pp pcscd.pp ricci.pp
ccs.pp evolution.pp mplayer.pp ntfs3g.pp pyzor.pp smartmon.pp
clamav.pp iscsid.pp mypolicy.pp oddjob.pp razor.pp
[root@localhost ~]# cat ~/ntfs3g.te
module ntfs3g 1.0;
require {
type insmod_exec_t;
type unlabeled_t;
type mount_t;
class file { getattr execute };
class filesystem mount;
}
#============= mount_t ==============
allow mount_t insmod_exec_t:file { getattr execute };
allow mount_t unlabeled_t:filesystem mount;
[root@localhost mnt]# ls -dZ /mnt/winc /mnt/wind
drwxrwxrwx root root system_u:object_r:unlabeled_t /mnt/winc
drwxrwxrwx root root system_u:object_r:unlabeled_t /mnt/wind
4. 재부팅하여 자동으로 mount 되었는지 확인한다.
5. 시스템 종료시에 audit 로그를 보게 될 것이다. 추측하기로는 umount 에 대한 정책이 빠져있어서 그런것으로 보인다. 추후에 SELinux 에 대해 더 알게 된다면 추가해 보아야 겠다.
a. 참고자료
Administrator Control of SELinux
http://www.centos.org/docs/5/html/Deployment_Guide-en-US/sec-sel-admincontrol.html
Bugzilla Bug 211767: SELinux blocks automatic mounting of ntfs partitions via ntfs-3g
https://bugzilla.redhat.com/show_bug.cgi?id=211767
NTFS Mount on boot not working
http://www.centos.org/modules/newbb/viewtopic.php?topic_id=12981
댓글 달기