1.7. Setting up a Samba file share that uses POSIX ACLs
As a Linux service, Samba supports shares with POSIX ACLs. They enable you to manage permissions locally on the Samba server using utilities, such as chmod. If the share is stored on a file system that supports extended attributes, you can define ACLs with multiple users and groups.
If you need to use fine-granular Windows ACLs instead, see Setting up a share that uses Windows ACLs.
Parts of this section were adopted from the Setting up a Share Using POSIX ACLs documentation published in the Samba Wiki. License: CC BY 4.0. Authors and contributors: See the history tab on the Wiki page.
1.7.1. Adding a share that uses POSIX ACLs 링크 복사링크가 클립보드에 복사되었습니다!
You can create a share named example that provides the content of the /srv/samba/example/ directory and uses POSIX ACLs.
Prerequisites
Samba has been set up in one of the following modes:
Procedure
Create the directory if it does not exist. For example:
# mkdir -p /srv/samba/example/If you run SELinux in
enforcingmode, set thesamba_share_tcontext on the directory:# semanage fcontext -a -t samba_share_t "/srv/samba/example(/.*)?" # restorecon -Rv /srv/samba/example/Set file system ACLs on the directory. For details, see:
Add the example share to the
/etc/samba/smb.conffile. For example, to add the share write-enabled:[example] path = /srv/samba/example/ read only = no참고Regardless of the file system ACLs; if you do not set
read only = no, Samba shares the directory in read-only mode.Verify the
/etc/samba/smb.conffile:# testparmOpen the required ports and reload the firewall configuration using the
firewall-cmdutility:# firewall-cmd --permanent --add-service=samba # firewall-cmd --reloadRestart the
smbservice:# systemctl restart smb
1.7.2. Setting standard Linux ACLs on a Samba share that uses POSIX ACLs 링크 복사링크가 클립보드에 복사되었습니다!
The standard ACLs on Linux support setting permissions for one owner, one group, and for all other undefined users. You can use the chown, chgrp, and chmod utility to update the ACLs. For more information, refer to the chown(1) and chmod(1) man pages on your system. If you require precise control, then you use the more complex POSIX ACLs, see
Setting extended ACLs on a Samba share that uses POSIX ACLs.
The following procedure sets the owner of the /srv/samba/example/ directory to the root user, grants read and write permissions to the Domain Users group, and denies access to all other users.
Prerequisites
- The Samba share on which you want to set the ACLs exists.
Procedure
Run the following command to initialize the process:
# chown root:"Domain Users" /srv/samba/example/ # chmod 2770 /srv/samba/example/참고Enabling the set-group-ID (SGID) bit on a directory automatically sets the default group for all new files and subdirectories to that of the directory group, instead of the usual behavior of setting it to the primary group of the user who created the new directory entry.
1.7.3. Setting extended ACLs on a Samba share that uses POSIX ACLs 링크 복사링크가 클립보드에 복사되었습니다!
If the file system the shared directory is stored on supports extended ACLs, you can use them to set complex permissions. Extended ACLs can contain permissions for multiple users and groups.
Extended POSIX ACLs enable you to configure complex ACLs with multiple users and groups. However, you can only set the following permissions:
- No access
- Read access
- Write access
- Full control
If you require the fine-granular Windows permissions, such as Create folder / append data, configure the share to use Windows ACLs. See Setting up a share that uses Windows ACLs.
The following procedure shows how to enable extended ACLs on a share. Additionally, it contains an example about setting extended ACLs.
Prerequisites
- The Samba share on which you want to set the ACLs exists.
Procedure
Enable the following parameter in the share’s section in the
/etc/samba/smb.conffile to enable ACL inheritance of extended ACLs:inherit acls = yesFor details, see the parameter description in the
smb.conf(5) man page.Restart the
smbservice:# systemctl restart smb- Set the ACLs on the directory. For example:
예 1.2. Setting Extended ACLs
The following procedure sets read, write, and execute permissions for the Domain Admins group, read, and execute permissions for the Domain Users group, and deny access to everyone else on the /srv/samba/example/ directory:
Disable auto-granting permissions to the primary group of user accounts:
# setfacl -m group::--- /srv/samba/example/ # setfacl -m default:group::--- /srv/samba/example/The primary group of the directory is additionally mapped to the dynamic
CREATOR GROUPprincipal. When you use extended POSIX ACLs on a Samba share, this principal is automatically added and you cannot remove it.Set the permissions on the directory:
Grant read, write, and execute permissions to the
Domain Adminsgroup:# setfacl -m group:"DOMAIN\Domain Admins":rwx /srv/samba/example/Grant read and execute permissions to the
Domain Usersgroup:# setfacl -m group:"DOMAIN\Domain Users":r-x /srv/samba/example/Set permissions for the
otherACL entry to deny access to users that do not match the other ACL entries:# setfacl -R -m other::--- /srv/samba/example/
These settings apply only to this directory. In Windows, these ACLs are mapped to the
This folder onlymode.To enable the permissions set in the previous step to be inherited by new file system objects created in this directory:
# setfacl -m default:group:"DOMAIN\Domain Admins":rwx /srv/samba/example/ # setfacl -m default:group:"DOMAIN\Domain Users":r-x /srv/samba/example/ # setfacl -m default:other::--- /srv/samba/example/With these settings, the
This folder onlymode for the principals is now set toThis folder, subfolders, and files.
Samba maps the permissions set in the procedure to the following Windows ACLs:
| Principal | Access | Applies to |
|---|---|---|
| Domain\Domain Admins | Full control | This folder, subfolders, and files |
| Domain\Domain Users | Read & execute | This folder, subfolders, and files |
|
| None | This folder, subfolders, and files |
| owner (Unix User\owner) [b] | Full control | This folder only |
| primary_group (Unix User\primary_group) [c] | None | This folder only |
| Full control | Subfolders and files only | |
| None | Subfolders and files only | |
[a]
Samba maps the permissions for this principal from the other ACL entry.
[b]
Samba maps the owner of the directory to this entry.
[c]
Samba maps the primary group of the directory to this entry.
[d]
On new file system objects, the creator inherits automatically the permissions of this principal.
[e]
Configuring or removing these principals from the ACLs not supported on shares that use POSIX ACLs.
[f]
On new file system objects, the creator’s primary group inherits automatically the permissions of this principal.
| ||