perl-5.38.0
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). The umask value 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 permissions 0777, if your umask is 0022, then the file will actually be created with permissions 0755. If your umask were 0027 (group can't write; others can't read, write, or execute), then passing sysopen 0666 would create a file with mode 0640 (because 0666 &~ 027 is 0640).

Unix パーミッション rwxr-x--- は 3 ビットの三つの組、 または 3 桁の 8 進数として表現されます: 0750 (先頭の 0 は 8 進数を意味し、実際の値ではありません)。 umask の値は無効にするパーミッションビットのこのような 数値表現です。 mkdirsysopen で渡されたパーミッション (または「モード」)の値は umask で修正され、たとえ sysopen0777 のパーミッションで ファイルを作るように指定しても、umask が 0022 なら、 結果としてファイルは 0755 のパーミッションで作成されます。 umask0027 (グループは書き込めない; その他は読み込み、 書き込み、実行できない) のとき sysopen0666 を渡すと、 ファイルはモード 0640 (なぜなら 0666 &~ 0270640)で作成されます。

Here's some advice: supply a creation mode of 0666 for regular files (in sysopen) and one of 0777 for directories (in mkdir) and executable files. This gives users the freedom of choice: if they want protected files, they might choose process umasks of 022, 027, or even the particularly antisocial mask of 077. 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