setfacl 2.2.49 -- set file access control lists Usage: setfacl [-bkndRLP] { -m|-M|-x|-X ... } file ... -m, --modify=acl modify the current ACL(s) of file(s) -M, --modify-file=file read ACL entries to modify from file -x, --remove=acl remove entries from the ACL(s) of file(s) -X, --remove-file=file read ACL entries to remove from file -b, --remove-all remove all extended ACL entries -k, --remove-default remove the default ACL --set=acl set the ACL of file(s), replacing the current ACL --set-file=file read ACL entries to set from file --mask do recalculate the effective rights mask -n, --no-mask don't recalculate the effective rights mask -d, --default operations apply to the default ACL -R, --recursive recurse into subdirectories -L, --logical logical walk, follow symbolic links -P, --physical physical walk, do not follow symbolic links --restore=file restore ACLs (inverse of `getfacl -R') --test test mode (ACLs are not modified) -v, --version print version and exit -h, --help this help text
setfacl 2.2.49 -- set file access control lists Usage: setfacl [-bkndRLP] { -m|-M|-x|-X ... } file ... -m, --modify=acl modify the current ACL(s) of file(s) -M, --modify-file=file read ACL entries to modify from file -x, --remove=acl remove entries from the ACL(s) of file(s) -X, --remove-file=file read ACL entries to remove from file -b, --remove-all remove all extended ACL entries -k, --remove-default remove the default ACL --set=acl set the ACL of file(s), replacing the current ACL --set-file=file read ACL entries to set from file --mask do recalculate the effective rights mask -n, --no-mask don't recalculate the effective rights mask -d, --default operations apply to the default ACL -R, --recursive recurse into subdirectories -L, --logical logical walk, follow symbolic links -P, --physical physical walk, do not follow symbolic links --restore=file restore ACLs (inverse of `getfacl -R') --test test mode (ACLs are not modified) -v, --version print version and exit -h, --help this help text
SETFACL(1) Access Control Lists SETFACL(1)
名前
setfacl - ファイルのアクセス制御リスト (access control list) を設定する
書式
setfacl [-bkndRLPvh] [{-m|-x} acl_spec] [{-M|-X} acl_file] file ...
setfacl --restore=file
説明
このユーティリティはファイルとディレクトリのアクセス制御リスト (Access
Control List, ACL) を設定する。コマンドラインでは、一連のコマンドの後に
ファイル群を指定する (さらに別の一連のコマンド、ファイル群、... を続 け
て指定することができる)。
オプション -m と -x は ACL がコマンドラインで指定されることを想定してい
る。複数の ACL エントリはコンマ文字 (‘,’) で区切られる。オプショ ン -M
と -X は ACL をファイルまたは標準入力から読み込む。 ACL エントリの書式
は、「ACL エントリ」のセクションで説明されている。
--set と --set-file オプションはファイルとディレクトリの ACL を設定する
。 以前の ACL は置き換えられる。この操作で指定される ACL エントリは、許
可 (permission) を含まなければならない。
-m (--modify) と -M (--modify-file) オプションはファイルとディレクト リ
の ACL を変更する。この操作で指定される ACL エントリは、許可を含まなけ
ればならない。
-x (--remove) と -X (--remove-file) オプションは ACL エントリを削除する
。 POSIXLY_CORRECT が定義されていない場合は、 perms フィールドを持たな
い ACL エントリだけが引き数として指定できる。
-M と -X オプションで (ACL を) ファイルから読み込む場合、 setfacl は
getfacl が生成した出力を受け付ける。 1 行には最大で 1 つの ACL エントリ
がある。シャープ記号 (‘#’) の後から行末まではコメントとして扱われる。
ACL をサポートしないファイルシステム上で setfacl を使用した場合、 set-
facl はファイルモード許可ビットを操作する。 ACL が許可ビットと完全には
合わない場合、 setfacl はファイルモード許可ビットを ACL に可能な限り 近
づ けるように変更し、標準エラー出力にエラーメッセージを書き出して、0 よ
り大きい終了状態で返る。
許可
ケーパビリティ (capability) CAP_FOWNER を持つファイル所有者とプロセスは
、ファイルの ACL を変更する権限が付与されている。これはファイルモードに
アクセスするのに必要な許可と類似している (現在の Linux シス テ ム で は
、CAP_FOWNER ケーパビリティを持つユーザは root のみである)。
オプション
-b, --remove-all
全ての拡張 ACL エントリを削除する。所有者・グループ・その他という基
本 (base) ACL エントリは保存される。
-k, --remove-default
デフォルト ACL を削除する。デフォルト ACL が存在しない場合、警告 は
出されない。
-n, --no-mask
実 効権 (effective right) マスクを再計算しない。 setfacl のデフォル
ト動作では、ACL マスクエントリが明示的に指定されない限り、 ACL マス
ク エ ン トリを再計算する。マスクエントリは所有グループ・指名ユーザ
(named user)・指名グループのエントリの全ての許可を結合したものに 設
定される (マスクエントリに影響を受けるエントリは、正にこれらである)
。
--mask
ACL マスクエントリが明示的に指定されている場合でも、実効権マスク を
再計算する (-n オプションを参照)。
-d, --default
全 て の操作をデフォルト ACL に適用する。入力セットに含まれる通常の
ACL エントリをデフォルト ACL エントリに昇格させる。入力セットに含ま
れるデフォルト ACL エントリは破棄される (これが起こった場合は警告を
出す)。
--restore=file
‘getfacl -R’ またはそれと同様なもので作成された許可のバックアップで
復 旧する。ディレクトリサブツリーの全ての許可が、この方法で復旧され
る。入力に所有者コメントまたはグループコメントが含まれていて、か つ
setfacl が root によって実行されている場合、全てのファイルの所有者
と所有グループも復旧される。この操作は ‘--test’ 以外のオプション と
併用できない。
--test
テ ストモード。ファイルの ACL を変更する代わりに、結果の ACL の一覧
を表示する。
-R, --recursive
全てのファイルとディレクトリに対して再帰的に操作を適用する。この オ
プションは ‘--restore’ と併用できない。
-L, --logical
論 理的に辿り、シンボリックリンクを辿る。デフォルトの動作では、シン
ボリックリンク引き数を辿り、サブディレクトリで見つかったシンボリ ッ
クリンクはスキップする。このオプションは ‘--restore’ と併用できない
。
-P, --physical
物理的に辿り、全てのシンボリックリンクをスキップする。シンボリッ ク
リンク引き数もスキップする。このオプションは ‘--restore’ と併用でき
ない。
--version
setfacl のバージョンを表示し、終了する。
--help
コマンドラインオプションを説明するヘルプを表示する。
-- コマンドラインオプションの終わり。残りの引き数は、たとえダッシュ 文
字で始まっていたとしても、ファイル名として解釈される。
- フ ァイル名引き数が 1 つのダッシュ文字である場合、 setfacl は標準入
力からファイルのリストを読み込む。
ACL エントリ
setfacl ユーティリティは以下の ACL エントリ書式を認識する (分かりやすい
ように空白を挿入してある):
[d[efault]:] [u[ser]:]uid [:perms]
指名ユーザの許可。 uid が空の場合は、ファイル所有者の許可。
[d[efault]:] g[roup]:gid [:perms]
指名グループの許可。 gid が空の場合は、所有者グループの許可。
[d[efault]:] m[ask][:] [:perms]
実効権マスク。
[d[efault]:] o[ther][:] [:perms]
その他の許可。
区切り文字と区切り文字以外の間の空白は無視される。
許 可 を含む正式な ACL エントリは、修正と設定の操作 (オプション -m, -M,
--set, --set-file) で使用される。 perms フィールドのないエントリは、 エ
ントリの削除 (オプション -x と -X) で使用される。
uid と gid には名前と数値のどちらも指定できる。
perms フィールド許可を表す文字の組み合わせである。読み込み (r), 書き込
み (w), 実行 (x) は、ファイルがディレクトリであるか何れかのユーザの実行
許 可 (X) が既にある場合にのみ実行される。文字の組合わせの代わりに、
perms フィールドを 8 進数 (0-7) にすることもできる。
自動的に作成されるエントリ
初期状態では、ファイルとディレクトリは所有者・グループ・その他という 3
つ の基本 ACL エントリを持つ。 ACL が有効であるためには満たさなければな
らない、いくつかのルールがある。
* 3 つの基本エントリは削除できない。これらの基本エントリ型のそれぞ れ
に対して、必ず 1 つのエントリがなければならない。
* ACL が指名ユーザエントリまたは指名グループオブジェクトを持つ場合、
実効権マスクも持たなければならない。
* ACL がデフォルト ACL エントリを持つ場合、 3 つのデフォルト ACL 基本
エントリ (デフォルト所有者・デフォルトグループ・デフォルトのその他)
が存在しなければならない。
* デフォルト ACL が指名ユーザエントリまたは指名グループオブジェクトを
持つ場合、デフォルト実効権マスクも持たなければならない。
ユーザがこれらのルールを確実に守るための助けとして、 setfacl は以下の条
件で既存のエントリからエントリを作成する:
* ACL が指名ユーザまたは指名グループのエントリを持ち、かつマスクエ ン
ト リが存在しない場合、グループエントリと同じ許可を持つマスクエント
リが作成される。 -n オプションが指定されない限り、マスクエントリ の
許 可は、そのマスクエントリの影響を受ける全ての許可を合わせたもの含
めるように、更に調整される (-n オプションの説明を参照すること)。
* デフォルト ACL エントリが作成され、かつデフォルト ACL が所有者・ 所
有グループ・その他のエントリを持たない場合、 ACL 所有者・所有グルー
プ・その他のエントリのコピーがデフォルト ACL に追加される。
* デフォルト ACL が指名ユーザまたは指名グループのエントリを持ち、かつ
マスクエントリが存在する場合、デフォルト ACL のグループエントリと同
じ許可を持つマスクエントリが追加される。 -n オプションが指定され な
い 限り、マスクエントリの許可は、そのマスクエントリの影響を受ける全
ての許可を合わせたもの含めるように、更に調整される (-n オプションの
説明を参照すること)。
例
追加のユーザの読み込みアクセスを許可する。
setfacl -m u:lisa:r file
全 てのグループと全ての指名ユーザの書き込みアクセスを (実効権マスクを使
って) 取り消す。
setfacl -m m::rx file
ファイルの ACL から指名グループエントリを削除する。
setfacl -x g:staff file
あるファイルの ACL を他にコピーする。
getfacl file1 | setfacl --set-file=- file2
アクセス ACL をデフォルト ACL にコピーする。
getfacl --access dir | setfacl -d -M- dir
POSIX 1003.1e DRAFT STANDARD 17 への準拠
環境変数 POSIXLY_CORRECT が定義されている場合、 getfacl のデフォルト の
動 作は、以下のように変わる。標準に準拠しない全てのオプションは無効にさ
れる。 ‘‘default:’’ プレフィックスは無効にされる。 -x と -X オプショ ン
は許可フィールドを受け付ける (しかし、無視する)。
著者
Andreas Gruenbacher,
SETFACL(1) Access Control Lists SETFACL(1)
NAME
setfacl - set file access control lists
SYNOPSIS
setfacl [-bkndRLPvh] [{-m|-x} acl_spec] [{-M|-X} acl_file] file ...
setfacl --restore=file
DESCRIPTION
This utility sets Access Control Lists (ACLs) of files and directories.
On the command line, a sequence of commands is followed by a sequence
of files (which in turn can be followed by another sequence of com-
mands, ...).
The options -m, and -x expect an ACL on the command line. Multiple ACL
entries are separated by comma characters (‘,’). The options -M, and -X
read an ACL from a file or from standard input. The ACL entry format is
described in Section ACL ENTRIES.
The --set and --set-file options set the ACL of a file or a directory.
The previous ACL is replaced. ACL entries for this operation must
include permissions.
The -m (--modify) and -M (--modify-file) options modify the ACL of a
file or directory. ACL entries for this operation must include permis-
sions.
The -x (--remove) and -X (--remove-file) options remove ACL entries. It
is not an error to remove an entry which does not exist. Only ACL
entries without the perms field are accepted as parameters, unless
POSIXLY_CORRECT is defined.
When reading from files using the -M, and -X options, setfacl accepts
the output getfacl produces. There is at most one ACL entry per line.
After a Pound sign (‘#’), everything up to the end of the line is
treated as a comment.
If setfacl is used on a file system which does not support ACLs, set-
facl operates on the file mode permission bits. If the ACL does not fit
completely in the permission bits, setfacl modifies the file mode per-
mission bits to reflect the ACL as closely as possible, writes an error
message to standard error, and returns with an exit status greater than
0.
PERMISSIONS
The file owner and processes capable of CAP_FOWNER are granted the
right to modify ACLs of a file. This is analogous to the permissions
required for accessing the file mode. (On current Linux systems, root
is the only user with the CAP_FOWNER capability.)
OPTIONS
-b, --remove-all
Remove all extended ACL entries. The base ACL entries of the owner,
group and others are retained.
-k, --remove-default
Remove the Default ACL. If no Default ACL exists, no warnings are
issued.
-n, --no-mask
Do not recalculate the effective rights mask. The default behavior
of setfacl is to recalculate the ACL mask entry, unless a mask
entry was explicitly given. The mask entry is set to the union of
all permissions of the owning group, and all named user and group
entries. (These are exactly the entries affected by the mask
entry).
--mask
Do recalculate the effective rights mask, even if an ACL mask entry
was explicitly given. (See the -n option.)
-d, --default
All operations apply to the Default ACL. Regular ACL entries in the
input set are promoted to Default ACL entries. Default ACL entries
in the input set are discarded. (A warning is issued if that hap-
pens).
--restore=file
Restore a permission backup created by ‘getfacl -R’ or similar. All
permissions of a complete directory subtree are restored using this
mechanism. If the input contains owner comments or group comments,
setfacl attempts to restore the owner and owning group. If the
input contains flags comments (which define the setuid, setgid, and
sticky bits), setfacl sets those three bits accordingly; otherwise,
it clears them. This option cannot be mixed with other options
except ‘--test’.
--test
Test mode. Instead of changing the ACLs of any files, the resulting
ACLs are listed.
-R, --recursive
Apply operations to all files and directories recursively. This
option cannot be mixed with ‘--restore’.
-L, --logical
Logical walk, follow symbolic links to directories. The default
behavior is to follow symbolic link arguments, and skip symbolic
links encountered in subdirectories. Only effective in combination
with -R. This option cannot be mixed with ‘--restore’.
-P, --physical
Physical walk, do not follow symbolic links to directories. This
also skips symbolic link arguments. Only effective in combination
with -R. This option cannot be mixed with ‘--restore’.
-v, --version
Print the version of setfacl and exit.
-h, --help
Print help explaining the command line options.
-- End of command line options. All remaining parameters are inter-
preted as file names, even if they start with a dash.
- If the file name parameter is a single dash, setfacl reads a list
of files from standard input.
ACL ENTRIES
The setfacl utility recognizes the following ACL entry formats (blanks
inserted for clarity):
[d[efault]:] [u[ser]:]uid [:perms]
Permissions of a named user. Permissions of the file owner if
uid is empty.
[d[efault]:] g[roup]:gid [:perms]
Permissions of a named group. Permissions of the owning group if
gid is empty.
[d[efault]:] m[ask][:] [:perms]
Effective rights mask
[d[efault]:] o[ther][:] [:perms]
Permissions of others.
Whitespace between delimiter characters and non-delimiter characters is
ignored.
Proper ACL entries including permissions are used in modify and set
operations. (options -m, -M, --set and --set-file). Entries without
the perms field are used for deletion of entries (options -x and -X).
For uid and gid you can specify either a name or a number.
The perms field is a combination of characters that indicate the per-
missions: read (r), write (w), execute (x), execute only if the file is
a directory or already has execute permission for some user (X).
Alternatively, the perms field can be an octal digit (0-7).
AUTOMATICALLY CREATED ENTRIES
Initially, files and directories contain only the three base ACL
entries for the owner, the group, and others. There are some rules that
need to be satisfied in order for an ACL to be valid:
* The three base entries cannot be removed. There must be exactly one
entry of each of these base entry types.
* Whenever an ACL contains named user entries or named group objects,
it must also contain an effective rights mask.
* Whenever an ACL contains any Default ACL entries, the three Default
ACL base entries (default owner, default group, and default others)
must also exist.
* Whenever a Default ACL contains named user entries or named group
objects, it must also contain a default effective rights mask.
To help the user ensure these rules, setfacl creates entries from
existing entries under the following conditions:
* If an ACL contains named user or named group entries, and no mask
entry exists, a mask entry containing the same permissions as the
group entry is created. Unless the -n option is given, the permis-
sions of the mask entry are further adjusted to include the union
of all permissions affected by the mask entry. (See the -n option
description).
* If a Default ACL entry is created, and the Default ACL contains no
owner, owning group, or others entry, a copy of the ACL owner, own-
ing group, or others entry is added to the Default ACL.
* If a Default ACL contains named user entries or named group
entries, and no mask entry exists, a mask entry containing the same
permissions as the default Default ACL’s group entry is added.
Unless the -n option is given, the permissions of the mask entry
are further adjusted to inclu de the union of all permissions
affected by the mask entry. (See the -n option description).
EXAMPLES
Granting an additional user read access
setfacl -m u:lisa:r file
Revoking write access from all groups and all named users (using the
effective rights mask)
setfacl -m m::rx file
Removing a named group entry from a file’s ACL
setfacl -x g:staff file
Copying the ACL of one file to another
getfacl file1 | setfacl --set-file=- file2
Copying the access ACL into the Default ACL
getfacl --access dir | setfacl -d -M- dir
CONFORMANCE TO POSIX 1003.1e DRAFT STANDARD 17
If the environment variable POSIXLY_CORRECT is defined, the default
behavior of setfacl changes as follows: All non-standard options are
disabled. The ‘‘default:’’ prefix is disabled. The -x and -X options
also accept permission fields (and ignore them).
AUTHOR
Andreas Gruenbacher,
Copyright(C) linux-cmd.com All Rights Reserved. Author Takayuki Yukawa