13/120

김건호·2022년 2월 23일
0

ACL

Acess control list
사용자 별로 파일이나 디렉토리에 권한을 부여 가능
특정 사용자, 그룹으로 파일이나 디렉토리에 권한을 부여 가능

기본 권한과의 차이

기본적인 일반권한 허가 루틴

  1. 소유주인가?
YN
소유주의 권한2번으로
  1. 소유그룹인가?
YN
소유그룹의 권한기타사용자의 권한

ACL을 설정한 경우

  1. 소유주인가?
YN
소유주의 권한2번으로
  1. 특정 사용자인가?
YN
특정 사용자의 권한3번으로
  1. 소유그룹인가?
YN
소유그룹의 권한4번으로
  1. 특정그룹인가?
YN
특정그룹의 권한기타사용자의 권한

ACL 확인법

파일이나 디렉토리 권한을 나타내는 값 맨 뒤 값이 +라면 ACL이 설정된 것

[root@localhost ~]# ls -ld /ptest
drwxrwxrw-+ 3 root root 39  2월 23 15:30 /ptest

ACL의 이해

  • acl의 대상의 권한과 mask의 권한이 AND 연산을 하여 결과가 나옴
  • 기존에 소유그룹의 권한이 마스크 권한으로 대체 됨
  • 특정사용자, 소유그룹, 특정그룹은 acl의 영향을 받지만, 소유주와 기타사용자는 acl의 영향을 받지 않음

ACL entries

[root@localhost ~]# getfacl /ptest/
getfacl: Removing leading '/' from absolute path names
# file: ptest/
# owner: root
# group: root
user::---
group::---
other::---
  • u::perm : 사용자의 권한
  • g::perm : 사용자 그룹의 권한
  • o::perm : 기타 사용자의 권한
  • u:username:perm : 특정 사용자의 권한 (/etc/passwd에 존재해야 함)
[root@localhost ~]# setfacl -m u:user01:5 /ptest/
[root@localhost ~]# ls -ld /ptest/
dr-xr-x---+ 2 root root 6  2월 23 22:26 /ptest/
[root@localhost ~]# getfacl /ptest
getfacl: Removing leading '/' from absolute path names
# file: ptest
# owner: root
# group: root
user::r-x
user:user01:r-x
group::---
mask::r-x
other::---

mask == 영향을 끼치는 acl값, /ptest/의 그룹권한이 mask값으로 대치된 것을 확인가능

  • g:groupname:perm : 특정 그룹의 권한(/etc/group에 존재해야 함)
  • m:perm : ACL mask, 특정 사용자나 그룹에 허용되는 최대 유효 사용 권한
[root@localhost ~]# setfacl -m u:user01:5 /ptest/
[root@localhost ~]# setfacl -m m::4 /ptest/
[root@localhost ~]# getfacl /ptest/
getfacl: Removing leading '/' from absolute path names
# file: ptest/
# owner: root
# group: root
user::r-x
user:user01:r-x                 #effective:r--
group::---
mask::r--
other::---
[root@localhost ~]# ls -ld /ptest/
dr-xr-----+ 2 root root 6  2월 23 22:26 /ptest/

user01에 대한 acl 권한이 5이지만 ACL mask인 권한의 최대 값이 4이므로 실제 권한 값은 #effective에 나와있는 r--가 됨

일반 acl과 기본(default) acl

일반 acl

acl이 설정되어 있는 그 자체에 대해서 권한 행사

기본 acl

  • 디렉토리에만 지정 가능
  • 기본 acl이 설정되어 있는 디렉토리에 대해서는 아무런 권한을 행사할 수 없음
  • 대신, 기본 acl이 설정되어 있는 디렉토리에 파일이나 디렉토리를 생성할 경우 기본 acl 설정이 생성 파일이나 디렉토리에 부여 => 생성된 디렉토리에는 기본acl이 상속
[root@localhost ~]# touch dir01/filea

