Reputation: 1093
A directory with setgid bit needs to be created. Normally the following works:
mkdir("/dummy", 755);
chmod("/dummy", 2755);
But there is a chance that other process can write something into the directory before the setgid bit was set.
Is there a way to create a directory with setgid bit already set or what is the best way to achieve this?
Upvotes: 1
Views: 89
Reputation: 8343
If you want to prevent everyone from using the directory before you called chmod, you could create (mkdir) the directory with rights 000 and only set them together with the setgid bit.
Upvotes: 2