无法访问 Windows 主文件夹,可能是使用 cygwin 解压到该文件夹​​导致的

无法访问 Windows 主文件夹,可能是使用 cygwin 解压到该文件夹​​导致的

我将一大堆配置文件存储在一个 zip 文件中,涵盖我的 Windows 7 用户文件树和我的 cygwin 用户文件树。

例如

drwx------+ 1 MyUserName Domain Users     0 Nov 24 15:21 c
drwx------+ 1 MyUserName Domain Users     0 Nov 24 15:21 c/Users
drwx------+ 1 MyUserName Domain Users     0 Nov 24 16:12 c/Users/MyUserName
drwx------+ 1 MyUserName Domain Users     0 Nov 24 16:34 c/Users/MyUserName/Documents
-rwxrwx---  1 MyUserName Domain Users 32464 Jul 28 17:41 c/Users/MyUserName/Documents/_viminfo
-rwxrwx---  1 MyUserName Domain Users 15092 Jul 27 13:42 c/Users/MyUserName/Documents/_vimrc
drwx------+ 1 MyUserName Domain Users     0 Nov 24 16:11 c/Users/MyUserName/Documents/vimfiles
-rwxrwx---  1 MyUserName Domain Users   315 Oct 15  2016 c/Users/MyUserName/Documents/vimfiles/.netrwhist
drwx------+ 1 MyUserName Domain Users     0 Nov 24 15:21 c/Users/MyUserName/Documents/vimfiles/after
drwx------+ 1 MyUserName Domain Users     0 Nov 24 15:21 c/Users/MyUserName/Documents/vimfiles/after/ftplugin
-rwxrwxr-x  1 MyUserName Domain Users    39 Feb  9  2016 c/Users/MyUserName/Documents/vimfiles/after/ftplugin/netrw.vim
drwx------+ 1 MyUserName Domain Users     0 Nov 24 15:21 c/Users/MyUserName/Documents/vimfiles/after/syntax
-rwxrwxr-x  1 MyUserName Domain Users    28 Jun 19  2013 c/Users/MyUserName/Documents/vimfiles/after/syntax/tex.vim
drwx------+ 1 MyUserName Domain Users     0 Nov 24 15:21 c/Users/MyUserName/Documents/vimfiles/colors
-rwxrwx---  1 MyUserName Domain Users  5006 May 27  2016 c/Users/MyUserName/Documents/vimfiles/colors/mine.vim
drwx------+ 1 MyUserName Domain Users     0 Nov 24 15:21 c/Users/MyUserName/Documents/vimfiles/plugin
-rwxrwxr-x  1 MyUserName Domain Users 26547 Sep 17  2014 c/Users/MyUserName/Documents/vimfiles/plugin/bufexplorer.vim
-rw-------  1 MyUserName Domain Users  3024 Jan 26  2015 c/Users/MyUserName/Documents/vimfiles/plugin/ChristiansHi20150126.vim
drwx------+ 1 MyUserName Domain Users     0 Nov 24 15:21 c/Users/MyUserName/Documents/vimfiles/spell
-rwxrwxr-x  1 MyUserName Domain Users   963 Sep  8  2014 c/Users/MyUserName/Documents/vimfiles/spell/en.latin1.add
drwx------+ 1 MyUserName Domain Users     0 Nov 24 15:21 c/Users/MyUserName/Documents/vimfiles/syntax
-rw-r--r--  1 MyUserName Domain Users  8870 Feb 13  2015 c/Users/MyUserName/Documents/vimfiles/syntax/asy.vim
-rwxrwxr-x  1 MyUserName Domain Users  2749 Jul 30  2013 c/Users/MyUserName/Documents/vimfiles/syntax/texmf.vim
-rwxrwxr-x  1 MyUserName Domain Users 33322 Jun  8  2011 c/Users/MyUserName/Documents/vimfiles/syntax/vbnet.vim
drwx------+ 1 MyUserName Domain Users     0 Nov 24 15:21 etc
-rwxrwx---  1 MyUserName Domain Users   518 Dec  4  2014 etc/fstab
-rw-r--r--  1 MyUserName Domain Users   192 Aug 19  2014 etc/fstab.cygwin64default
drwx------+ 1 MyUserName Domain Users     0 Nov 24 15:21 etc/fstab.d
-rwxrwx---  1 MyUserName Domain Users     0 Aug  4  2011 etc/fstab.d/SomeUserName
drwx------+ 1 MyUserName Domain Users     0 Nov 24 15:21 home
drwx------+ 1 MyUserName Domain Users     0 Nov 24 15:21 home/MyUserName
-rwx------  1 MyUserName Domain Users  1852 Aug 21 14:21 home/MyUserName/.alias.bash
-rwx------  1 MyUserName Domain Users  1503 Aug 19  2014 home/MyUserName/.alias.csh
lrwxrwxrwx  1 MyUserName Domain Users     7 Nov 24 15:21 home/MyUserName/.bash_login -> .bashrc
-rwxr-xr-x  1 MyUserName Domain Users  1150 Aug 19  2014 home/MyUserName/.bash_profile
-rwxr-xr-x  1 MyUserName Domain Users  2499 Jun 15  2015 home/MyUserName/.bashrc
-rwx------  1 MyUserName Domain Users  1904 Aug 19  2014 home/MyUserName/.cshrc
-rwxr-xr-x  1 MyUserName Domain Users    41 Aug 19  2014 home/MyUserName/.inputrc
-rw-r--r--  1 MyUserName Domain Users   101 Aug 19  2014 home/MyUserName/.minttyrc
-rwx------  1 MyUserName Domain Users   102 Jan 27  2015 home/MyUserName/.octaverc
-rwxr-xr-x  1 MyUserName Domain Users    65 Dec  2  2014 home/MyUserName/.pdfjam.conf
-rwxr-xr-x  1 MyUserName Domain Users   792 Aug 19  2014 home/MyUserName/.profile
-rw-------  1 MyUserName Domain Users    51 Jun 14  2015 home/MyUserName/.Renviron
-rw-------  1 MyUserName Domain Users   706 Apr 20  2015 home/MyUserName/.Rprofile
-rwx------  1 MyUserName Domain Users    58 Jun 16  2015 home/MyUserName/.startxwinrc
-rwx------  1 MyUserName Domain Users  9521 Aug 19  2014 home/MyUserName/.twmrc
-rwx------  1 MyUserName Domain Users  9306 Aug 19  2014 home/MyUserName/.twmrc.alt
-rwx------  1 MyUserName Domain Users  1803 May  1  2015 home/MyUserName/.Xresources
drwx------+ 1 MyUserName Domain Users     0 Nov 24 15:21 home/MyUserName/bin
-rwxrwx---  1 MyUserName Domain Users   138 May 14  2012 home/MyUserName/bin/a2pdf.bash
-rwxrwx---  1 MyUserName Domain Users     8 Jan 25  2014 home/MyUserName/bin/bc.rc
-rwxrwx---  1 MyUserName Domain Users    29 Jan 25  2014 home/MyUserName/bin/dosbc
-rw-------  1 MyUserName Domain Users  1557 Nov  8  2013 home/MyUserName/bin/dvi2pdfa
-rwxrwx---  1 MyUserName Domain Users   349 Aug  2  2013 home/MyUserName/bin/pcvim
drwx------+ 1 MyUserName Domain Users     0 Nov 24 15:21 usr
drwx------+ 1 MyUserName Domain Users     0 Nov 24 15:21 usr/share
drwx------+ 1 MyUserName Domain Users     0 Nov 24 16:11 usr/share/vim
lrwxrwxrwx  1 MyUserName Domain Users    35 Nov 24 15:21 usr/share/vim/vimfiles -> /c/Users/MyUserName/Documents/vimfiles
lrwxrwxrwx  1 MyUserName Domain Users    33 Nov 24 15:21 usr/share/vim/vimrc -> /c/Users/MyUserName/Documents/_vimrc

