POSIX ACLs を利用して共有を設定する

提供: 雑廉堂Wiki
2019年3月1日 (金) 20:50時点におけるMeisina04 (トーク | 投稿記録)による版 (Setting Share Permissions)

はじめに

SambaはPOSIXアクセス制御リスト(ACL)との共有をサポートしています。 それらを使用すると、UNIXユーティリティを使用してSambaホスト上でローカルに権限を管理できます。 共有のファイルシステムが拡張属性をサポートしている場合は、WindowsのACLと同様に、拡張POSIX ACLを使用して複数のユーザーおよびグループをACLに設定できます。 詳細は拡張ACLの設定をご覧ください。 細かいWindows ACLが必要な場合は、代わりにWindows ACLを使用して共有を設定してください。 詳細については、 Windows ACLを使用した共有の設定を参照してください。

Sambaは、以下のPOSIX ACLとの共有をサポートしています。

  • ドメインメンバー
  • NT4 PDCとBDC
  • スタンドアロンホスト

ホストの準備

共有を作成する前に、Sambaをセットアップしてください。 詳しくは、以下を参照してください。



ファイルを実行可能にする

デフォルト設定を使用すると、POSIX x-bitが設定されている場合、ユーザはSamba共有上で*.exe*.batなどのファイルのみを実行できます。。たとえば、次のファイルはrootユーザーおよびDomain Usersグループのメンバーに対して実行可能です:

-rwxr-x--- 1 root "Domain Users" 133160 1. Jan 00:00 /srv/samba/Demo/example.exe

シナリオによっては、xビットが設定されているかどうかにかかわらず、ユーザーが共有上のすべてのファイルを実行できるようにする必要があります。 有効にするには、smb.conf[global]セクションで設定します。:

acl allow execute always = yes

共有を追加する

共有名Demoを使用して/srv/samba/Demo/ディレクトリを共有するには、次の手順を実行します:

  • ディレクトリを作成:
# mkdir -p /srv/samba/Demo/
  • 共有の定義[Demo]smb.confファイルに追加します。:
[Demo]
       path = /srv/samba/Demo/
       read only = no
これらは、書き込み可能な共有を設定するために必要な最小限のパラメータです。 必要に応じて、共有権限を設定できます。 詳細は共有アクセス許可の設定をご覧ください。
  • Sambaの設定をリロード:
# smbcontrol all reload-config

ACLを設定

標準UNIX ACLを設定

UNIXオペレーティングシステムの標準アクセス制御リスト(ACL)は、1人の所有者、1つのグループ、およびその他すべての人(その他)に対するアクセス許可の設定をサポートしています。 ディレクトリに複数のACLを設定する必要がある場合は、拡張ACLの設定を参照してください。

例えば、/srv/samba/Demo/ディレクトリの所有者をrootにするには、所有者とDomain Usersグループに読み書きの許可を付与し、そして他のすべてのユーザーに対してはアクセスを拒否します。次のように入力してください:

# chmod 2770 /srv/samba/Demo/
# chown root:"Domain Users" /srv/samba/Demo/

For further details about the permissions, see the chmod(1) and chown(1) man page.

拡張ACLを設定

ファイルシステムが拡張アクセス制御リスト(ACL)をサポートしている場合は、拡張POSIX ACLを使用できます。 WindowsのACLと同じように、ファイルやディレクトリ上の複数のユーザーやグループに権限を設定することができます。 ただし、POSIX ACLは次の一般的な権限モードに制限されています:

  • None
  • Read
  • Write
  • Full control

たとえば、Domain Adminsグループに対する読み取り、書き込み、および実行権限を設定するには、Domain Usersグループに対する読み取りおよび実行権限を使用し、/srv/samba/Demo/ディレクトリで他のユーザー全員へのアクセスを拒否します:

  • inherit acls = yesパラメータを、その共有の設定に追加してください。例えば次のように入力してください:
[Demo]
       path = /srv/samba/Demo/
       read only = no
       inherit acls = yes
inherit acls = yesパラメータは拡張ACLのACLの継承を有効にします。詳細は、smb.confのマニュアルページのパラメータの説明を参照してください。
  • Samba をリロード:
# smbcontrol all reload-config
  • ディレクトリが拡張ACLをサポートするファイルシステムに格納されていることを確認します。 詳細については、ファイルシステムのサポートを参照してください。
  • ユーザーアカウントのプライマリグループに対するアクセス許可の自動付与を無効にします:
# setfacl -m group::--- /srv/samba/Demo/
# setfacl -m default:group::--- /srv/samba/Demo/
ディレクトリのプライマリグループは、動的なCREATOR GROUPプリンシパルにさらにマッピングされます。 Samba共有で拡張POSIX ACLを使用する場合、この主体は自動的に追加され、削除することはできません。CREATOR GROUPプリンシパルの詳細については、Well-known security identifiers in Windows operating systemsを参照してください。
  • ディレクトリにアクセス許可を設定:
  • Domain Adminsグループに読み取り、書き込み、および実行権限を付与します:
# setfacl -m group:"SAMDOM\Domain Admins":rwx /srv/samba/Demo/
  • Domain Usersグループに読み取り権限と実行権限を付与します:
# setfacl -m group:"SAMDOM\Domain Users":r-x /srv/samba/Demo/
  • 他のACLエントリと一致しないユーザーへのアクセスを拒否するには、other ACLエントリにアクセス許可を設定します:
# setfacl -R -m other::--- /srv/samba/Demo/
これらの設定はディレクトリ自体にのみ適用されます。 Windowsでは、これはこのフォルダのみに変換されます。
  • 前の手順で設定したのと同じ権限が、このディレクトリに作成された新しいファイルシステムオブジェクトに継承されるように設定するには、次のように入力します:
# setfacl -m default:group:"SAMDOM\Domain Admins":rwx /srv/samba/Demo/
# setfacl -m default:group:"SAMDOM\Domain Users":r-x /srv/samba/Demo/
# setfacl -m default:other::--- /srv/samba/Demo/
この設定で、プリンシパルに対するこのフォルダのみモードがこのフォルダ、サブフォルダおよびファイルに変更されます。

前の手順で設定したACLは、次のWindows ACLにマッピングされます:

Principal Access Applies to Comments
SAMDOM\Domain Admins Full control This folder, subfolders, and files
SAMDOM\Domain Users Read & execute This folder, subfolders, and files
Everyone None This folder, subfolders, and files Samba maps the permissions for this principal from the UNIX other ACL entry.
directory_owner (Unix User\directory_owner) * Full control This folder only Samba maps the owner of the directory to this entry.
directory_primary_group (Unix User\directory_primary_group) * None This folder only Samba maps the primary group of the directory to this entry.
CREATOR OWNER * Full control Subfolders and files only On new file system objects, the creator inherits automatically the permissions of this principal.
CREATOR GROUP * None Subfolders and files only On new file system objects, the creator's primary group inherits automatically the permissions of this principal.

* これらのプリンシパルをACLから構成または削除することは、Windows ACLを使用している場合にのみサポートされます。 詳細については、Windows ACLs を利用して共有を設定するを参照してください。

詳しくは、setfaclのマニュアルページを参照してください。

共有権限を設定する

オプション: Sambaはユーザーが接続したときに検証される各共有に許可を設定することを可能にします。

共有上のコンテンツへのアクセスは、ファイルシステムのアクセス制御リスト(ACL)を使用して制御されます。 詳細は、 Samba共有へのPOSIX ACLの設定を参照してください。

Optional: Samba enables you to set permissions on each share which are validated when a user connects.

Access to the content on a share, is controlled using file system access control lists (ACL). For details, see Setting POSIX ACLs on a Samba Share


Configuring User and Group-based Share Access

Share-based access control enables you to grant or deny access to a share for certain users and groups. For example, to enable all members of the Domain Users group to access a share while access is denied for the example_user account, add the following parameters to the share's configuration:

       valid users = +SAMDOM\"Domain Users"
       invalid users = SAMDOM\example_user

The invalid users parameter has a higher priority than the valid users parameter. For example, if the example_user account is a member of the Domain Users group, access is denied for this account in the previous example.

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


Configuring Host-based Share Access

Host-based access control enables you to grant or deny access to a share based on host names, IP addresses, or IP ranges. For example, to enable the 127.0.0.1 IP address, the 10.99.0.0/24 IP range, and the GoodHost host name to access a share, and additionally deny access for the BadHost host name, add the following parameters to the share's configuration:

       hosts allow = 127.0.0.1 10.99.0.0/24 GoodHost
       hosts deny = BadHost

The hosts deny parameter has a higher priority than the hosts allow parameter. For example, if BadHost resolves to an IP address that is listed in the hosts allow parameter, access to this host is denied.

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