複数のメンバー、複数のグループで共有可能なフォルダを作成する
&size(10){member serverの共有フォルダに、windows操作でコントロール可能なサブフォルダを用意してみる};

参照先 [[https://wiki.samba.org/index.php/Shares_with_POSIX_ACLs>+https://wiki.samba.org/index.php/Shares_with_POSIX_ACLs]]
[[https://wiki.samba.org/index.php/Setting_up_a_Share_Using_Windows_ACLs>+https://wiki.samba.org/index.php/Setting_up_a_Share_Using_Windows_ACLs]]
&ref(2015y11m26d_223132255.png,nolink,noborder);
NFSはmember serverでsmb.confや/shareのACLsを操作して共有フォルダを提供する。


***member serverを作る [#oe9ce43f]
まずはNFSマシンをmember serverに仕立てる。
/etc/hostsと/etc/resolv.confを調整して、
#code(nonumber){{
[root@nfs ~]# vi /etc/hosts
127.0.0.1    localhost.localdomain localhost
192.168.0.11 nfs.sybyl.local nfs

[root@nfs ~]# cat /etc/resolv.conf
# Generated by NetworkManager
search sybyl.local
nameserver 192.168.0.3

[root@nfs ~]#
}}
次に、sambaをインストールしてmember serverにさせます。
[[samba/Linux参加]]で示した sssd による方法と、[[samba/Linux参加/winbindd]]のwinbindによる方法がありますが、
ここでは winbinid の方法で参加させてみます。

#code(nonumber){{
[root@nfs ~]# yum install samba samba-winbind      <-- yumのパッケージを利用します
[root@nfs ~]# vi /etc/samba/smb.conf
[global]
  workgroup = SYBYL
  security = ADS
  realm = SYBYL.LOCAL
  idmap config SYBYL:backend = ad
  idmap config SYBYL:range = 1000-30000
  idmap config SYBYL:unix_nss_info = yes  <-- backendが[ad]の際、shellやhomedirの値も利用する
  idmap config *:range = 30001-30010
  idmap config *:backend = tdb
  winbind nss info = rfc2307
  winbind use default domain = true
  vfs objects = acl_xattr
  map acl inherit = yes
  store dos attributes = yes

[root@nfs ~]# net ads join osName=CentOS osVer=7.4 -Uadministrator
Enter administrator's password:
Using short domain name -- SYBYL
Joined 'NFS' to dns domain 'sybyl.local'
[root@nfs ~]#
}}
これでSYBYLドメインに参加した。
認証およびユーザ情報を winbind 経由で引くには authconfig で設定を行う

#code(nonumber){{
[root@nfs ~]# authconfig --enablewinbind --enablewinbindauth --update
}}
これでデーモン winbindd が起動します。
確認のためユーザ情報を引いて見ます。
#code(nonumber){{
[root@nfs ~]# getent passwd illya
illya:*:1002:3000:Illyasviel von Einzbern:/home/illya:/bin/bash

[root@nfs ~]# getent group fate
fate:x:2000:

[root@nfs ~]#
}}


一方でADDCにてUID,GIDを定義していないユーザは引けない。
#code(nonumber){{
[root@nfs ~]# getent passwd administrator
[root@nfs ~]# getent group "domain admins"
}}
&color(white,blue){留意};
idmapのbackendを「rid」に変更すれば、このようなUID,GIDがないアカウントに対しても自動的にIDを振ってくれます。
しかしそれはこのmember serverだけで有効なUID,GIDである。nfsとして他のマシン(windows/Linux)と共有すると同じユーザなのに
参照できないファイル、フォルダが作られる可能性が生じる。

&size(10){一応、「rid」だからたぶん大丈夫だと思うけど、ユーザ作成時にUID,GIDの定義が不可で既存のリソースとの連携に支障がありえる};

っで「共有フォルダ」の作成をwindows操作で作って、グループ、ユーザに権限をアサインするには
「administrator」と「domain admins」のUID,GIDを定義する必要がある。

***「Administrator」と「Domain Admins」のUID,GID定義 [#l78a0efd]
windwosマシンからドメインのAdministratorでログインして、「ActiveDirectoryユーザとコンピュータ」から定義します。
まず「Domain Admins」を開き、下記のように定義します。
&ref(2017y10m02d_140913067.png,nolink);

その後、「Administrator」を開き、これも下記のように定義します。
&ref(2017y10m02d_140949955.png,nolink);


***共有フォルダを作る(ACL制御) [#oe2a5dd4]
まずは管理者権限を有するユーザがwindows画面で操作して、作ったフォルダを特定のユーザだけ利用できるようにしてみる。
まず管理者権限を有するユーザにSeDiskOperatorPrivilege権限を与える
現在このSeDiskOperatorPrivilege権限を有しているのは
#code(nonumber){{
[root@nfs ~]# net rpc rights list privileges SeDiskOperatorPrivilege  -U"SYBYL\Administrator"
Enter SYBYL\Administrator's password:
SeDiskOperatorPrivilege:
  BUILTIN\Administrators

[root@nfs ~]#
}}

から「Administrators」グループが所有している。これに「Domain Admin」グループも追加します
#code(nonumber){{
[root@nfs ~]# net rpc rights grant "SYBYL\Domain Admins" SeDiskOperatorPrivilege -U "SYBYL\administrator"
Enter SYBYL\administrator's password:
Successfully granted rights.

[root@nfs ~]#
}}