[root@localhost ~]# setfacl -m u:user01:0 dir01
[root@localhost ~]# ls -ld dir01
drwxr-xr-x+ 2 root root 19  2월 24 09:46 dir01
[root@localhost ~]#
[root@localhost ~]# getfacl dir01/
# file: dir01/
# owner: root
# group: root
user::rwx
user:user01:---
group::r-x
mask::r-x
other::r-x

[root@localhost ~]# setfacl -m d:u:user01:0 dir01

[root@localhost ~]# ls -l dir01/
합계 0
-rw-r--r--. 1 root root 0  2월 24 09:46 filea
-rw-r--r--. 1 root root 0  2월 24 09:47 fileb
// 설정을 바꾸더라도 기존의 파일에는 영향을 끼치지 않음
// 설정 이후 생성된 파일에 default acl 부여됨
[root@localhost ~]# ls -l dir01
합계 0
-rw-r--r--. 1 root root 0  2월 24 09:46 filea
-rw-r--r--. 1 root root 0  2월 24 09:47 fileb
-rw-r--r--+ 1 root root 0  2월 24 09:49 filec
[root@localhost ~]# getfacl dir01/filec
# file: dir01/filec
# owner: root
# group: root
user::rw-
user:user01:---
group::r-x                      #effective:r--
mask::r--
other::r--
// 하위 디렉토리에 상속
[root@localhost ~]# mkdir dir01/dir02
[root@localhost ~]# getfacl dir01/dir02
# file: dir01/dir02
# owner: root
# group: root
user::rwx
user:user01:---
group::r-x
mask::r-x
other::r-x
default:user::rwx
default:user:user01:---
default:group::r-x
default:mask::r-x
default:other::r-x

기존에 있는 파일까지 변경하고 싶다면❓
-R (recursive)옵션사용

[root@localhost ~]# setfacl -R -m u:centos:0 dir01
[root@localhost ~]# ls -l dir01
합계 0
drwxr-xr-x+ 2 root root 6  2월 24 09:50 dir02
-rw-r--r--+ 1 root root 0  2월 24 09:46 filea
-rw-r--r--+ 1 root root 0  2월 24 09:47 fileb
-rw-r-xr--+ 1 root root 0  2월 24 09:49 filec

관련명령어

getfacl

Get File Access Control List
ACL 설정을 확인하는 명령어
mask값이 없다면 acl이 지정되지 않은 것

[root@localhost ~]# getfacl /ptest
getfacl: Removing leading '/' from absolute path names
# file: ptest
# owner: root
# group: root
user::r-x
user:user01:r-x
group::---
mask::r-x
other::---

setfacl

Set File Access Control List
ACL을 설정하는 명령어

# setfacl [option] [acl_entries] [파일/디렉토리명]

옵션

  • -m : acl 설정
[root@localhost ~]# setfacl -m u:user01:5 /ptest/
  • -x : acl엔트리 삭제
[root@localhost ~]# setfacl -x u:user01: /ptest/

mask를 삭제하려면, 특정사용자, 특정그룹에 대한 엔트리부터 삭제해야함

  • -b : acl설정 초기화
[root@localhost ~]# setfacl -b /ptest/
  • -k : default acl설정 초기화
[root@localhost ~]# setfacl -k /ptest/

디렉토리 acldir01는 aclgroup 만이 읽기 쓰기가능하고 나머지는 읽기만 가능하도록 설정
❗ 디렉토리의 조건이 읽기 쓰기만 있다고 하더라도 디렉토리는 실행 권한이 없으면 접근이 되지 않아 읽기 쓰기를 할 수 없다. 항상 실행권한을 잊지 말자

# chmod 555 /ptest/acldir01
# setfacl -m g:aclgroup:7 /ptest/acldir01
profile
Ken, 🔽🔽 거노밥 유튜브(house icon) 🔽🔽

0개의 댓글