Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maintain file and folder permissions inside archives

Tags:

I am packaging and distributing a program I made for Windows,Linux and Mac. I plan to put the files and folders in zip archives.

If I set the correct folder and file permissions and then compress into zip and redistribute them, will those permissions be maintained when the user extracts them in Linux or Mac systems ? Or do they have to set the permissions themselves ?

like image 742
ajaybc Avatar asked May 24 '12 10:05

ajaybc


People also ask

How do you preserve permissions?

Preserve File Permissions Using cp You can use the -p option of cp to preserve the mode, ownership, and timestamps of the file. However, you will need to add the -r option to this command when dealing with directories. It will copy all sub-directories and individual files, keeping their original permissions intact.

What are the 5 different file and folder permissions?

There are basically six types of permissions in Windows: Full Control, Modify, Read & Execute, List Folder Contents, Read, and Write.


2 Answers

zip does not store file permissions in the archive.

tar archives will preserve file permissions on Linux and OS X. I have no idea what happens on Windows. If you can test things out on Windows and it works, this is probably your best bet. It probably depends on what tool people use to unpack the archives.

Another option would be to create an installer, although there are few non-commercial options for creating cross-platform installers. Wikipedia has a list.

like image 120
larsks Avatar answered Sep 28 '22 03:09

larsks


An installer is your best option here. Lets me explain a bit better why.

Windows has these permissions:

Modify Read & Execute Read Write 

Which are assigned to Groups or Usernames,

Unix based systems have:

Read Write  Execute 

Which can be assigned to owner, group and others.

Has you can see, its difficult to map permissions from one system to another, since the filesystems handle permissions differently.

However some zip utilities like Info-Zip supports Unix based filesystem features, such as user and group IDs, file permissions, and support for symbolic links. It also support NTFS filesystem permissions, and will make an attempt to translate from NTFS permissions to Unix permissions or vice-versa when extracting files. This can result in potentially unintended combinations, e.g. .exe files being created on NTFS volumes with executable permission denied.*

If you are planning on distributing your program, an installer is indeed your best solution.

*From wikipedia: Zip (file format)

like image 32
aemus Avatar answered Sep 28 '22 02:09

aemus