Page 1 of 1

Creating directories with setgid bit - no way to not set it for files though?

Posted: September 9th, 2010, 7:26 am
by spanky85
In the interests of keeping things manageable I'd like to use the setgid bit to ensure a common group is used for all new directories and files. I've set the "Permissions for completed downloads" setting to "2770", but of course this sets the setgid bit for files as well as for directories, which is undesirable for security reasons. When set to "770" the created directories don't inherit the parent directory's setgid bit since I assume they're actually created in the temporary location without it then moved across, which circumvents the usual behaviour for creating directories in directories with setgid set. I've had a good search for this on the forums but couldn't find anything.

Is there any way to specify permissions for created directories separately from permissions for created files?

Or, is there a way to specify the group for created files and directories?

Or, is there some other way to accomplish this (perhaps some post-completion script or command)?

I'm quite new to sabnzbd so far so please keep it simple :) Brilliant application so far by the way, well done.

Re: Creating directories with setgid bit - no way to not set it for files though?

Posted: September 9th, 2010, 7:34 am
by shypike
In SABnzbd you set the permissions for directories and it will derive the
permissions for files (by removing the X flag).
The assumption is that the permissions are only R, W and X, it doesn't take other flags into account.
The easiest way would be to write your own script.

Code: Select all

#!/bin/sh
find "$1" -type dir -exec chmod 2770 {} \;
I'm sure this needs editing, because I can never get find/exec commands right the first time.

Re: Creating directories with setgid bit - no way to not set it for files though?

Posted: September 9th, 2010, 8:27 am
by spanky85
I see, to me that's not very intuitive but I guess it simplifies things. Perhaps just a note by the option would help avoid confusion?

I used this script in the end, slightly different syntax and adds the s flag to the existing permissions so the normal setting is still respected:

Code: Select all

#!/bin/sh
find "$1" -type d -exec chmod g+s '{}' \;
Thanks for your help!