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

  1. Create the directory if it does not exist. For example:

    # mkdir -p /srv/samba/example/
  2. If you run SELinux in enforcing mode, set the samba_share_t context on the directory:

    # semanage fcontext -a -t samba_share_t "/srv/samba/example(/.*)?"
    # restorecon -Rv /srv/samba/example/
  3. Set file system ACLs on the directory. For details, see:

  4. Add the example share to the /etc/samba/smb.conf file. 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.

  5. Verify the /etc/samba/smb.conf file:

    # testparm
  6. Open the required ports and reload the firewall configuration using the firewall-cmd utility:

    # firewall-cmd --permanent --add-service=samba
    # firewall-cmd --reload
  7. Restart the smb service:

    # 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

  1. Enable the following parameter in the share’s section in the /etc/samba/smb.conf file to enable ACL inheritance of extended ACLs:

    inherit acls = yes

    For details, see the parameter description in the smb.conf(5) man page.

  2. Restart the smb service:

    # systemctl restart smb
  3. 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:

  1. 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 GROUP principal. When you use extended POSIX ACLs on a Samba share, this principal is automatically added and you cannot remove it.

  2. Set the permissions on the directory:

    1. Grant read, write, and execute permissions to the Domain Admins group:

      # setfacl -m group:"DOMAIN\Domain Admins":rwx /srv/samba/example/
    2. Grant read and execute permissions to the Domain Users group:

      # setfacl -m group:"DOMAIN\Domain Users":r-x /srv/samba/example/
    3. Set permissions for the other ACL 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 only mode.

  3. 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 only mode for the principals is now set to This folder, subfolders, and files.

Samba maps the permissions set in the procedure to the following Windows ACLs:

Expand
PrincipalAccessApplies to

Domain\Domain Admins

Full control

This folder, subfolders, and files

Domain\Domain Users

Read & execute

This folder, subfolders, and files

Everyone [a]

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

CREATOR OWNER [d] [e]

Full control

Subfolders and files only

CREATOR GROUP [e] [f]

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.
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2026 Red Hat
맨 위로 이동