From 4dc442a9570fed747a7006920edbf3c15acf1f82 Mon Sep 17 00:00:00 2001 From: et-nik Date: Mon, 1 May 2023 20:31:18 +0200 Subject: [PATCH] fix chownR, skip invalid symlink --- internal/app/game_server_commands/os_utils_unix.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/app/game_server_commands/os_utils_unix.go b/internal/app/game_server_commands/os_utils_unix.go index 4c34e1b..5cdfc68 100644 --- a/internal/app/game_server_commands/os_utils_unix.go +++ b/internal/app/game_server_commands/os_utils_unix.go @@ -20,11 +20,16 @@ func chownR(path string, uid, gid int) error { } if info.Mode()&os.ModeSymlink != 0 { - _, err = os.Readlink(name) + symlinkFile, err := os.Readlink(name) if err != nil { // Ignore invalid symlink return nil } + + if _, err = os.Stat(symlinkFile); err != nil { + // Ignore invalid symlink + return nil + } } return os.Chown(name, uid, gid)