1

I need to set default file creation permissions for everyone to 777 [rwx], however umask uses 666 for files:

  • If I need permissions to be 444, I would issue umask 222 [666 - 222 = 444], but the problem is I need to set them to 777

How do I achieve this?

JW0914
  • 9,096

1 Answers1

2

You really can't - there is no "default file permission" on POSIX systems.

File permissions are set when the file is created with either the open()/openat() or creat() function.

Per the open() specifications (note the bolded part, added to emphasize where file permission bits come from):

O_CREAT

If the file exists, this flag has no effect except as noted under O_EXCL below. Otherwise, if O_DIRECTORY is not set the file shall be created as a regular file; the user ID of the file shall be set to the effective user ID of the process; the group ID of the file shall be set to the group ID of the file's parent directory or to the effective group ID of the process; and the access permission bits (see <sys/stat.h>) of the file mode shall be set to the value of the argument following the oflag argument taken as type mode_t modified as follows: a bitwise AND is performed on the file-mode bits and the corresponding bits in the complement of the process' file mode creation mask. ...

The application creating the file picks the file's initial permissions, but with the bits that are non-zero in the process umask setting set to zero.

There is no "default" permission setting.