web-dev-qa-db-ja.com

ディレクトリにアクセス許可を設定するには、すべてのサブディレクトリへのアクセス許可を継承しますか?

* nixディレクトリにアクセス許可を設定して、サブディレクトリが作成されるときに、すべてのアクセス許可を親ディレクトリとしてサブディレクトリが作成されるようにする方法はありますか?


following、 がありますが、私が求めていることをすべて実行しているわけではないようです。

ほとんどのシステムでは、ディレクトリのset-group-IDビットが設定されている場合、新しく作成されたサブファイルはディレクトリと同じグループを継承し、新しく作成されたサブディレクトリは親ディレクトリのset-group-IDビットを継承します。一部のシステムでは、ディレクトリのset-user-IDビットが、新しいサブファイルの所有権と新しいサブディレクトリのset-user-IDビットに同様の影響を及ぼします。これらのメカニズムにより、chmodまたはchownを使用して新しいファイルを共有する必要性が少なくなるため、ユーザーはファイルをより簡単に共有できます。

3
boardrider

サブフォルダーが作成されると、新しいサブフォルダーのアクセス許可は次のように定義されます。

  1. ユーザーのプロパティがディレクトリを作成しました:

    a。ユーザーID

    b。グループID

  2. 定義されたumask

  3. 親フォルダdefault ACL(存在する場合)

注:詳細については、 acl manを参照してください。

オブジェクトの作成とデフォルトのACL

ファイルオブジェクトのアクセスACLは、オブジェクトがcreat()、mkdir()、mknod()、mkfifo()、またはopen()関数のいずれかで作成されるときに初期化されます。デフォルトのACLがディレクトリに関連付けられている場合、ファイルオブジェクトを作成する関数のmodeパラメータとディレクトリのデフォルトのACLを使用して、新しいオブジェクトのACLが決定されます。

1。新しいオブジェクトは、含まれているディレクトリのデフォルトACLをアクセスACLとして継承します。

2。ファイルパーミッションビットに対応するアクセスACLエントリは、modeパラメータで指定されたパーミッションに含まれていないパーミッションを含まないように変更されています。

デフォルトのACLがディレクトリに関連付けられていない場合、ファイルオブジェクトを作成する関数のmodeパラメータとファイル作成マスク(umask(2)を参照)を使用して、新しいオブジェクトのACLを決定します。 :

  1. 新しいオブジェクトには、タグタイプACL_USER_OBJ、ACL_GROUP_OBJ、およびACL_OTHERのエントリを含むアクセスACLが割り当てられます。これらのエントリのアクセス許可は、ファイル作成マスクで指定されたアクセス許可に設定されます。

  2. ファイル許可ビットに対応するアクセスACLエントリは、modeパラメータで指定された許可に含まれていない許可が含まれないように変更されています。

デフォルトのACLを設定する方法の説明 このQ&Aからコピーされました

chmod g+s <directory>  //set gid 
setfacl -d -m g::rwx /<directory>  //set group to rwx default 
setfacl -d -m o::rx /<directory>   //set other

次に、次のことを確認できます。

getfacl /<directory>

出力:

# file: ../<directory>/
# owner: <user>
# group: media
# flags: -s-
user::rwx
group::rwx
other::r-x
default:user::rwx
default:group::rwx
default:other::r-x

umaskの詳細については、 mask manを参照してください。

   umask() sets the calling process's file mode creation mask (umask) to
   mask & 0777 (i.e., only the file permission bits of mask are used),
   and returns the previous value of the mask.

   The umask is used by open(2), mkdir(2), and other system calls that
   create files to modify the permissions placed on newly created files
   or directories.  Specifically, permissions in the umask are turned
   off from the mode argument to open(2) and mkdir(2).

   Alternatively, if the parent directory has a default ACL (see
   acl(5)), the umask is ignored, the default ACL is inherited, the
   permission bits are set based on the inherited ACL, and permission
   bits absent in the mode argument are turned off.  For example, the
   following default ACL is equivalent to a umask of 022:

       u::rwx,g::r-x,o::r-x

   Combining the effect of this default ACL with a mode argument of 0666
   (rw-rw-rw-), the resulting file permissions would be 0644 (rw-
   r--r--).

   The constants that should be used to specify mask are described under
3
Yaron