Skip to content

Commit

Permalink
Update cli/config/configfile/file.go
Browse files Browse the repository at this point in the history
use filepath.EvalSymlink instead of check with filepath.IsAbs

Co-authored-by: Paweł Gronowski <[email protected]>
Signed-off-by: Will Wang <[email protected]>
  • Loading branch information
willww64 and vvoland committed Jul 23, 2024
1 parent c90705a commit 115fdd9
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions cli/config/configfile/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 115fdd9

Please sign in to comment.