特定のユーザーがディレクトリとすべてのサブディレクトリへのrwxアクセス権を持つようにディレクトリのACLを設定するにはどうすればよいですか。

特定のユーザーがディレクトリとすべてのサブディレクトリへのrwxアクセス権を持つようにディレクトリのACLを設定するにはどうすればよいですか。

注:質問を明確にするために空のディレクトリから始めるとします。空でない場合は、その-Rオプションが利用可能であることがわかりますsetfacl

私が試したことは次のとおりです(/tmp/badDirユーザーが作成して所有するときにユーザーにアクセスを許可しようとしています)。meotheruser

$ sudo -u otheruser mkdir /tmp/badDir
$ sudo setfacl -dm "user:me:rwX" /tmp/badDir
$ sudo -u otheruser touch /tmp/badDir/baz
$ touch /tmp/badDir/baz

だから一見すると大丈夫に見えます。

ただし、他の必要な操作を試してみると、次のような結果が出ることは予想されません。

$ touch /tmp/badDir
touch: setting times of '/tmp/badDir': Permission denied
$ touch /tmp/badDir/foo
touch: cannot touch '/tmp/badDir/foo': Permission denied

したがって、作成したディレクトリのファイルを変更することはできますが、ディレクトリメタデータを変更したり、ディレクトリにファイルを作成したりすることはできませんotheruser

ls合計の出力は次getfaclのとおりです。

$ ls -last /tmp/badDir
total 0
0 drwxrwxrwt  1 root     root     1794 Jun 22 09:22 ..
0 -rw-rw-r--+ 1 otheruser otheruser    0 Jun 22 09:22 baz
0 drwxr-xr-x+ 1 otheruser otheruser    6 Jun 22 09:22 .


$ getfacl /tmp/badDir
getfacl: Removing leading '/' from absolute path names
# file: tmp/badDir
# owner: otheruser
# group: otheruser
user::rwx
group::r-x
other::r-x
default:user::rwx
default:user:me:rwx
default:group::r-x
default:mask::rwx
default:other::r-x

$ getfacl /tmp/badDir/baz
getfacl: Removing leading '/' from absolute path names
# file: tmp/badDir/baz
# owner: otheruser
# group: otheruser
user::rw-
user:me:rwx     #effective:rw-
group::r-x          #effective:r--
mask::rw-
other::r--

アップデート1

確認のためにACLを有効にしました。

$ sudo tune2fs -l /dev/disk/by-uuid/8d6bba7d-63c1-4406-855a-f56987dea98e | grep acl                                     
Default mount options:    user_xattr acl

ベストアンサー1

同僚が私にディレクトリに対する権限を個別に設定する必要があると指摘しました。このディレクトリに生成されたファイルに対するデフォルトの権限。したがって、次の両方が必要です。

sudo setfacl -d -m "user:me:rwX" /tmp/badDir
sudo setfacl    -m "user:me:rwX" /tmp/badDir # Notice the missing -d

おすすめ記事