そして管理者権限を有するユーザがwindows画面で操作して、作ったフォルダを特定のユーザだけ利用できるようにしてみる。
smb.confに共有フォルダの場所定義を追加して、その設定を反映させる
#code(nonumber){{
[root@nfs ~]# mkdir -p /share
[root@nfs ~]# ls -ld /share
drwxr-xr-x 2 root root 6 10月  2 20:45 /share

[root@nfs ~]# cat <<_EOF_>>/etc/samba/smb.conf
[share]
  path=/share/
  read only=no
  inherit acls = yes
_EOF_
[root@nfs ~]# smbcontrol all reload-config
}}
ここでwindowsPCからドメインのadministratorであっても\\nfs\shareにフォルダは追加できない。エラーになります。
ここからACLを付与していきます。
#code(nonumber){{
[root@nfs ~]# setfacl -m group::--- /share/
[root@nfs ~]# setfacl -m default:group::--- /share/
[root@nfs ~]# setfacl -m group:"SYBYL\Domain Admins":rwx /share/
[root@nfs ~]# setfacl -m group:"SYBYL\Domain Users":r-x /share/
[root@nfs ~]# setfacl -R -m other::--- /share/
}}
ここで/share/のACLを確認してみます。
#code(nonumber){{
[root@nfs ~]# cd /
[root@nfs /]# getfacl share
# file: share
# owner: root
# group: root
user::rwx
group::---
group:domain\040users:r-x
group:domain\040admins:rwx
mask::rwx
other::---
default:user::rwx
default:group::---
default:other::r-x

[root@nfs /]#
}}
ここで再度windowsPCから \\nfs\share に新規フォルダ「emiya」を作成する。
この作ったフォルダ「emiya」のプロパティを開いて、「セキュリティ」タブから利用するユーザを追加して、
権限に「フルコントロール」を与える。
&ref(2017y10m02d_210208041.png,nolink);
これで、フォルダ「emiya」はユーザ「illya」と「saber」が自由に利用できる。


***共有フォルダを作る(UNIX ACL編) [#c7b19b0d]
従来からある方法。こっちの方が単純明快。
グループ fate に所属するユーザだけが利用できる共有フォルダを作ってみる
#code(nonumber){{
[root@nfs ~]# mkdir -p /fate
[root@nfs ~]# chmod 770 /fate
[root@nfs ~]# chgrp fate /fate
[root@nfs ~]# cat <<_EOF_>>/etc/samba/smb.conf
[fate]
  path=/fate/
  read only = no
  valid users = +SYBYL\fate
_EOF_
[root@nfs ~]# smbcontrol all reload-config
}}
この場合、ドメインのAdministratorで調整は出来ません。。。
samba member serverマシン内でsetfaclコマンドを駆使して調整するしかないです。
&size(10){ユーザ単位でACLを行う場合はかなり面倒かと思う};

***書き込むユーザは別々だけど、同一のユーザ(nobody)で保存させるには [#za18f329]
まず共有フォルダを用意して、そのフォルダの所有権を代える。ここではnobodyのgroupを設定
#code(nonumber){{
[root@nfs ~]# mkdir -p /data
[root@nfs ~]# chmod 770 /data
[root@nfs ~]# chgrp nobody /data
[root@nfs ~]# cat <<_EOF_>>/etc/samba/smb.conf
[data]
  path=/data/
  read only = no
  force user = nobody
  force group= nobody
_EOF_
[root@nfs ~]# smbcontrol all reload-config
}}
これでドメインユーザなら誰でも \\nfs\data\ にアクセスできて、そこに置いたファイルは nobody:nobody の所有物になる。

***ドメインに登録されていないユーザでも書き込める共有フォルダを用意する [#n8f4b993]
パスワードなしで共有可能なフォルダ。
具体的には
-ドメインに参加していないマシンから、ドメインに登録していないユーザでも利用できる共有フォルダ
-ドメインに参加しているマシンで、ローカルアカウント(ドメインユーザ名以外)でも利用できる共有フォルダ

を作る。先ずフォルダを用意して、誰でも書き込み可能とする
&color(red){*};&size(10){後述の特定のユーザ所有物(nobody)にしたい場合、chown nobody /share/imageとする};
#code(nonumber){{
[root@nfs ~]# mkdir /image
[root@nfs ~]# chmod 777 /image
[root@nfs ~]# vi /etc/samba/smb.conf
[global]
 :
 map to guest = Bad Password
 guest account = nobody
 :
[image]
  path=/image/
  read only = no
  guest ok = yes
[root@nfs ~]# smbcontrol all reload-config
}}
&color(red){*};&size(10){共有フォルダに置かれたフォルダ、ファイルの所有者は認証を経ていればそのユーザの所有物になる};
&size(10){認証を経由しないならnobodyの所有となる};
&size(10){特定のユーザの所有物に固定したいなら、force user、force groupを適用する};
&color(white,blue){要注意}; &color(green){''map to guest''};は&color(darkorchid){''ActiveDirectoryドメインコントローラ''};では機能しない。メンバサーバのみ有効
参照:[[https://wiki.samba.org/index.php/FAQ#How_Do_I_Enable_Guest_Access_to_a_Share_on_a_Samba_AD_DC.3F>+https://wiki.samba.org/index.php/FAQ#How_Do_I_Enable_Guest_Access_to_a_Share_on_a_Samba_AD_DC.3F]]
既に smb が稼働しているのなら
#code(nonumber){{
[root@nfs ~]# smbcontrol all reload-config
}}
と設定ファイルを再読み込みする。
1

トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS