cygwin如何/为何打破Windows权限?

时间:2017-03-31 17:20:49

标签: security cygwin ntfs

我们有“来自现场”的投诉(即来自系统管理员安装软件)cygwin“搞砸”NTFS上的Windows权限(Windows 7/10/2008/2012等)。

问题用例

一般用例是:

  • Sysadmin从cygwin bash cmd行启动了一些“软件安装程序”
  • 安装程序运行正常
  • Sysadmin尝试启动Windows服务

结果:    服务无法启动

解决方法步骤

这些步骤似乎已经解决了问题:

  • 系统管理员使用Windows ICACLS命令重置ntfs权限:(在此示例中,“acme”是新创建的目录。此命令设置acme及其子级重新继承文件夹“d:\ instances”的权限

    d:\实例> icacls acme / RESET / T / C / Q

  • 系统管理员开始服务

结果:   Windows服务启动

问题

  • 是什么让cygwin处理新写入文件的权限与powershell不同?这是一个错误的umask版本吗?
  • 系统管理员可以提前采取措施确保cygwin正确设置权限吗?

提前致谢

2 个答案:

答案 0 :(得分:2)

我找到了答案here;它指的是this邮件列表信。

你需要编辑Cygwin的/ etc / fstab并添加" noacl"到mount-options列表。

答案 1 :(得分:-1)

这里补充一下ulathek的答案是两个网址的复制粘贴:

首先:

How to fix incorrect Cygwin permission in Windows 7

Cygwin started to behave quite strangely after recent updates. I was not able to edit files in vim, because it was complaining that files are read only. Even cp -r didn’t work correctly. Permission of new directory was broken and I was not able to remove it. Pretty weird behavior.

E.g. ls -l

total 2
----------+ 1 georgik None 34 Jul 14 18:09 index.jade
----------+ 1 georgik None 109 Jul 14 17:40 layout.jade

Hm. It is clear that something is wrong with permission. Even owner has no permission on those files.

Output of mount command:

C: on /cygdrive/c type ntfs (binary,posix=0,user,noumount,auto)

I found a solution at cygwin forum. It’s quite easy to fix it.

Open /etc/fstab and enter following line:

none /cygdrive cygdrive binary,noacl,posix=0,user 0 0

Save it. Close all cygwin terminals and start new terminal.

Output of mount:

C: on /cygdrive/c type ntfs (binary,noacl,posix=0,user,noumount,auto)

Output of ls -l

total 2
-rw-r--r-- 1 georgik None 34 Jul 14 18:09 index.jade
-rw-r--r-- 1 georgik None 109 Jul 14 17:40 layout.jade

第二:

7/14/2010 10:57 AM
> Drive Y is a mapping to a network location. Interestingly, ls -l
>> /cygdrive returns:
>>   d---------+ 1 ????????       ????????     24576 2010-07-09 11:18 c
>>   drwx------+ 1 Administrators Domain Users     0 2010-07-14 06:58 y
>>
>> The c folder looks weird, the y folder looks correct.
>>     
> Try ls -ln /cygdrive.  The user and group ownerships on the root of the
> C: drive are most likely not found in your passwd and group files.  The
> -n option for ls will print the user and group IDs rather than try to
> look up their names.  Unfortunately, I can't think of any way offhand to
> generate the passwd and group entries given only user and group IDs.
> Maybe someone else can comment on that.
>   

I think your answer is correct:
  $ ls -ln /cygdrive
  total 24
  d---------+ 1 4294967295 4294967295 24576 2010-07-09 11:18 c
  drwx------+ 1        544      10513     0 2010-07-14 11:45 y

I edited my /etc/fstab file (it contained only commented lines) and
added this line at the end of the file:
  none /cygdrive cygdrive binary,noacl,posix=0,user 0 0

I closed all my Cygwin processes, opened a new terminal and did an ls-l
on visitor.cpp again:
  -rw-r--r-- 1 cory Domain Users 3236 2010-07-11 22:37 visitor.cpp

Success!!! The permissions are now reported as 644 rather than 000 and I
can edit the file with Cygwin vim and not have bogus read-only issues.
Thank you Jeremy.

cory