create_directories: preserve sticky and setgid permissions#1855
create_directories: preserve sticky and setgid permissions#1855franzpoeschel wants to merge 2 commits intoopenPMD:devfrom
Conversation
| }; | ||
| #else | ||
| mode_t mask = umask(0); | ||
| umask(mask); |
There was a problem hiding this comment.
Why do we retrieve the umask just to apply it manually without any modifications? That's what the system does implicitly anyway?
There was a problem hiding this comment.
Is that supposed to make the function thread-safe against modification of the umask on other threads? If yes, this does not work due to the double call to umask(), also it is irrelevant for MPI-parallel deletion.
There was a problem hiding this comment.
Agreed. Let's make sure that if someone creates dirs and files with openPMD, it behaves the same as a terminal mkdir and touch with respect to umask and other inherited properties.
It's possible the current implementation is overly verbose and forgets setgid/sticky bits
There was a problem hiding this comment.
Discussed yesterday: Our current implementation probably assumes that the umask is overwritten by the mode_t mode parameter of mkdir(), but that is not the case:
The argument mode specifies the mode for the new directory (see inode(7)). It is modified by the process's umask in the usual way: in the absence
of a default ACL, the mode of the created directory is (mode & ~umask & 0777). Whether other mode bits are honored for the created directory de-
pends on the operating system. For Linux, see VERSIONS below.
Hence, our manual umask handling (1) is unnecessary and (2) is not thread safe due to temporarily manipulating the umask.
Ref. ComputationalRadiationPhysics/picongpu#5638