Skip to content

Commit 8d2069e

Browse files
committed
Handle qemu binaries being symlinks
1 parent 9825cbc commit 8d2069e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

builder/step_setup_qemu.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ func checkBinfmtMisc(srcPath string) (string, error) {
1919
return "", fmt.Errorf("failed to read /proc/sys/fs/binfmt_misc directory: %v", err)
2020
}
2121

22+
srcPathStat, _ := os.Stat(srcPath)
2223
for _, file := range files {
2324
if file.Name() == "register" || file.Name() == "status" {
2425
continue
@@ -36,8 +37,12 @@ func checkBinfmtMisc(srcPath string) (string, error) {
3637
continue
3738
}
3839

39-
if fields[0] == "interpreter" && fields[1] == srcPath {
40-
return pth, nil
40+
if fields[0] == "interpreter" {
41+
fieldStat, _ := os.Stat(fields[1])
42+
// os.SameFile allows also comparing of sym- and relativ symlinks.
43+
if os.SameFile(fieldStat, srcPathStat) {
44+
return pth, nil
45+
}
4146
}
4247
}
4348
}

0 commit comments

Comments
 (0)