Open kurochan opened 5 months ago
The reason for adding os.Ctimes() is to simulate a modification. Only then guest can understand that a change happened for that file
@balajiv113 I understand your point. I was investigating to isolate the cause of this problem.
As a result, I have noticed that chmod fails regardless of whether or not os.Ctimes()
is done.
As a result, I have noticed that chmod fails regardless of whether or not os.Ctimes() is done.
Exactly, this is what i was expecting. Our code related to inotify should not have any impact in unzip flow. This will be mostly a change needed from unzip itself or the mount type (virtiofs / 9p) doesn't support it.
FYI: I tried to decompress a tar.gz file with permission and this was working fine
I reproduced with tar.gz. Perhaps it has something to do with file size. Small file sizes(e.g. 1KB) did not cause errors.
kuro@lima-debug-inotify:/tmp/lima$ dd if=/dev/urandom of=test.bin bs=50M count=1
1+0 records in
1+0 records out
52428800 bytes (52 MB, 50 MiB) copied, 0.110755 s, 473 MB/s
kuro@lima-debug-inotify:/tmp/lima$ chmod +x test.bin
kuro@lima-debug-inotify:/tmp/lima$ tar zcvf test.tar.gz test.bin
test.bin
kuro@lima-debug-inotify:/tmp/lima$ tar zxvf ./test.tar.gz
test.bin
tar: test.bin: Cannot utime: Operation not permitted
tar: Exiting with failure status due to previous errors
strace result:
kuro@lima-debug-inotify:/tmp/lima$ strace tar zxvf ./test.tar.gz
...[snip]
write(4, "\3519\34a\244\2300\4\304\236GO\202\241\256\vK\361\213\224v\250\355x\341\237\204Se\373-\355"..., 512) = 512
utimensat(4, NULL, [UTIME_OMIT, {tv_sec=1719503700, tv_nsec=0} /* 2024-06-28T00:55:00+0900 */], 0) = -1 EPERM (Operation not permitted)
write(2, "tar: ", 5tar: ) = 5
write(2, "test.bin: Cannot utime", 22test.bin: Cannot utime) = 22
write(2, ": Operation not permitted", 25: Operation not permitted) = 25
tar throws for utime only. But the file should be unzipped with proper permission
Overview
After enabling the
mountInotify
feature, files on virtiofs faied to chmod under specific conditions. I tried some debugging but could not figure out the cause.Environment
$ uname -v Darwin Kernel Version 23.5.0: Wed May 1 20:17:33 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6031
vmType: "vz" networks:
images:
mounts:
2. Create a VM
3. Download zip file(ex. terraform) and extract
The error
fchmod (file attributes) error: Operation not permitted
occurred and the binaryterraform
does not have executable flag. However, afterchmod +x
manually, it have executable flag.Debug
strace
fchmod(4, 0100755) = -1 EPERM (Operation not permitted)
seems failed to chmod.Customize
guestagent
I implemented three types of function
HandleInotify
. https://github.com/lima-vm/lima/blob/38c62c5e815fdc93e6e88543be1eb9ef7699eaf5/pkg/guestagent/guestagent_linux.go#L337-L346a. Remove
os.Ctimes()
This causes the same issue.
b. Remove everything
This does NOT cause problems.
c. Insert delay before
os.Stat()
This does NOT cause problems. (100ms is bad, but 500ms or later is ok)