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 では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

Theme

© 2026 Red Hat
トップに戻る