=encoding euc-jp =head1 NAME =begin original filetest - Perl pragma to control the filetest permission operators =end original filetest - ファイルテスト権限演算子を制御する Perl プラグマ =head1 SYNOPSIS $can_perhaps_read = -r "file"; # use the mode bits { use filetest 'access'; # intuit harder $can_really_read = -r "file"; } $can_perhaps_read = -r "file"; # use the mode bits again =head1 DESCRIPTION =begin original This pragma tells the compiler to change the behaviour of the filetest permission operators, C<-r> C<-w> C<-x> C<-R> C<-W> C<-X> (see L). =end original このプラグマはファイルテスト権限演算子 C<-r> C<-w> C<-x> C<-R> C<-W> C<-X> の (L 参照)振る舞いを変えることをコンパイラに伝えます。 =begin original The default behaviour of file test operators is to use the simple mode bits as returned by the stat() family of system calls. However, many operating systems have additional features to define more complex access rights, for example ACLs (Access Control Lists). For such environments, C may help the permission operators to return results more consistent with other tools. =end original ファイルテスト演算子のデフォルトの振る舞いは、システムコールの stat() 系列から返された単純なモードビットを使うものです。 しかし、多くのオペレーティングシステムは、例えば ACL (Access Control List)のような、より複雑なアクセス権限を定義するための 追加の機能を持っています。 このような環境のために、C は権限演算子が他のツールと より一貫性のある結果を返す助けをします。 =begin original The C or C statements affect file tests defined in their block, up to the end of the closest enclosing block (they are lexically block-scoped). =end original C や C 文は、一番内側のブロックの終わりまで、 定義されたブロック内のファイルテストに影響を与えます (レキシカルブロック スコープを持ちます)。 =begin original Currently, only the C sub-pragma is implemented. It enables (or disables) the use of access() when available, that is, on most UNIX systems and other POSIX environments. See details below. =end original 現在のところ、C 副プラグマのみが実装されています。 これは利用可能な(つまり、ほとんどの UNIX システムとその他の POSIX 環境の) 場合に access() の使用を有効に(または無効に)します。 詳しくは以下を参照してください。 =head2 Consider this carefully (これを注意深く検討する) =begin original The stat() mode bits are probably right for most of the files and directories found on your system, because few people want to use the additional features offered by access(). But you may encounter surprises if your program runs on a system that uses ACLs, since the stat() information won't reflect the actual permissions. =end original stat() モードビットはシステムで見付かるほとんどのファイルとディレクトリに 対しておそらく正しいです; なぜなら access() で提供される追加の機能を 使いたい人はほとんどいないからです。 しかし ACL を使うシステムでプログラムを動かすと、驚きに 遭遇するかもしれません; stat() 情報は実際の権限を反映していないからです。 =begin original There may be a slight performance decrease in the filetest operations when the filetest pragma is in effect, because checking bits is very cheap. =end original filetest プラグマが有効の時、ファイルテスト演算子の性能は少し低下します; ビットのチェックはとても安価だからです。 =begin original Also, note that using the file tests for security purposes is a lost cause from the start: there is a window open for race conditions (who is to say that the permissions will not change between the test and the real operation?). Therefore if you are serious about security, just try the real operation and test for its success - think in terms of atomic operations. Filetests are more useful for filesystem administrative tasks, when you have no need for the content of the elements on disk. =end original また、セキュリティの理由でファイルテストを使うことは最初から大義を 失っていることに注意してください: 競合条件のための窓が開いています (テストと実際の操作の間に権限が変更されないと誰が言えますか?)。 従って、セキュリティについて真剣に考えるなら、単に実際に操作を行って 成功したかどうかをテストしてください - アトミックな操作ということについて 考えてください。 ファイルテストはファイルシステム管理タスクでより有用です; ディスク上の 要素の内容には関係がない場合です。 =head2 The "access" sub-pragma ("access" 副プラグマ) =begin original UNIX and POSIX systems provide an abstract access() operating system call, which should be used to query the read, write, and execute rights. This function hides various distinct approaches in additional operating system specific security features, like Access Control Lists (ACLs) =end original UNIX と POSIX のシステムは抽象 access() オペレーティングシステムコールを 提供しています; これは読み書き実行権限の問い合わせに使われます。 この関数は Access Control List (ACL) のようなオペレーティングシステムに 固有の追加のセキュリティ機能の様々な異なった手法を隠蔽します。 =begin original The extended filetest functionality is used by Perl only when the argument of the operators is a filename, not when it is a filehandle. =end original 拡張されたファイルテスト機能は、演算子の引数がファイル名の時にのみ Perl によって使われます; ファイルハンドルの時は使われません。 =head2 Limitation with regard to C<_> (C<_> に関連する制限) =begin original Because access() does not invoke stat() (at least not in a way visible to Perl), B. This means that the outcome of the following two tests is different. The first has the stat bits of C in C<_>, and in the second case this still contains the bits of C. =end original access() は(少なくとも Perl から見える形では) stat() を起動しないので、 B。 これは、以下の二つのテストの結果が異なるということです。 前者は C の stat ビットが C<_> に保管されますが、後者は C のビットを含んでいます。 { -d '/etc'; -w '/etc/passwd'; print -f _ ? 'Yes' : 'No'; # Yes } { use filetest 'access'; -d '/etc'; -w '/etc/passwd'; print -f _ ? 'Yes' : 'No'; # No } =begin original Of course, unless your OS does not implement access(), in which case the pragma is simply ignored. Best not to use C<_> at all in a file where the filetest pragma is active! =end original もちろん、OS が access() を実装していない限り、このプラグマは単に 無視されます。 filetest プラグマが有効なところではファイルに対して一切 C<_> を使わないのが 最良です! =begin original As a side effect, as C<_> doesn't work, stacked filetest operators (C<-f -w $file>) won't work either. =end original 副作用として、C<_> が動作しないので、スタックしたファイルテスト演算子 (C<-f -w $file>) は動作しません。 =begin original This limitation might be removed in a future version of perl. =end original この制限は将来のバージョンの perl では取り除かれるかもしれません。 =begin meta Translate: SHIRAKATA Kentaro Status: completed =end meta =cut