
CentOS 6.2를 사용하고 있으며 파일이 있습니다.대체 액세스 방법문자가 점으로 나타납니다.
ls -l myfile
-rwxr-x---. 1 me mygroup 172 Aug 13 10:03 myfile
^
This dot.
ls가 표시하는 도움말에서정보 coreutils 'ls 호출'
Following the file mode bits is a single character that specifies
whether an alternate access method such as an access control list
applies to the file. When the character following the file mode
bits is a space, there is no alternate access method. When it is
a printing character, then there is such a method.
GNU `ls' uses a `.' character to indicate a file with an SELinux
security context, but no other alternate access method.
A file with any other combination of alternate access methods is
marked with a `+' character.
그래서 이 파일에는SELinux 보안 컨텍스트그것에 할당되었습니다. 사용사실을 확인하세요그리고살찌다이 명령은 다음을 표시합니다.
getfacl myfile
# file: myfile
# owner: me
# group: mygroup
user::rwx
group::r-x
other::---
getfattr -m - myfile
# file: myfile
security.selinux
getfattr -n security.selinux myfile
# file: myfile
security.selinux="unconfined_u:object_r:usr_t:s0"
원본 파일을 백업했습니다.
cp --preserve=all myfile myfile.ORIG
그런 다음 원본 텍스트가 편집되었습니다.
vi myfile
:wq
이렇게 하면 기존의 모든 배경이 파괴됩니다.
ls -l myfile
-rwxr-x--- 1 me mygroup 172 Aug 13 10:06 myfile
^
The dot is gone.
getfattr -n security.selinux myfile
myfile: security.selinux: No such attribute
getfacl myfile
# file: myfile
# owner: me
# group: mygroup
user::rwx
group::r-x
other::---
이 파일을 편집하고 확장된 속성과 대체 액세스 방법 설정을 유지하기 위해 권장되는 절차는 무엇입니까?
답변1
편집자는 파일을 저장할 때 두 가지 전략 중 하나를 따를 수 있습니다.
- 새 파일을 만든 다음 이를 이동하여 이전 파일을 대체합니다. 가장 큰 장점은 유효한 파일이 항상 존재한다는 것입니다. 이전 버전은 자동으로 새 버전으로 대체됩니다. 단점은 새 파일이 생성되므로 편집자가 최선을 다해 이전 파일의 소유권과 권한을 수동으로 복사해야 한다는 것입니다. 이 방법은 하드 링크도 끊습니다.
- 기존 파일에 씁니다. 이렇게 하면 하드 링크와 권한이 유지됩니다. 또한 추가 디스크 공간이 필요하지 않지만 먼저 백업을 수행하는 것이 좋습니다. 이는 의미가 없습니다. 이 방법의 가장 큰 단점은 파일이 저장되는 동안 프로그램이 파일을 읽으려고 하면 잘린 파일이 표시된다는 것입니다. 저장이 중단되면(예: 정전으로 인해) 파일의 일부가 보존됩니다.
편집자는 일반적으로 첫 번째 방법을 선호하고 기존 파일에 대한 권한을 복사할 수 없거나 기존 파일에 하드 링크가 있음을 감지하면 두 번째 방법으로 전환합니다.
대부분의 편집자는 아마도 추가 SELinux 속성의 존재를 인식하지 못하므로 첫 번째 방법을 적용합니다. 최신 버전의 GNU coreutils(≥ 8.6)를 사용하면 cp --preserve=context --attributes-only
대상 파일의 내용을 변경하지 않고도 한 파일의 SELinux 컨텍스트를 다른 파일로 복사할 수 있습니다.
또는 편집자에게 파일을 그 자리에서 편집하도록 지시하십시오. Vim 설정 사용
backupcopy
옵션yes
이것이 시스템의 기본 설정이 아닌 경우 . Emacs를 사용하여 설정backup-by-copying
바꾸다도착하다 t
.