LoginSignup
11
6

More than 5 years have passed since last update.

macOS でよく見かける拡張属性や ACL

Last updated at Posted at 2018-07-09

はじめに

ホームディレクトリで ls -l をしたとき、Linux ではあまりお目にかからないが、macOS ではファイルモードの項目 (所有者・グループ・他ユーザのパーミッションを表す文字列のところ、と言えば理解が早いかもしれない) の末尾にプラス「+」やアットマーク「@」がついているのを目にする。これは ls の man の The Long Format の項目にしっかり書かれてあって、

If the file or directory has extended attributes, the permissions field printed by the -l option is followed by a '@' character. Otherwise, if the file or directory has extended security information (such as an access control list), the permissions field printed by the -l option is followed by a '+' character.
(ディレクトリに拡張属性があるなら、ls -l したときの出力でパーミッションの後に @ がつく。ファイルあるいはディレクトリに拡張セキュリティ情報 (たとえば Access Control List: ACL) があるなら同様にパーミッションの後に + がつく。)

とのことである。なので @ は拡張属性、+ は ACL なのだとまずは理解することができる。となると次に、どのような拡張属性が、あるいは ACL がそこにかかっているのか、が気になるだろうし、それらをどうすれば操作することができるのだろうか、ということが気になるだろう。

拡張属性

前述の man にもあるように、拡張属性はファイルもしくはディレクトリにつく。ls -l をディレクトリに対して行うとその下のファイルまで表示されてしまうが、d オプションを指定すると指定したディレクトリの情報のみが表示される。@ オプションをさらにつけると拡張属性を表示してくれる。

% ls -ld@ Documents
drwx------@ 25 reo  staff  800  7  9 13:46 Documents
        com.dropbox.attributes   82
        com.dropbox.attrs        28

同様のことは xattr コマンドでもできる。ls コマンドでは拡張属性を表示するだけだが、xattr コマンドでは拡張属性の操作も可能である。

% xattr Documents
com.dropbox.attributes
com.dropbox.attrs

xattr コマンドで行う拡張属性の修正は xattr のマニュアルを参照していただくとして、これらの拡張属性はアプリケーションによって与えられている場合があるので、xattr コマンドで属性を剥ぎ取ったりせず、アプリケーションの操作 (アンインストールや設定の変更) により属性を変化させることが望ましいかもしれない。

ACL

ACL も拡張属性と同様にファイルもしくはディレクトリにつく。ACL の内容を表示させるためには ls で e オプションをつければ良い。

% ls -lde Documents
drwx------@ 25 reo  staff  800  7  9 13:46 Documents
 0: group:everyone deny delete

ACL を操作するのは意外にも chmod コマンドである。+a オプションで追加、-a オプションで削除である。たとえばこのように。

% chmod -a "group:everyone deny delete" Documents
% ls -lde Documents
drwx------@ 25 reo  staff  800  7  9 13:46 Documents
% chmod +a "group:everyone deny delete" Documents
% ls -lde Documents
drwx------@ 25 reo  staff  800  7  9 13:46 Documents
 0: group:everyone deny delete
11
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
6