delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/04/08/21:10:28

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <3CB23EF3.1040504@cornell.edu>
Date: Mon, 08 Apr 2002 21:08:03 -0400
From: Ivan Dobrianov <id11 AT cornell DOT edu>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.9) Gecko/20020311
X-Accept-Language: en-us, en
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
CC: awc AT bitmover DOT com, gmargo AT yahoo DOT com
Subject: Re: tar won't restore permissions

Ok, I posted this question more than a year ago ... and the problem is 
still present in the latest Cygwin builds:

tar xpvf myArchive.tar

will not restore read-only permissions, i.e. files with r-- perms will 
get rw- permission when restored!!! I am seeing this on Win NT, 2000, 
and XP on FAT32 and NTFS with and without setting $CYGWIN to ntea or 
ntfs. This used to work right in the days of B20.

I. To see the bug:
1) copy the follwing text to a file called "demo"
-----------------------------------------------------
echo " "

[ -d tar_bug ] || mkdir tar_bug
cd tar_bug
rm -rf *

cat > myFile<<EOF
qwerty
EOF

chmod 444 myFile
ls -l myFile

tar cvf myArchive.tar myFile
tar tvf myArchive.tar

sleep 2

mkdir untarred
cd untarred
tar xpvf ../myArchive.tar -U

ls -l
--------------------------------------------------------
2) Do:
sh demo

3) I get the follwing output:
--------------------------------------------------------
-r--r--r--   1 administ None            8 Jan 20 11:55 myFile
myFile
-r--r--r-- administrator/None 8 2001-01-20 11:55:14 myFile
myFile
total 0
-rw-r--r--   1 administ None            8 Jan 20 11:55 myFile
--------------------------------------------------------

*** Note that myFile is writable in the end! ***

NOTE: Yes, if you "CYGWIN=ntea" under NTFS, the problem _SEEMS_ to get 
fixed, but upon inspection, with say Explorer, it turns out the file is 
still writable - the problem is just being masked!

II. The fix.

Well, I have a tweaked version of tar-1.13.19-1 which seems to work 
fine. Here is the hacky patch of extract.c that does the trick
--------------------------------------------------------
~/tar_fix > diff extract.c_DUP_00 extract.c
125a126,127
 >   /* printf ("File: %s\n", file_name); */
 >
135c137,139
<       if (permstatus == ARCHIVED_PERMSTATUS
---
 >       /* Ivan says: for whatever reason the caller THINKS the mode is ok,
 >          but it is not, at least under Win NT w/ cygwin */
 >       if (0 && permstatus == ARCHIVED_PERMSTATUS
158a163,164
 >
 >   /* printf ("File: %s -> mode: %o\n", file_name, mode); */
~/tar_fix >
--------------------------------------------------------

I don't know if this is the "right" way to fix the problem - probably it 
is not!  I'll leave it to more knowledgeable people to do the real thing 
  ... or point the workaround that has been eluding me for that past 
year and more :-)


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019