In Cygwin, I set the permission of a folder "tmp"
$ chmod 600 tmp
$ ls -ld tmp
drw-------+ 1 leecy Users 0 Aug 15 10:56 tmp
But Git Bash (from Git for Windows) gets a different idea of the permission:
$ ls -ld ~/tmp
drwxr-xr-x 1 leecy 1049089 0 Aug 15 10:56 /c/cygwin64/home/leecy/tmp/
I have researched, read, and tried out the suggestions (chgrp
, chown :Users
, setfacl
, etc) from the following posts but still could not find a solution:
- 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
By the way, this problem is believed to be the reason why my git clone
operation
(which uses SSH) has recently stopped working. In the above I am
demonstrating the problem with a test folder tmp
, but in real life
the folder is actually my .ssh
and my git clone
recently started
failing with an error of:
$ git clone ...
Cloning into 'foo'...
Bad owner or permissions on /home/leecy/.ssh/config
fatal: Could not read from remote repository.
There may be some recent change related to the Windows Domain set up (done by the corporate IT people) that is related to this problem -- the problem started to surface after that change.
Versions:
Cygwin: 2.8.2(0.313/5/3)
Git Bash: git version 2.14.1.windows.1
Update
Thanks for the suggestion by Doug Henderson (see it in the comment).
I tried using the command setfacl -b -k
, it did remove
the extra non-standard POSIX permissions, but it did not
solve the problem.
Before using 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
After using 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:---
But that did not help
cygwin:
$ ls -ld tmp
drw------- 1 leecy Users 0 Aug 15 10:56 tmp
Git Bash:
$ ls -ld tmp
drwxr-xr-x 1 leecy 1049089 0 Aug 15 10:56 tmp/
Update 2
Using getfacl
I examined closely what group the file is in, and
indeed cygwin
and git bash
have two different ideas
Cygwin
$ getfacl tmp
# file: tmp
# owner: leecy
# group: Users
user::rw-
group::---
other:---
Git Bash
$ getfacl tmp
# file: tmp
# owner: leecy
# group: 1049089 <unknown>
user::rwx
group::r-x
other:r-x
The number 1049089
may mean Domain Users
in my system, but
this number seems to be understood by cygwin
but not git bash
.
I said that because my cygwin /etc/group
has a line like this
(this file was not there originally, I created it using the command
mkgroup -l -d > /etc/group
as suggested in this post)
Domain Users:S-1-5-21-1593251271-2640304127-1825641215-513:1049089:
I also tried the command chgrp
and chown
. Both ran without error,
but is not taking effect (the number 545
is the group id for Users
that cygwin
(but not git bash
) understands)
No effect of 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
No effect of 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