Linux ACL을 사용하여 Samba 공유의 하위 디렉터리를 탐색할 수 없습니다.

Linux ACL을 사용하여 Samba 공유의 하위 디렉터리를 탐색할 수 없습니다.

기본적인 문제는 QNAP에 연결된 도메인이 있고 사용자가 백업에서 자신의 파일을 복원할 수 있도록 Samba를 통해 RSnapshot 스냅샷을 게시하려고 한다는 것입니다. (원래 RSnapshot HowTo를 기반으로 함:http://rsnapshot.org/rsnapshot/docs/docbook/rest.html#restoring-backups)

그러나 새 스냅샷이 상속할 기본 ACL(setfacl -mg:MYDOM\Domain\Users:rx)을 설정하지 않으면 공유 스냅샷의 내용을 전혀 찾아볼 수 없습니다.

RSnapshot 개요

시간별/일별/주별/월별 스냅샷을 생성하고 표준 및 확장 Linux ACL을 올바르게 보존합니다. 스냅샷은 다음 디렉터리에 저장됩니다.

/share/CACHEDEV1_DATA/Local Backups

권한이 변경되는 것을 방지하기 위해 디렉터리에 대한 기본 ACL을 지우고 기본 권한만 설정했습니다. 권한은 다음과 같습니다:

# ls -al
drwxrwxrwx    4 admin    administ      4096 Nov 22 17:00 Local Backups/

# getfacl Local\ Backups/
# file: Local Backups/
# owner: admin
# group: administrators
user::rwx
user:admin:rwx
user:guest:---
group::rwx
group:MYDOM\domain\040users:r-x
mask::rwx
other::rwx
default:user::rwx
default:group::rwx
default:mask::rwx
default:other::rwx

즉, 스냅샷 하위 디렉터리(hourly.0, hourly.1 등)에 대한 기본 권한은 다음과 같습니다.

# cd hourly.0

# ls -al
drwxrwxrwx    3 admin    administ      4096 Nov 22 16:02 ./

# getfacl .
# file: .
# owner: admin
# group: administrators
user::rwx
group::rwx
mask::rwx
other::rwx
default:user::rwx
default:group::rwx
default:mask::rwx
default:other::rwx

이 시점에서 RSnapshot은 완전히 테스트되었으며 예상대로 작동합니다. (FS 권한이나 Samba가 문제인 경우 권한은 상당히 자유롭습니다.)

삼바 개요

WebGUI를 통해 LocalBackups라는 공유를 생성하고 smb.conf 파일을 살펴보니 수정 없이 작동할 것으로 예상됩니다. LocalBackups 디렉터리에는 문제 없이 액세스할 수 있지만 백업(예: hourly.0, hourly.1 등)에 액세스하려고 할 때마다 "\192.168.1.20\LocalBackups\에 액세스할 수 있는 권한이 없습니다. 시간당.0.

smb.conf에서 [global] 섹션은 다음과 같습니다.

[global]
# Add this, apparently Windows 7 Bug.
# acl allow execute always = yes
log level = 3
passdb backend = smbpasswd
workgroup = MYDOM
security = ADS
server string =
encrypt passwords = Yes
username level = 0
#map to guest = Bad User
null passwords = yes
max log size = 10
socket options = TCP_NODELAY SO_KEEPALIVE
os level = 20
preferred master = no
dns proxy = No
smb passwd file=/etc/config/smbpasswd
username map = /etc/config/smbusers
guest account = guest
directory mask = 0777
create mask = 0777
oplocks = yes
locking = yes
disable spoolss = no
load printers = yes
veto files = /.AppleDB/.AppleDouble/.AppleDesktop/:2eDS_Store/Network Trash Folder/Temporary Items/TheVolumeSettingsFolder/.@__thumb/.@__desc/:2e*/.@__qini/.Qsync/.@upload_cache/.qsync/.qsync_sn/.@qsys/.streams/.digest/
delete veto files = yes
map archive = no
map system = no
map hidden = no
map read only = no
deadtime = 10
server role = auto
use sendfile = yes
unix extensions = no
store dos attributes = yes
client ntlmv2 auth = yes
dos filetime resolution = no
wide links = yes
#force unknown acl user = yes
force unknown acl user = yes
template homedir = /share/homes/DOMAIN=%D/%U
inherit acls = yes
domain logons = no
min receivefile size = 256
case sensitive = auto
domain master = auto
local master = no
enhance acl v1 = yes
remove everyone = yes
conn log = no
kernel oplocks = no
max protocol = SMB2_10
smb2 leases = yes
durable handles = yes
kernel share modes = no
posix locking = no
lock directory = /share/CACHEDEV1_DATA/.samba/lock
state directory = /share/CACHEDEV1_DATA/.samba/state
cache directory = /share/CACHEDEV1_DATA/.samba/cache
printcap cache time = 0
acl allow execute always = yes
server signing = disabled
aio read size = 1
aio write size = 0
streams_depot:delete_lost = yes
streams_depot:check_valid = no
fruit:nfs_aces = no
fruit:veto_appledouble = no
winbind expand groups = 1
pid directory = /var/lock
printcap name = /etc/printcap
printing = cups
show add printer wizard = no
realm = mydom.local
ldap timeout = 5
password server = mydc001.mydom.local
pam password change = yes
winbind enum users = Yes
winbind enum groups = Yes
winbind cache time = 3600
idmap config * : backend = tdb
idmap config * : range = 400001-500000
idmap config MYDOM : backend = rid
idmap config MYDOM : range = 10000001-20000000
host msdfs = yes
vfs objects =  shadow_copy2 acl_xattr catia fruit qnap_macea streams_depot aio_pthread

[LocalBackups] 섹션은 다음과 같습니다.

[LocalBackups]
comment =
path = /share/CACHEDEV1_DATA/Local Backups
browsable = yes
oplocks = yes
ftp write only = no
recycle bin = no
recycle bin administrators only = no
qbox = no
public = yes
#invalid users = "guest"
#read list = @"MYDOM\Domain Users"
#write list = "admin"
#valid users = "root","admin",@"MYDOM\Domain Users"
guest ok = yes
read only = yes
inherit permissions = no
shadow:snapdir = /share/CACHEDEV1_DATA/_.share/LocalBackups/.snapshot
shadow:basedir = /share/CACHEDEV1_DATA/Local Backups
shadow:sort = desc
shadow:format = @GMT-%Y.%m.%d-%H:%M:%S
smb encrypt = disabled
strict allocate = yes
streams_depot:check_valid = yes
mangled names = yes
admin users =
admin only = "admin"
#nt acl support = no

이 구성을 사용하면 LocalBackupds 디렉터리에 들어갈 수 있지만 스냅샷 하위 디렉터리(예: hourly.0, hourly.1 등)에는 들어갈 수 없습니다.

주석 처리된 행은 차이가 있는지 확인하려는 것이지만 동작은 주석 처리된 행과 일치하거나 주석 처리된 행 없이 일치합니다.

MYDOM\Domain Users를 포함하도록 스냅샷 디렉터리 중 하나(hourly.0)에서 ACL을 변경하면 Samba를 통해 해당 디렉터리(hourly.0)에 접근할 수 있습니다. 그런 다음 디렉터리의 권한은 다음과 같습니다.

# cd hourly.0

# ls -al
drwxrwxrwx    3 admin    administ      4096 Nov 22 18:00 ./

# getfacl .
# file: .
# owner: admin
# group: administrators
user::rwx
group::rwx
group:MYDOM\domain\040users:rwx
mask::rwx
other::rwx
default:user::rwx
default:group::rwx
default:mask::rwx
default:other::rwx

현재 QNAP에서 적절한 로깅을 활성화하는 방법을 알 수 없습니다. 기본 WebUI 로그 정보를 보면 SMB 연결 요청이 내 사용자 이름 등과 함께 전달되는 것을 볼 수 있습니다. 나는 FS 권한보다 더 제한적인 Samba 구성 쪽으로 기울고 있지만 추측하고 있습니다.

이 단계에서는 ACL, Samba 또는 둘 다에 대한 지식이 부족한지 확신할 수 없습니다. 어떤 아이디어가 있나요?

답변1

Samba로 이 문제를 해결하려고 시도하는 대신 Samba 구성을 QNAP에서 생성한 기본값으로 재설정했습니다. (즉, 주석 처리된 행의 주석 처리를 제거하십시오. smb.conf나 자신이나 다른 관리자가 새 공유를 생성하는 경우 웹 GUI가 조정된 파일을 덮어쓸 수 있으므로 장기적으로는 더 안전해 보입니다 .)

그런 다음 파일 시스템 권한을 변경하고, 그룹에 대한 확장 ACL을 추가하고, 디렉터리를 MYDOM\Domain Users읽습니다 .r+x

/share
/share/CACHEDEV1_DATA
/share/CACHEDEV1_DATA/homes

이렇게 하면 도메인 사용자는 파일이 백업되는 동안 해당 homes디렉터리 까지 탐색할 수 있습니다. 그러나 스냅샷 디렉터리( )에서 /share/CACHEDEV1_DATA/Local Backups상속된 기본 ACL이 없고 사용자의 홈 디렉터리도 변경되지 않았으므로 원래 사용자만 자신의 홈 디렉터리에 액세스할 수 있습니다.

R 스냅샷 변경

확장 ACL이 보존된다고 생각합니다. 이는 사실이 아니며, 홈 디렉터리의 표준 ACL이 도메인 사용자 및 그룹을 사용하여 설정되기 때문에 올바른 것처럼 보입니다. 따라서 표준 ACL은 유지되지만 확장 ACL은 유지되지 않습니다. 이 문제를 해결하기 위해 rsnapshot 스크립트를 편집하고 -A다음을 변경하여 rsync에 플래그를 추가했습니다.

my $default_rsync_short_args = '-a';

도착하다

my $default_rsync_short_args = '-aA';

create_backup_point_dir스냅샷 디렉터리(예: hourly.0 등)에 대한 액세스를 수정하기 위해 함수 하단에 다음을 추가하여 함수에 대한 권한도 변경했습니다.

system("setfacl -m g:MYDOM\\\\Domain\\ Users:rx \"$destpath\"");

이제 예상대로 작동하며 사용자는 백업에서 개인 파일을 복원할 수 있습니다. :)

추가 테스트가 완료되면 이를 rsnapshot 패치에 통합하려고 합니다.

관련 정보