1

这是设置:

  • 我有一个git用户umask022.
  • git将文件和文件夹添加到名为htdocs.
  • htdocs具有drwxr-srx权限(gid 集)并由git:apache
  • htdocs-rw-r--r--(644) 和drwxr-srx(2775)中创建的文件和文件夹

有时我需要授予 Apache 对文件夹的写入权限:

chmod g+w some-folder

问题是它丢失了gid,所以不是:

drwxrwsr-x

我得到:

drwxrwxr-x

当我尝试重新添加 gid 时:

chmod g+s some-folder

它什么也没做。some-folder仍然只有 755 个权限。

我还尝试手动将其设置为 2755:

chmod 2755 some-folder

没有运气。

有人对我如何保持 gid 设置有任何想法吗?

更新

经过几个小时的研究并看到其他用户也有同样的问题,@twalberg确定了仅有的两个可用选项。我决定创建一个新组并将 git 和 apache 都放入其中。现在 git 属于该组,gid 保持设置。

4

1 回答 1

1

man 2 chmod有话要说:

    If the calling process is not privileged  (Linux:  does  not  have  the
    CAP_FSETID  capability),  and  the group of the file does not match the
    effective group ID of the process or one  of  its  supplementary  group
    IDs,  the  S_ISGID  bit  will be turned off, but this will not cause an
    error to be returned.

我猜那git不在apache组中,所以当git更改目录上的模式时,setgid 位会自动清除。您可以添加gitapache组中,也可以使用特权帐户执行chmod.

于 2013-08-16T18:57:42.493 回答