프린트 하기

OS 환경 : Oracle Linux 8.4 (64bit)

 

DB 환경 : Oracle Database 19.27.0.0

 

에러 : mv: setting attribute 'security.selinux' for 'security.selinux': Operation not permitted

mv시 발생하는 에러 메세지

1
2
3
4
5
$ cd /app/oracle/media
$ mv ./* /oraimsi/media/
mv: setting attribute 'security.selinux' for 'security.selinux': Operation not permitted
mv: setting attribute 'security.selinux' for 'security.selinux': Operation not permitted
mv: setting attribute 'security.selinux' for 'security.selinux': Operation not permitted
cs

실제로 mv는 되었지만 경고성으로 위 메세지들이 발생함

 

 

해결 방법 : selinux disabled 처리 및 selinux 미사용시 attr 속성 제거

현재 selinux 속성 확인

1
2
3
4
5
6
7
8
9
10
11
12
13
$ cat /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 - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

disabled 상태임

 

 

/oraimsi 디스크와 기존 / 디스크에 mount 시 다른 옵션이 있는지 확인

1
2
3
$ mount | grep /dev/sd
/dev/sda1 on /boot type xfs (rw,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota)
/dev/sdb1 on /oraimsi type xfs (rw,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota)
cs

없음, 동일함

 

 

현재 붙어 있는 xattr 확인

1
2
3
4
5
6
7
8
$ cd /app/oracle/media/
$ getfattr --m- -R .
# file: .
security.selinux="unconfined_u:object_r:default_t:s0"
 
$ cd /oraimsi/media/
$ getfattr --m- -R .
(결과 없음)

두개 폴더의 xattr 속성값이 다름(/oraimsi에는 selinux 설정이 없음)

 

 

/app/oralce/media에 있는 selinux 속성 제거(root 권한으로)

*selinux를 안쓰는 경우에만 아래 명령을 사용해야함

1
# find /app/oracle/media -exec setfattr -x security.selinux {} \;

 

 

다시 확인

1
2
3
$ cd /app/oracle/media/
$ getfattr --m- -R .
(결과 없음)

정상적으로 제거됨

 

 

참고로 mv시 --no-preserve=context 옵션을 사용하면 에러가 발생하지 않는다고함

그런데 매번 저 옵션을 쓰기 귀찮아서 해결방법을 찾아봤음

 

 

원인 : 원본 파일의 security.selinux xattr을 mv가 복사하려다 권한이 없어 실패함

원본 디렉토리에 security.selinux xattr이 남아 있었고, mv가 이 속성을 대상 디렉토리에 쓰려 했으나 권한이 없어 실패했음
SELinux는 꺼져 있어서 실제 동작엔 문제 없었고 경고만 출력되었음

 

 

좀더 자세히 원인을 추측해보자면 /app/oracle/media 및 /app/oracle/이하 디렉토리들은 초기 oracle db 구성 전 selinux 를 disabled 처리하기전에 mkdir 로 생성했던것같음. 그래서 selinux 속성값이 개별 폴더에 들어간것으로 보임

하지만 신규로 mount한 /oraimsi는 이 시점이 이미 selinux가 disabled 였기때문에 selinux 속성값이 안들어갔었음 

그래서 selinux 속성이 있는 폴더에서 없는 폴더로 mv 하려다가 에러가 난것으로 보임

 

 

참조 : 

https://unix.stackexchange.com/questions/725967/what-is-this-strange-selinux-attribute-on-several-of-my-files?utm_source=chatgpt.com