How can cygwin's `tar` change ownership of `c:\Users\MyUserName` to `SYSTEM`?

1

I recently posted about losing access to c:\Users\MyUserName by untarring files from the unix root directory /. I am resigned to the fact that I need to talk to the IT folks about recovering access, so I am no longer asking about that. However, I am troubled by the fact that this has happened, apparently because the ownership of c:\Users\MyUserName got changed to SYSTEM. I'm wondering how this is possible. I will necessarily repeat some of the background details from the aforementioned posting.

The thing I was untarring was a collection of apps configuration files distributed throughout the Windows and cygwin file tree, all packed into a zip file:

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

I unpacked the file tree into a temporary working directory, then issue the following compound tar command from that directory:

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

After doing this, I lost access to c:\Users\MyUserName, and it seems that the reason is that the ownership changed to SYSTEM:

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

Note that the ownership is not SYSTEM in the above source file tree that was unpacked from the zip file. As well, my cygwin installation was installed as a non-administrator (setup-x86_64.exe --no-admin). It seems very odd that tar.exe is able to change the ownership of c:\Users\MyUserName to SYSTEM, much less would change it.

I am concerned about this possible hazard with my using tar in the future. It is such an odd problem that having to get IT folks to restore ownerships is almost a sure-fire way to get cygwin banned in my shop. More realistically, I would just remove execute permission from tar.exe, but to me, that is a huge handicap.

On another machine, I tried to duplicate the problem using test file trees (not including c:\Users\MyUserName), but have not been able to replicate the problem.

What could possibly explain the change of ownership, and how can I still use tar in the future while avoiding the hazard?

Note that due to arduous and tenuous processes for approving software for installation, I am using a 2015 version of Cygwin. My past troubleshooting of the problem is documented on the site linked to in my opening sentence at the top of this posting.

user36800

Posted 2017-11-25T22:26:01.177

Reputation: 147

Why are you reposting your question after only 24 hours? – Ramhound – 2017-11-25T22:33:36.253

2The user profile directories in Windows are owned by System by default, and it does not cause any user to loose access. – kreemoweet – 2017-11-25T22:42:48.397

@Ramhound: It's a different question. The page that I cited here asks how to recover permissions, whereas this question is about whether anyone can explain how tar can do this, with the aim of being able to use tar in the future (and not draw the ire of IT folk). – user36800 – 2017-11-26T00:49:25.273

@kreemoweet: Nice name! :) Your comment was very illuminating. I said that I wasn't able to replicate the problem in a different machine. Well that machine shows that c:\Users\MyUserName also is owned by SYSTEM, and I don't have the same permission problem. This confirms your comment. But in light of that, would you be able to comment on what exactly is causing the permission problem, if it isn't the ownership? My suspicion is that owner has rwx permissions on the problematic machine, but group does not (in contrast to the working machine). I'll try to fix it with chmod on Monday. – user36800 – 2017-11-26T00:53:49.800

Though I must say, it seems odd for the group permissions to be rwx...it is, after all, an individual's account. It's also odd that in the listing of the files in the posted question, the owner is show as MyUserName, which doesn't corroborate the fact that c:\Users\MyUserName is owned by SYSTEM. However, that might be just the cygwin translation of ownership (right?) – user36800 – 2017-11-26T00:55:49.903

For the record, owner of /c/Users/MyUserNam shows as MyUserName, and the group is Domain Users, when using ls -l and stat. The only way that I have found to actually SYSTEM as owner is to pull up the folder's Properties->Security(tab)-> Advanced(button)-> Owner(tab). Not sure why there is this discrepancy, and I'm assuming that it is due to cygwin's translation of NT secruity parameters to something that unix users would find familiar. – user36800 – 2017-11-30T13:00:03.683

EGAD! The above is "slightly" wrong. The owner & group actually show as SYSTEM using ls -ld and stat on /c/Users/MyUserName. In contrast, owner and group show as MyUserName and Domain Users when using those same commands on c:/Users/MyUserName. Very odd! – user36800 – 2017-11-30T13:10:20.290

No answers