简体   繁体   English

在没有root用户的情况下更改cpio归档文件中的所有权

[英]Change ownership in cpio archive without root

I need to add files to an initramfs file(I own the file as this is for some other device), however I do not have root permissions on my development machine. 我需要将文件添加到initramfs文件中(我拥有该文件,因为它是用于其他设备的文件),但是我在开发计算机上没有root权限。 The usual way would be to unpack the initramfs, add files, change owner to root and pack again. 通常的方法是解压缩initramfs,添加文件,将所有者更改为root并再次打包。 I can not do this, as changing owner on this machine would require root permissions. 我无法执行此操作,因为更改此计算机上的所有者将需要root权限。 If I do not change owner the system might behave weird(and it is just not a clean setup). 如果我不更改所有者,则系统可能会表现得很奇怪(这不是一个干净的设置)。

I can not do this on the target system as it is an embedded system, which only has read only access to the initramfs file. 我无法在目标系统上执行此操作,因为它是嵌入式系统,仅对initramfs文件具有只读访问权限。

Is there any way to change the permissions during or after packing the cpio archive? 在打包cpio归档文件期间或之后,是否可以更改权限?

Use fakeroot to deal with permissions during extraction and compression. 在提取和压缩过程中使用fakeroot处理权限。 it is developed to provide root environment without actually being root. 它被开发来提供根环境,而无需实际成为根。

girishp@~/incoming$ /usr/bin/fakeroot /bin/bash
root@~/incoming$

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM