proot icon indicating copy to clipboard operation
proot copied to clipboard

GNU tar: "file changed as we read it"

Open orent opened this issue 10 years ago • 2 comments

Step to reproduce:

echo >1      # not touch, size must be >0
chmod -w 1   # must be read only
proot -0 tar -cf 1.tar 1
/bin/tar: 1: file changed as we read it

Notes: This happens only on older versions of GNU tar (happns on 1.23 but not on 1.26). According to strace the newer version uses newfstatat() rather than stat().

orent avatar Jun 15 '14 09:06 orent

Hello @orent,

Thanks for the bug report.

I confirm; the -0 option of PRoot changes permissions right before a file is accessed by a process, and restores them rigth after. See this article [1] for further details. The fix is to reset the modification time once the permissions are restored. I'm looking at this.

Regards, Cédric.

[1] http://ivoire.dinauz.org/blog/post/2013/11/21/Pretending-to-be-root-inside-PRoot

cedric-vincent avatar Jun 16 '14 12:06 cedric-vincent

It looks like the code unconditionally override the permissions even when the file is opened for read-only access and no change in permission is necessary.

orent avatar Jun 23 '14 08:06 orent