From d9c9095789d1ea31faef0f485b16b20070c6496c Mon Sep 17 00:00:00 2001 From: Will Wang Date: Tue, 23 Jul 2024 23:06:37 +0800 Subject: [PATCH] Update cli/config/configfile/file.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit use filepath.EvalSymlink instead of check with filepath.IsAbs Co-authored-by: Paweł Gronowski --- cli/config/configfile/file.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/cli/config/configfile/file.go b/cli/config/configfile/file.go index 2fa34f909437..a94451e7813a 100644 --- a/cli/config/configfile/file.go +++ b/cli/config/configfile/file.go @@ -169,12 +169,8 @@ func (configFile *ConfigFile) Save() (retErr error) { // Handle situation where the configfile is a symlink cfgFile := configFile.Filename - if f, err := os.Readlink(cfgFile); err == nil { + if f, err := filepath.EvalSymlinks(cfgFile); err == nil { cfgFile = f - // The target of a symlink can be a relative path, ensure the final path is absolute - if !filepath.IsAbs(f) { - cfgFile = filepath.Join(dir, f) - } } // Try copying the current config file (if any) ownership and permissions