umask与用户的umask不同

umask与用户的umask不同

本文介绍了什么原因导致git的post-receive umask与用户的umask不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

经过一些挖掘和帮助在这里,我发现我在git中的 umask 设置有问题。我想实现的是任何正在我的服务器上检出的git repo, umask 设置默认为0002.我不想配置这个在每个post-receive钩子中......我希望这是默认的 umask 。我如何实现这一目标?



通过登录到服务器上的 git 用户的ssh来上传我的存储库。当我检查 umask 设置时,它已经设置为正确的设置:

  root @ server:〜#su git 
git @ server:〜$ umask
0002

然而,如果我把 umask> /tmp/debug.log 在我的post-receive钩子中,那么该文件显示0077的 umask !是什么原因导致这种情况有所不同?



根服务器也有相同的 umask ,我无法计算为什么当我检出一个存储库时, umask 是不同的。如果我更改为 git 用户并创建一个文件,那么一切正常:

  git @ server:〜$ touch newfile 
git @ server:〜$ ls -la
total 8
-rw-rw-r-- 1 git git 0 Aug 6 02 :17 newfile
-rw ------- 1 git git 0 Aug 6 02:16 post

newfile 是我刚创建的文件, post 文件是我通过git检出的文件,显然拥有不同的权限。我还向git用户的.bashrc添加了 umask ,但无济于事:

  git @ server:〜$ cat〜/ .bashrc 
export LANGUAGE =en_US.UTF-8
export LC_ALL =en_US.UTF-8
export LANG =en_US.UTF-8
export LC_TYPE =en_US.UTF-8
umask 0002

值得一提的是,我使用gitolite来管理我的仓库。



以下是我使用的post-receive钩子脚本示例:

 #!/ bin / sh 
export GIT_WORK_TREE = / home / user / www /
git checkout -f


解决方案

事实证明 我正在使用gitolite。为什么?因为在gitolite配置中有一个设置来规定新文件的umask。奇怪的是,我从来不需要在之前的gitolite安装中更改此设置,但可能默认设置已更改。无论如何,下面是我如何最终整理出来的:



打开〜/ .gitolite.rc 文件:

找到这一行:

  $ REPO_UMASK = 0077; 

然后将其更改为选择的设置,例如:

  $ REPO_UMASK = 0002; 

事情终于奏效了!

After some digging and help here from other people, I found out that I have a problem with the umask setting in git. What I want to achieve is that any git repo that is being checked out on my server, that the umask setting defaults to 0002. I don't want to have to configure this in every post-receive hook... I want this to be the default umask. How do I achieve that?

My repositories are uploaded by logging in to ssh with the git user on the server. When I check the umask setting, this is already set to the right setting:

root@server:~# su git
git@server:~$ umask
0002

However, if I put umask > /tmp/debug.log in my post-receive hook, then that file shows an umask of 0077! What causes this to be different?

The root server also has the same umask and I just can't figure out why the umask is different when I check out a repository. If I change to the git user and create a file, then all works well:

git@server:~$ touch newfile
git@server:~$ ls -la
total 8
-rw-rw-r-- 1 git git    0 Aug  6 02:17 newfile
-rw------- 1 git git    0 Aug  6 02:16 post

newfile is the file I just created, The post file is a file I checked out via git, clearly with different permissions. I also added umask to the .bashrc of the git user, but to no avail:

git@server:~$ cat ~/.bashrc
export LANGUAGE="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
export LANG="en_US.UTF-8"
export LC_TYPE="en_US.UTF-8"
umask 0002

For what it's worth, I use gitolite to manage my repositories.

And this an example post-receive hook script I use:

#!/bin/sh
export GIT_WORK_TREE=/home/user/www/
git checkout -f
解决方案

So it turns out it does matter that I am using gitolite. Why? Because there is a setting in the gitolite configuration that dictates the umask of new files. Oddly I never had to change this setting in previous gitolite installs, but perhaps the default has been changed. In any way, here is how I finally sorted it out:

Open the ~/.gitolite.rc file:

Locate this line:

$REPO_UMASK = 0077;

And change it to the setting of choice, eg:

$REPO_UMASK = 0002;

Things finally worked afterwards!

这篇关于什么原因导致git的post-receive umask与用户的umask不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 17:13