Update cli/config/configfile/file.go

use filepath.EvalSymlink instead of check with filepath.IsAbs

Co-authored-by: Paweł Gronowski <me@woland.xyz>
Signed-off-by: Will Wang <willww64@gmail.com>
This commit is contained in:
Will Wang 2024-07-23 23:06:37 +08:00
parent c90705a413
commit 115fdd979b
No known key found for this signature in database
GPG Key ID: 777CB89880638858
1 changed files with 1 additions and 5 deletions

View File

@ -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