tar -pz in Windows?
August 7, 2009 3:49 PM   Subscribe

I'm trying to find a procedure to create a zip file in Windows and preserve Unix file permissions from the original files...

I have a set of bash scripts to be archived, originally created on a linux machine with file permissions 755. Some people in our group are using Windows and if they archive the files then pass them back to a Linux user, the file permissions are lost, unzip extracts files with 644 permission, so an additional step is needed to execute them. No problem if the archival was preformed on linux, but not all members of our group are comfortable with it.

Situation is the same whether using the default XP "Send to compressed", or something like winRar or 7-zip, I can't find any option that will respect / preserve the UNIX permissions from Windows, anyone know of a way?
posted by oblio_one to Computers & Internet (10 answers total)
 
It's been ages since I've used Windows, but I thought it didn't have an equivalent of the execute bit? So that information has been lost as soon as you extract onto a Windows filesystem.
posted by hattifattener at 3:58 PM on August 7, 2009


Windows has its own access control system that's entirely different from file permissions on Unix. And the ZIP format doesn't support Unix file permissions in itself; that's an Info-ZIP extension (Info-ZIP is the unzip implementation most commonly used on Unix). And since Windows Zip utilities usually pick up the permissions from the host system (which doesn't support Unix permission flags) and encode them using the standard format (which doesn't support Unix permission flags), there's no simple solution to your problem.

As a first intermediate step, I'd suggest providing an unpacking script that unpacks the zip file and fixes the privileges as necessary. That's a two line script. (An alternative would be to provide a custom Zip utility for your Windows users, but that's a lot more work).

Next, I'd train the team to use a version management system to transfer files between developers. Many system (including Subversion, Perforce, etc) can handle basic file permissions independently of the host system they're being used on.
posted by effbot at 4:07 PM on August 7, 2009 [1 favorite]


.Zip functions as both a container and compression, and historically it came from platforms which really didn't have user permissions. The UNIX tools actually don't do this alone either, but they have a shell which allows combination of commands; you use tar to glue all the files and permissions into a single archive, then gzip to compress it.

Given the nature of the content, I'm 2nd'ing effbot's suggestion to use SVN. TortoiseSVN is easy to set up. If it's not the case that people are changing the bash script, then separate the scripts from the data they operate on.
posted by pwnguin at 4:39 PM on August 7, 2009


Archiving is different from compressing. Perhaps your users can bundle the files into a tar archive, before compression with gzip. See GNUWin32 utilities for 32-bit Windows versions of tar and gzip.

As an added bonus, archiving before compression will save more disk space, than archiving individually compressed files.
posted by Blazecock Pileon at 4:51 PM on August 7, 2009


Ain't gonna happen. In each script include a line (such as you would for chkconfig attributes) that has the required permissions (four-digit octal style), then write a script that is always included with the archive that will go through and set permissions after unpacking. There simply is no connection between Windows and Unix permissions, and each are ignored--if not destroyed--by the other.
posted by rhizome at 5:05 PM on August 7, 2009


Make tar.gz's on linux, then let the Windows team use Cygwin (linux on Windows) to unpack them in a Windows-accessible location (Cygwin path "/cygdrive/X" = Windows "X:" drive). Use cygwin's tar to repack the files and scp to transfer them back to Linux. You should be able to use nearly the same bash script on both sides to automate whatever the users aren't comfortable with.

2nding effbot - you should really be using a version management system if these are developers rather than sending around zip files.
posted by benzenedream at 5:06 PM on August 7, 2009


Just chiming in to second effbot: sharing between developers by zipping up files is The Wrong Way To Do Itâ„¢. Set up subversion (Perforce is nice, but not free) and get your Windows users comfortable with TortoiseSVN. It integrates with the explorer shell, so shouldn't be too difficult to pick up. On the UNIX side, you simply sync from the repo to get the latest versions. You get the added bonus of accountability, a changelog, ability to revert, etc.
posted by cj_ at 5:49 PM on August 7, 2009


Good lord. Use version control.

You can even use git or another distributed VC and nobody has to run a dedicated server.

And to answer your question: Windows doesn't know what a file permission is. I've never met a Windows zip program that understands permissions. I'm actually continually surprised that unix zip manages to capture them.
posted by Netzapper at 1:34 AM on August 8, 2009


Windows absolutely does know what a file permission is. NTFS ACLs are a lot more flexible/powerful than the "classic" Unix user-group-other paradigm.
posted by Lazlo at 6:53 PM on August 8, 2009


Windows absolutely does know what a file permission is. NTFS ACLs are a lot more flexible/powerful than the "classic" Unix user-group-other paradigm.

An access control list is not equivalent to unix file permissions.

The fact that you can implement unix permissions with ACLs is irrelevant. They aren't the same. And Windows doesn't convert between the two. (In fact, even if you use ACLs (provided by SElinux, although nobody uses them) on linux, they aren't converted between the two.)
posted by Netzapper at 7:30 PM on August 8, 2009


« Older Life is a semi-colon; it is only a pause.   |   Name this type of glove please Newer »
This thread is closed to new comments.