Umask 在 open() 系统调用中?

Umask In open() Syscall?

在阅读有关 open 系统调用以及我们发送的参数的更多详细信息时,我阅读了:

The umask acts as a set of permissions that applications cannot set on files. It's a file mode creation mask for processes and cannot be set for directories itself. Most applications would not create files with execute permissions set, so they would have a default of 666, which is then modified by the umask. As you have set the umask to remove the read/write bits for the owner and the read bits for others, a default such as 777 in applications would result in the file permissions being 133. This would mean that you (and others) could execute the file, and others would be able to write to it. If you want to make files not be read/write/execute by anyone but the owner, you should use a umask like 077 to turn off those permissions for the group & others. In contrast, a umask of 000 will make newly created directories readable, writable and descendible for everyone (the permissions will be 777). Such a umask is highly insecure and you should never set the umask to 000. The default umask on Ubuntu is 022 which means that newly created files are readable by everyone, but only writable by the owner.

谁能解释一下这个面具一般是什么?我以前没听说过?

umask 值决定了创建文件时赋予的权限,默认赋予文件的权限,创建后您可以使用 chmod 更改它。

如果要检查值设置,则必须执行“umask”命令,这可以告诉您默认值,用户必须创建文件。

如果你想改变 umask 值你可以运行下面的命令来设置它。

umask 022

请记住,您在上述命令中描述的数字是不会授予该文件的权限,因此,在这种情况下,将生成 755。