Skip to content

Commit 339287f

Browse files
smarterclaytonmfojtik
authored andcommitted
UPSTREAM: 54979: When cert dir is relative, cert rotation builds incorrect symlinks
Symlinks relative to a working directory were being constructed to the wrong location, leading to failure to refresh client certs.
1 parent 5b8f4aa commit 339287f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

staging/src/k8s.io/client-go/util/certificate/certificate_store.go

+7
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,13 @@ func (s *fileStore) updateSymlink(filename string) error {
266266
return fmt.Errorf("file %q does not exist so it can not be used as the currently selected cert/key", filename)
267267
}
268268

269+
// Ensure the source path is absolute to ensure the symlink target is
270+
// correct when certDirectory is a relative path.
271+
filename, err := filepath.Abs(filename)
272+
if err != nil {
273+
return err
274+
}
275+
269276
// Create the 'updated' symlink pointing to the requested file name.
270277
if err := os.Symlink(filename, updatedPath); err != nil {
271278
return fmt.Errorf("unable to create a symlink from %q to %q: %v", updatedPath, filename, err)

0 commit comments

Comments
 (0)