Linux 维护档案内的文件和文件夹权限
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10735297/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Maintain file and folder permissions inside archives
提问by ajaybc
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.
我正在打包和分发我为 Windows、Linux 和 Mac 制作的程序。我计划将文件和文件夹放在 zip 档案中。
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 ?
如果我设置正确的文件夹和文件权限,然后压缩成 zip 并重新分发它们,当用户在 Linux 或 Mac 系统中解压缩它们时,这些权限是否会保留?还是他们必须自己设置权限?
采纳答案by larsks
zip
does not store file permissions in the archive.
zip
不在存档中存储文件权限。
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.
tar
archives 将保留 Linux 和 OS X 上的文件权限。我不知道在 Windows 上会发生什么。如果您可以在 Windows 上进行测试并且可以正常工作,那么这可能是您最好的选择。这可能取决于人们使用什么工具来解压档案。
Another option would be to create an installer, although there are few non-commercial options for creating cross-platform installers. Wikipedia has a list.
另一种选择是创建安装程序,尽管用于创建跨平台安装程序的非商业选项很少。维基百科有一个列表。
回答by aemus
An installer is your best option here. Lets me explain a bit better why.
安装程序是您最好的选择。让我更好地解释一下为什么。
Windows has these permissions:
Windows 具有以下权限:
Modify
Read & Execute
Read
Write
Which are assigned to Groups or Usernames,
分配给组或用户名,
Unix based systems have:
基于 Unix 的系统具有:
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.*
然而,一些 zip 实用程序(如 Info-Zip)支持基于 Unix 的文件系统功能,例如用户和组 ID、文件权限以及对符号链接的支持。它还支持 NTFS 文件系统权限,并会在提取文件时尝试从 NTFS 权限转换为 Unix 权限,反之亦然。这可能会导致潜在的意外组合,例如在 NTFS 卷上创建的 .exe 文件可执行权限被拒绝。*
If you are planning on distributing your program, an installer is indeed your best solution.
如果您计划分发您的程序,安装程序确实是您的最佳解决方案。
*From wikipedia: Zip (file format)
*来自维基百科:Zip(文件格式)