From cafa7d7307025cfd3be615c9f78bca819186bf0c Mon Sep 17 00:00:00 2001 From: Flavian Missi Date: Mon, 14 Aug 2023 11:26:40 +0200 Subject: [PATCH] replace .. with : on registry CA file paths --- pkg/daemon/certificate_writer.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/daemon/certificate_writer.go b/pkg/daemon/certificate_writer.go index 0f39ebc873..158cef5cc9 100644 --- a/pkg/daemon/certificate_writer.go +++ b/pkg/daemon/certificate_writer.go @@ -4,7 +4,7 @@ import ( "fmt" "os" "path/filepath" - + "strings" "time" mcfgv1 "github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1" @@ -15,9 +15,7 @@ import ( "k8s.io/klog/v2" ) -var ( - ccRequeueDelay = 1 * time.Minute -) +var ccRequeueDelay = 1 * time.Minute func (dn *Daemon) handleControllerConfigEvent(obj interface{}) { controllerConfig := obj.(*mcfgv1.ControllerConfig) @@ -112,19 +110,21 @@ func (dn *Daemon) syncControllerConfigHandler(key string) error { } for _, CA := range controllerConfig.Spec.ImageRegistryBundleData { - if err := os.MkdirAll(filepath.Join(imageCAFilePath, CA.File), defaultDirectoryPermissions); err != nil { + caFile := strings.ReplaceAll(CA.File, "..", ":") + if err := os.MkdirAll(filepath.Join(imageCAFilePath, caFile), defaultDirectoryPermissions); err != nil { return err } - if err := writeFileAtomicallyWithDefaults(filepath.Join(imageCAFilePath, CA.File, "ca.crt"), CA.Data); err != nil { + if err := writeFileAtomicallyWithDefaults(filepath.Join(imageCAFilePath, caFile, "ca.crt"), CA.Data); err != nil { return err } } for _, CA := range controllerConfig.Spec.ImageRegistryBundleUserData { - if err := os.MkdirAll(filepath.Join(imageCAFilePath, CA.File), defaultDirectoryPermissions); err != nil { + caFile := strings.ReplaceAll(CA.File, "..", ":") + if err := os.MkdirAll(filepath.Join(imageCAFilePath, caFile), defaultDirectoryPermissions); err != nil { return err } - if err := writeFileAtomicallyWithDefaults(filepath.Join(imageCAFilePath, CA.File, "ca.crt"), CA.Data); err != nil { + if err := writeFileAtomicallyWithDefaults(filepath.Join(imageCAFilePath, caFile, "ca.crt"), CA.Data); err != nil { return err } }