zen-fs / core

A filesystem, anywhere.
https://zenfs.dev/core/
MIT License
145 stars 22 forks source link

Support for Inheriting Group Permission from Directory Using Setgid (g+s) in emulation layer #133

Open mcandeia opened 2 weeks ago

mcandeia commented 2 weeks ago

https://en.wikipedia.org/wiki/Setuid#setuid_and_setgid_on_directories

Example

When the setgid bit (g+s) is set on a directory, any new files or subdirectories created within it should automatically inherit the directory's group rather than the group of the user creating the file. This behavior is useful for shared directories where consistent group ownership is needed (e.g., collaborative environments or web directories).


// Set up directory with setgid
await fs.chmod('/var/www', 0o2775);
await fs.chown('/var/www', 33, 33); // 33 is the default www-data user/gid on unix

// Expected behavior: Files created in '/var/www' inherit group from directory
await fs.writeFile('/var/www/app/index.html', '<html><body>hello</body></html>');
const stat = await fs.stat('/var/www/app/index.html');
console.log(stat.gid); // Should match gid of /var/www
james-pre commented 2 weeks ago

5b4e391 adds support to StoreFS