cygwin 的 `tar` 如何将 `c:\Users\MyUserName` 的所有权更改为 `SYSTEM`?

cygwin 的 `tar` 如何将 `c:\Users\MyUserName` 的所有权更改为 `SYSTEM`?

最近发布关于c:\Users\MyUserName从 unix 根目录解压文件时失去对 的访问权限/。我已经接受了需要与 IT 人员讨论恢复访问权限的事实,所以我不再询问这个问题。但是,我对这种情况的发生感到困扰,显然是因为 的所有权c:\Users\MyUserName已更改为SYSTEM。我想知道这怎么可能。我将重复上述帖子中的一些背景细节。

我正在解压的是分布在 Windows 和 cygwin 文件树中的应用程序配置文件集合,全部打包成一个 zip 文件:

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我将文件树解压到临时工作目录中,然后从该目录发出以下复合命令:

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

执行此操作后,我无法再访问c:\Users\MyUserName,原因似乎是所有权更改为SYSTEM

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

请注意所有权是不是 SYSTEM在从 zip 文件解压的上述源文件树中。此外,我的 cygwin 安装是以非管理员身份安装的 ( )。这setup-x86_64.exe --no-admin似乎很奇怪tar.exe有能力的改变所有权c:\Users\MyUserNameSYSTEM更不用说更改。

我担心tar将来使用时可能会出现这种危险。这是一个非常奇怪的问题,以至于必须让 IT 人员恢复所有权几乎肯定会导致我的商店禁止使用 cygwin。更现实地说,我只会删除 的执行权限tar.exe,但对我来说,这是一个巨大的障碍。

在另一台机器上,我尝试使用测试文件树复制该问题(不是包括c:\Users\MyUserName),但无法复制该问题。

什么可以解释所有权的变更?我tar将来如何才能使用它同时避免危险?

请注意,由于批准安装软件的流程繁琐且不可靠,我使用的是 2015 版 Cygwin。我过去对该问题的故障排除记录在本文开头的开篇链接的网站上。

相关内容