如何使用 Perl 的 Archive::Tar 保留 tar 存档中的 setuid 位?
我正在使用 Perl 的 Archive::Tar 模块。 它保留文件权限,但不保留粘滞位。 在我提取存档的另一端,所有粘性位都消失了。 我认为 UNIX/LINUX 操作系统将这些粘性位存储在其他地方。 如何让我的存档也保留粘性位?
使用 -p 开关 tar 可以保留它,但是如何使用 Archive::Tar? 我在两边都使用 Perl 的模块。
I'm using Perl's Archive::Tar module. It preserves the file permissions but doesn't preserve the sticky bit. At the other end where I extract the archive, all the sticky bits are gone. I think UNIX/LINUX operating system stores these sticky bits somewhere else. How can I make my archive preserve sticky bits also?
Using the -p switch to tar preserves it but how do I do it using Archive::Tar? I'm using Perl's module on both the sides.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
根据 Fine Source 的说法,Archive::Tar::File 会去除模式中的高位。
您可以在脚本的开头尝试以下魔法咒语(在任何内容之前)
可能引用了 Archive::Tar) 并看看是否会颠覆它:
简要说明:STRIP_MODE 是一个常量,其中包含一个可以传递原始模式并返回应该存储的模式的子例程。 它通常设置为
因为它是一个常量,从 Archive::Tar::Constant 导入到 Archive::Tar::File 并在那里使用,所以无论设置为什么,都将内联到 Archive::Tar::File 中已编译。 因此,要更改它,必须在内联之前更改常量,即在加载 Archive::Tar::File 之前。
注意:由于更改内联常量很容易出错(在为时已晚而无法产生任何效果后更改它),因此它通常会生成严重警告,并且无法通过常规方法禁用。
According to the Fine Source, Archive::Tar::File strips off the high bits from the mode.
You can try the following magic incantation at the beginning of your script (before anything
might have referenced Archive::Tar) and see if that subverts it:
Brief explanation: STRIP_MODE is a constant that contains a subroutine that can be passed the raw mode and returns the mode that should be stored. It is normally set to
Because it is a constant, imported from Archive::Tar::Constant into Archive::Tar::File and used there, whatever it is set to will be inlined into Archive::Tar::File as it is compiled. So to change it, the constant must be changed before it is inlined, that is, before Archive::Tar::File ever gets loaded.
N.B. Because changing an inlinable constant is prone to error (changing it after it is too late to have any effect), it normally generates a severe warning that can't be disabled by usual means.
不确定,但在官方 tar 命令上,您需要传递 -p 才能实现此目的
Not sure, but on the official tar command, you need to pass -p to make this happen
您可能需要查看 Archive::Tar 文档 了解详细信息。 乍一看,似乎
应该执行您想要的操作,尽管文档声称上述设置是默认设置。 Archive::Tar 可能会像粘性位一样剥离高阶模式位。
存档是使用 Archive::Tar 创建和提取的,还是在一端或另一端使用标准 tar 程序?
You might want to take a look at the Archive::Tar documentation for the details. From a brief glance, it appears that
should do what you want, although the documentation claims that the above setting is the default. It may be that Archive::Tar strips off the higher-order mode bits like the sticky bit.
Is the archive both created and extracted with Archive::Tar, or are you using the standard tar program at one end or the other?