CentOS 서버에서 사용자를 인증하기 위해 SSSD를 사용하고 있습니다. oddjobd-mkhomedir은 기본 홈 디렉토리가 / home 일 때 완벽하게 작동하지만 특정 서버에서는 기본 홈 디렉토리를 / data (SAN 마운트에 있음)로 변경해야했습니다.
이제 사용자가 로그인을 시도 할 때마다 다음 메시지와 함께 bash 쉘에 드롭됩니다.
Creating home directory for first.last.
Could not chdir to home directory /data/X.Y.local/first.last: No such file or directory
-bash-4.1$
모든 시도에 대해 다음 AVC 거부 메시지가 표시됩니다.
type=AVC msg=audit(1492004159.114:1428): avc: denied { create } for pid=2832
comm="mkhomedir" name="x.y.local"
scontext=system_u:system_r:oddjob_mkhomedir_t:s0-s0:c0.c1023
tcontext=system_u:object_r:default_t:s0 tclass=dir
/ data의 컨텍스트를 변경했는지 확인하십시오.
drwxr-xr-x. root root system_u:object_r:home_root_t:s0 data
/ data에 / home과 동일한 컨텍스트가있는 경우 SELinux가 oddjobd가 /data/XYlocal/first.last를 작성하도록 제한하는 이유는 무엇입니까?
# sestatus
SELinux status: enabled
SELinuxfs mount: /selinux
Current mode: enforcing
Mode from config file: enforcing
Policy version: 24
Policy from config file: targeted
[최신 정보]
이것이 올바른 해결 방법인지 확실하지 않지만 다음 세 항목을 추가 한 후 사용자는 이제 로그인하여 홈 디렉토리로 이동할 수 있습니다. 새 사용자의 디렉토리는 아래 정의 된 컨텍스트를 기반으로 작성됩니다.
semanage fcontext -a -t home_root_t /data
semanage fcontext -a -t user_home_dir_t /data/x.y.local
semanage fcontext -a -t user_home_t "/data/x.y.local(/.*)?"
이것이이 문제를 해결하는 올바른 방법입니까?
답변
마지막 섹션 semanage fcontext
은 컨텍스트를 영구적으로 설정하는 올바른 방법입니다. restorecon
그래도 적용 하려면 실행해야합니다 .
restorecon -Rv /data
restorecon
의 항목을 고려 /etc/selinux/targeted/contexts/files/file_contexts.local
하여 방금 추가 한 사용자 정의 fcontext가 있어야합니다.semanage
이러한 컨텍스트를 임시로 설정하려면 다음 chcon
명령을 참조하십시오 .
chcon -Rv -t home_root_t /data
답변
홈 디렉토리를 재배치 할 때 가장 좋은 해결책은 아마도 서버 오류에 대한이 답변에semanage fcontext
설명 된 것과 같은 EQUAL 메커니즘을 사용하는 것입니다 .
semanage fcontext -a -e /home /data
이렇게하면 원래 집 위치의 모든 규칙이 새 집 위치에도 적용됩니다.