我将所有内容解压到一个临时文件夹中,然后将它们复制到适当的位置,并从临时目录发出以下命令:

tar cf - * | ( cd / ; tar xf - )

我认为我造成了一个大问题。我怀疑所有解压的目录都覆盖了现有目录,目录的所有权已更改为 SYSTEM,包括 c:\Users\MyUserName。现在我甚至无法使用 Windows 资源管理器浏览我自己的 Windows 主文件夹。也就是说,我无法从 c:\ 开始并一路单击下去。我在 c:\Users\MyUserName 处收到权限被拒绝的提示,显然是因为所有权发生了变化:

$ls -ld /c/Users/MyUserName
drwx------+ 1 SYSTEM SYSTEM 0 2017-11-24 16:56 /c/Users/MyUserName

与上述情况相反,cygstart MyUserName从发出/c/Users可以正常打开 Windows 主目录,但它看起来像是处女帐户的主目录,不包含我所知道的应该在那里的任何东西。也许它是文件c:\users\MyUserName\Appdata\local\VirtualStore树的沙盒版本。

另一种可能性是,文件系统通过 fstab 挂载的方式导致权限混乱:

# For a description of the file format, see the Users Guide
# http://cygwin.com/cygwin-ug-net/using.html#mount-table

# This is default anyway:
# none /cygdrive cygdrive binary,posix=0,user 0 0
c: /c ntfs binary,posix=0,user,auto
d: /d ntfs binary,posix=0,user,auto
e: /e ntfs binary,posix=0,user,auto
f: /f ntfs binary,posix=0,user,auto
g: /g ntfs binary,posix=0,user,auto
i: /i ntfs binary,posix=0,user,auto
o: /o ntfs binary,posix=0,user,auto
r: /r ntfs binary,posix=0,user,auto
s: /s ntfs binary,posix=0,user,auto

我不太熟悉挂载文件系统的细节,所以我不确定上面的内容是否能说明什么。我的检查是使用 cygdrive 绕过 /c,但仍然会出现同样的问题:

$ls /cygdrive/c/Users/MyUserName/
ls: cannot open directory /cygdrive/c/Users/MyUserName/: Permission denied

如果我带着这个奇怪的权限/安全问题去找我的 IT 人员,他们可能会砍掉我的所有附属物,让我被解雇,并且再也不会让我摆弄 Microsoft Office 以外的任何东西。

作为非管理员,我可以做些什么来恢复对 c:\Users\MyUserName 的正常访问?

我不完全确定问题是否是由于解压到 c:\Users\MyUserName 造成的,但这是我目前唯一的怀疑。由于漫长而繁琐的审批流程,我安装了 2015 版的 cygwin。

答案1

正如 DavidPostill 所言,作为非管理员,我找不到任何方法来恢复对 Windows 主目录的访问权限。管理员必须这样做,事实上,他设置权限的尝试最初被拒绝了。我不确定他做了什么,但我相信他获得了文件夹树的所有权,然后将权限分配给我的用户帐户。

相关内容