proot
proot copied to clipboard
GNU tar: "file changed as we read it"
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().
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
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.