Skip to content

create_directories: preserve sticky and setgid permissions#1855

Open
franzpoeschel wants to merge 2 commits intoopenPMD:devfrom
franzpoeschel:fix-sticky-permissions
Open

create_directories: preserve sticky and setgid permissions#1855
franzpoeschel wants to merge 2 commits intoopenPMD:devfrom
franzpoeschel:fix-sticky-permissions

Conversation

@franzpoeschel
Copy link
Contributor

};
#else
mode_t mask = umask(0);
umask(mask);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we retrieve the umask just to apply it manually without any modifications? That's what the system does implicitly anyway?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

@ax3l ax3l Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@franzpoeschel franzpoeschel requested a review from ax3l March 3, 2026 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants