【发布时间】:2018-01-23 14:18:24
【问题描述】:
在 Cygwin 中,我设置了文件夹“tmp”的权限
$ chmod 600 tmp
$ ls -ld tmp
drw-------+ 1 leecy Users 0 Aug 15 10:56 tmp
但 Git Bash(来自 Git for Windows)有不同的想法 权限:
$ ls -ld ~/tmp
drwxr-xr-x 1 leecy 1049089 0 Aug 15 10:56 /c/cygwin64/home/leecy/tmp/
我已经研究、阅读并尝试了以下帖子中的建议(chgrp、chown :Users、setfacl 等),但仍然找不到解决方案:
- Updating file permissions with git-bash on Windows 7
- chmod cannot change group permission on cygwin
- Using Cygwin in Windows 8, chmod 600 does not work as expected?
- cygwin's chmod behaves as working, but it does not work
顺便说一下,这个问题相信是我git clone操作的原因
(使用 SSH)最近停止工作。在上面我是
用测试文件夹tmp 演示问题,但在现实生活中
该文件夹实际上是我的.ssh 和我的git clone 最近开始
失败并出现以下错误:
$ git clone ...
Cloning into 'foo'...
Bad owner or permissions on /home/leecy/.ssh/config
fatal: Could not read from remote repository.
最近可能有一些与 Windows 域相关的更改 与此相关的设置(由公司 IT 人员完成) 问题 - 更改后问题开始浮出水面。
版本:
Cygwin: 2.8.2(0.313/5/3)
Git Bash: git version 2.14.1.windows.1
更新
感谢 Doug Henderson 的建议(见评论)。
我尝试使用命令setfacl -b -k,它确实删除了
额外的非标准 POSIX 权限,但它没有
解决问题。
在使用setfacl -b -k之前
$ getfacl tmp
# file: tmp
# owner: leecy
# group: Users
user::rw-
group::---
other:---
default:user::rwx
default:group::r-x
default:other:r-x
使用setfacl -b -k后
leecy@USLEECY-C1 ~
$ setfacl -b -k tmp
leecy@USLEECY-C1 ~
$ getfacl tmp
# file: tmp
# owner: leecy
# group: Users
user::rw-
group::---
other:---
但这并没有帮助
cygwin:
$ ls -ld tmp
drw------- 1 leecy Users 0 Aug 15 10:56 tmp
Git 重击:
$ ls -ld tmp
drwxr-xr-x 1 leecy 1049089 0 Aug 15 10:56 tmp/
更新 2
使用getfacl 我仔细检查了文件所在的组,并且
确实cygwin和git bash有两个不同的想法
赛格温
$ getfacl tmp
# file: tmp
# owner: leecy
# group: Users
user::rw-
group::---
other:---
Git 重击
$ getfacl tmp
# file: tmp
# owner: leecy
# group: 1049089 <unknown>
user::rwx
group::r-x
other:r-x
数字1049089 在我的系统中可能意味着Domain Users,但是
cygwin 似乎可以理解这个数字,但git bash 不理解。
我这么说是因为我的 cygwin /etc/group 有这样一行
(这个文件原本不存在,我使用命令创建它
mkgroup -l -d > /etc/group 建议在此 post)
Domain Users:S-1-5-21-1593251271-2640304127-1825641215-513:1049089:
我还尝试了命令chgrp 和chown。两者都运行没有错误,
但未生效(数字545 是Users 的组ID
cygwin(但不是git bash)理解)
chgrp无效
$ getfacl tmp
# file: tmp
# owner: leecy
# group: 1049089 <unknown>
user::rwx
group::r-x
other:r-x
$ chgrp 545 tmp
$ ls -ld tmp
drwxr-xr-x 1 leecy 1049089 0 Aug 15 10:56 tmp/
$ getfacl tmp
# file: tmp
# owner: leecy
# group: 1049089 <unknown>
user::rwx
group::r-x
other:r-x
chown无效
leecy@USLEECY-C1 MINGW64 ~
$ chown leecy.545 tmp
leecy@USLEECY-C1 MINGW64 ~
$ ls -ld tmp
drwxr-xr-x 1 leecy 1049089 0 Aug 15 10:56 tmp/
leecy@USLEECY-C1 MINGW64 ~
$ getfacl tmp
# file: tmp
# owner: leecy
# group: 1049089 <unknown>
user::rwx
group::r-x
other:r-x
【问题讨论】:
-
cygwin 有一个 git 包。为什么不使用它?
-
在cygwin中ls显示的权限末尾的
+表示存在不适合用户/组/其他、读/写/执行模型的附加权限。您可以使用getfaclcygwin 命令或icaclswindows 命令或在文件资源管理器中右键单击属性来显示它们。检查tmp目录及其父目录的acls。您可能会在其中一个修改预期权限的父级上找到默认 acl。 -
您还应该检查 git 全局配置的内容。在 cygwin 和 msys2 上,它可能位于
~/.gitconfig中。我已将它们配置为彼此相处融洽。 cygwin 和 msys2 使用不同的方法将 windows 内部用户 id 和组 id 转换为 unix 样式名称和数字。比较/etc/nsswitch.conf文件以获取线索。 -
@DougHenderson -- 感谢您的建议!我尝试了命令
setfact -b -k。它确实删除了额外的非标准 POSIX 权限,但并没有解决问题。有关详细信息,请参阅我在问题中的更新。 -
我还查看了我的
~/.gitconfig。我在那里没有看到任何与权限相关的内容。文件中唯一的指令是[user]、[credential]和[gui]
标签: git permissions window cygwin git-bash