I am reading some source code and I found this statement at the very beginning of the main routine:
umask(077);
What could be the reason for that?
The man page (man 2 umask) states:
umask — set file creation mode mask
This clearing allows each user to
restrict the default access to his
files
But is not clear to me why would anyone do that? as a shortcut ?
Setting
umask(077)ensures that any files created by the program will only be accessible to their owner (0 in first position = all permissions potentially available) and nobody else (7 in second/third position = all permissions disallowed to group/other).