0

I don't understand how umask works in these two files: my machine doesn't use pam_umask module.

If I change user and create a new file/directory, the umask used is taken from /etc/profile (the umask in /etc/login.defs is unused).

Which is the purpose of umask in /etc/login.defs?

From the manpage seems it is used only for the permission definition of an home directory for new users: is it correct?

1

You answered your own question. The man page for login.defs explains:

UMASK (number)

The file mode creation mask is initialized to this value. If not specified, the mask will be initialized to 022.

useradd and newusers use this mask to set the mode of the home directory they create

It is also used by pam_umask as the default umask value.

/etc/profile is executed by the login shell. When not logging in via shell, umask set in /etc/profile is not effective.

pam_umask module can be configured to set the session umask to the value defined in login.defs. Compared to setting umask in /etc/profile, umask set by pam_umask is also effective in situations when logging in does not execute login shell (graphical session, ssh session without shell).

  • So in my system umask in /etc/login.defs is used only for permissions of a newly created home: can you explain me the situations where the umask in /etc/profile is not effective? You have written about different deafault shell: is this the case? If I have two users with different shells (e.g. sh and bash), how umask is managed? is it always taken from /etc/profile? – andrew Aug 15 '18 at 18:55
  • Most shells execute /etc/profile when invoked as login shell. A typical example when /etc/profile is not executed and umask set there is not effective when logging in graphical session or when logging in via ssh and providing a command to execute. – sebasth Aug 15 '18 at 19:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.