umask

From Kicksecure
Jump to navigation Jump to search
Documentation Previous page: chmod-calc Index page: Documentation Next page: RAM Adjusted Desktop Starter umask

Due to the umask hardening security feature, a usability issue may arise where file permissions are more restrictive than expected.

This guide demonstrates how to reproduce the issue and provides solutions to mitigate it.

Steps to reproduce[edit]

1. Create the file testfile.

touch -- testfile

2. Copy the file using cp.

sudo -- cp -- testfile /etc/testfile

3. View file permissions.

  • A) ls
    • ls -la -- /etc/testfile
  • B) chmod-calc:
    • chmod-calc /etc/testfile

Expected ls result[edit]

Readable by "others" ("public")

-rw-r--r-- 1 root root 0 May 11 10:54 /etc/testfile

Actual ls result[edit]

Unreadable by "others"

-rw-r----- 1 root root 0 May 11 10:54 /etc/testfile

Explanation[edit]

This behavior occurs because the file testfile was initially created with restrictive permissions, making it unreadable by "others". When the file is copied, those permissions are preserved by default.

The cp command retains the original file's mode (permissions) unless otherwise instructed. To prevent this, use the --no-preserve=mode option.

Solutions[edit]

Use cp with the --no-preserve=mode option to avoid inheriting the original permissions.

sudo -- cp --no-preserve=mode -- testfile /etc/testfile

Or, if the file has already been copied, adjust its permissions manually using chmod:

sudo -- chmod o+r -- /etc/testfile

Documentation Previous page: chmod-calc Index page: Documentation Next page: RAM Adjusted Desktop Starter

Notification image

We believe security software like Kicksecure needs to remain Open Source and independent. Would you help sustain and grow the project? Learn more about our 13 year success story and maybe DONATE!