When could or should I use chmod g+s on a file or directory?

后端 未结 8 1446
日久生厌
日久生厌 2021-01-30 13:47

In deploying to a new (Solaris 9) environment recently, one of the steps was to copy a set of files and directories to their new location and then to apply the group UID bit (us

相关标签:
8条回答
  • 2021-01-30 14:24

    To expand on your specific problem a little, it has already been noted that sgid executables can cause problems by granting users permissions they don't normally have. While this is an issue for any executable, it creates a potentially-exploitable race condition in the case of scripts (specifically meaning "files which execute by means of an external interpreter identified by a #! at the beginning of the file") which can be used to execute any arbitrary code with the script's permissions.

    Unix deriviatives have implemented a number of schemes over the years which are aimed at mitigating or eliminating this vulnerability, most of which have included some form of prohibiting the execution of suid or sgid scripts entirely or requiring you to jump through a few hoops to enable it (usually on a script-by-script basis). One such scheme would be the cause of your inability to run the scripts after turning on their sgid flag.

    0 讨论(0)
  • 2021-01-30 14:31

    Setting directories g+s makes all new files created in said directory have their group set to the directory's group.

    This can actually be really handy for collaborative purposes if you have the umask set so that files have group write by default.

    Note: This is the way it works in Linux, it could work completely differently in Solaris.

    0 讨论(0)
提交回复
热议问题