- umask EXPR
- umask
-
Sets the umask for the process to EXPR and returns the previous value. If EXPR is omitted, merely returns the current umask.
現在のプロセスの umask を EXPR に設定し、以前の値を返します。 EXPR が省略されると、単にその時点の umask の値を返します。
The Unix permission
rwxr-x---is represented as three sets of three bits, or three octal digits:0750(the leading 0 indicates octal and isn't one of the digits). Theumaskvalue is such a number representing disabled permissions bits. The permission (or "mode") values you pass mkdir or sysopen are modified by your umask, so even if you tell sysopen to create a file with permissions0777, if your umask is0022, then the file will actually be created with permissions0755. If yourumaskwere0027(group can't write; others can't read, write, or execute), then passing sysopen0666would create a file with mode0640(because0666 &~ 027is0640).Unix パーミッション
rwxr-x---は 3 ビットの三つの組、 または 3 桁の 8 進数として表現されます:0750(先頭の 0 は 8 進数を意味し、実際の値ではありません)。umaskの値は無効にするパーミッションビットのこのような 数値表現です。 mkdir や sysopen で渡されたパーミッション (または「モード」)の値は umask で修正され、たとえ sysopen で0777のパーミッションで ファイルを作るように指定しても、umask が0022なら、 結果としてファイルは0755のパーミッションで作成されます。umaskが0027(グループは書き込めない; その他は読み込み、 書き込み、実行できない) のとき sysopen に0666を渡すと、 ファイルはモード0640(なぜなら0666 &~ 027は0640)で作成されます。Here's some advice: supply a creation mode of
0666for regular files (in sysopen) and one of0777for directories (in mkdir) and executable files. This gives users the freedom of choice: if they want protected files, they might choose process umasks of022,027, or even the particularly antisocial mask of077. Programs should rarely if ever make policy decisions better left to the user. The exception to this is when writing files that should be kept private: mail files, web browser cookies, .rhosts files, and so on.以下は助言です: 作成モードとして、 (sysopen による)通常ファイルでは
0666を、(mkdir による)ディレクトリでは0777を指定しましょう。 これにより、ユーザーに選択の自由を与えます: もしファイルを守りたいなら、 プロセスの umask として022,027, あるいは特に非社交的な077を選択できます。 プログラムがユーザーより適切なポリシー選択ができることは稀です。 例外は、プライベートに保つべきファイル(メール、ウェブブラウザのクッキー、 .rhosts ファイルなど)を書く場合です。If umask(2) is not implemented on your system and you are trying to restrict access for yourself (i.e.,
(EXPR & 0700) > 0), raises an exception. If umask(2) is not implemented and you are not trying to restrict access for yourself, returns undef.umask(2) が実装されていないシステムで、自分自身 へのアクセスを 制限しようとした(つまり
(EXPR & 0700) > 0)場合、例外が発生します。 umask(2) が実装されていないシステムで、自分自身へのアクセスは 制限しようとしなかった場合、undef を返します。Remember that a umask is a number, usually given in octal; it is not a string of octal digits. See also oct, if all you have is a string.
umask は通常 8 進数で与えられる数値であることを忘れないでください; 8 進数の 文字列 ではありません。 文字列しかない場合、 oct も参照してください。
Portability issues: "umask" in perlport.
移植性の問題: "umask" in perlport。