MiK*_*iKi 4 linux network-share samba access-control-list
有没有办法直接通过 Linux 本身从 Samba 共享的文件和文件夹设置 Windows ACL?
我知道有 setfacl/getfacl 选项,但它们只能在以下之间更改: - DENY | 只读 | 完全控制 - 如果我没记错的话。
但我需要一个Windows安全组修改权限。并且递归到所有以下目录。如果我直接通过 SMB 连接从 Windows 更改此设置,由于文件数量庞大,这将需要数小时甚至数天的时间。有办法做到这一点还是仍然不可能?我知道这些信息存储在共享中的任何位置,因为我可以将 Linux 中的文件复制到共享文件夹,并且它们会自动获得之前选择的修改权限。
为了避免通过 SMB 更改设置,我从共享中复制文件。删除共享中的所有文件并更改共享上 Windows 的权限。
Actually this is how I proceeding so far:
In Linux:
1. I copy files and folders from the share folder to a separate location.
2. I delete all stuff in the share folder.
In Windows:
3. Then accessing the empty share folder through SMB.
4. From here I can change recursively the permissions for access groups to apply "modify" permissions.
Back in Linux:
5. Now I can copy the files and folders back into the share folder to set the permissions.
Run Code Online (Sandbox Code Playgroud)
-> 文件通过复制过程获得了新的权限。
小智 5
如果您运行的是 Samba 4,命令samba-tool ntacl肯定可以做到这一点。
不幸的是,很难找到有关如何使用此命令设置 ACL 的详细文档:
#samba-tool ntacl set -h
Usage: samba-tool ntacl set <acl> <file> [options]
Set ACLs on a file.
Options:
-h, --help show this help message and exit
--quiet Be quiet
--xattr-backend=XATTR_BACKEND
xattr backend type (native fs or tdb)
--eadb-file=EADB_FILE
Name of the tdb file where attributes are stored
--use-ntvfs Set the ACLs directly to the TDB or xattr for use with
the ntvfs file server
--use-s3fs Set the ACLs for use with the default s3fs file server
via the VFS layer
--service=SERVICE Name of the smb.conf service to use when applying the
ACLs
Samba Common Options:
-s FILE, --configfile=FILE
Configuration file
-d DEBUGLEVEL, --debuglevel=DEBUGLEVEL
debug level
--option=OPTION set smb.conf option from command line
--realm=REALM set the realm name
Credentials Options:
--simple-bind-dn=DN
DN to use for a simple bind
--password=PASSWORD
Password
-U USERNAME, --username=USERNAME
Username
-W WORKGROUP, --workgroup=WORKGROUP
Workgroup
-N, --no-pass Don't ask for a password
-k KERBEROS, --kerberos=KERBEROS
Use Kerberos
--ipaddress=IPADDRESS
IP address of server
-P, --machine-pass Use stored machine account password
Version Options:
-V, --version Display version number
Run Code Online (Sandbox Code Playgroud)
我建议你这个程序:
# 1)
# In Windows
# Go to one shared folder/file and change the permissions as desired
#2)
# In Linux
# Get infos of the ACLs of the directory/file you just set up in SDDL format
#samba-tool ntacl get --as-sddl /path/to/my/share
O:LAG:BAD:P(A;OICI;0x001f01ff;;;BA)(A;OICI;0x001200a9;;;SO)(A;OICI;0x001f01ff;;;SY)(A;OICI;0x001200a9;;;AU)
#3)
# Use the SDDL parameter to change all the files you want with same ACL
# samba-tool ntacl set "O:LAG:BAD:P(A;OICI;0x001f01ff;;;BA)(A;OICI;0x001200a9;;;SO)(A;OICI;0x001f01ff;;;SY)(A;OICI;0x001200a9;;;AU)" /path/to/other/files
Run Code Online (Sandbox Code Playgroud)
细节:
samba-tool ntacl get --as-sddl [file/directory]
Run Code Online (Sandbox Code Playgroud)
将获取 SDDL 格式的 ACL 信息。有关 SDDL 的更多信息请参见此处
samba-tool ntacl set "[SDDL string]" [file/directory]
Run Code Online (Sandbox Code Playgroud)
将在文件/文件夹上应用指定的 ACL
该解决方案并不完美,但它可以帮助您。
关于 samba-tool 命令: https://www.samba.org/samba/docs/man/manpages-3/samba-tool.8.html
Samba 邮件列表的相关问题: https://lists.samba.org/archive/samba-technical/2011-October/079820.html