From 46e17b26ffcbe53b017f2acf9d13e685b0fd745b Mon Sep 17 00:00:00 2001 From: Onur Date: Sat, 28 Jan 2017 13:30:00 -0800 Subject: [PATCH] spec, libcni, pkg/invoke: Use OS-agnostic separator when parsing CNI_PATH Hardcoding the list separator character as ":" causes CNI to fail when parsing CNI_PATH on other operating systems. For example, Windows uses ";" as list separator because ":" can legally appear in paths such as "C:\path\to\file". This change replaces use of ":" with OS-agnostic APIs or os.PathListSeparator. Fixes #358 --- invoke/delegate.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/invoke/delegate.go b/invoke/delegate.go index f25beddc..c78a69ee 100644 --- a/invoke/delegate.go +++ b/invoke/delegate.go @@ -17,7 +17,7 @@ package invoke import ( "fmt" "os" - "strings" + "path/filepath" "github.com/containernetworking/cni/pkg/types" ) @@ -27,7 +27,7 @@ func DelegateAdd(delegatePlugin string, netconf []byte) (types.Result, error) { return nil, fmt.Errorf("CNI_COMMAND is not ADD") } - paths := strings.Split(os.Getenv("CNI_PATH"), ":") + paths := filepath.SplitList(os.Getenv("CNI_PATH")) pluginPath, err := FindInPath(delegatePlugin, paths) if err != nil { @@ -42,7 +42,7 @@ func DelegateDel(delegatePlugin string, netconf []byte) error { return fmt.Errorf("CNI_COMMAND is not DEL") } - paths := strings.Split(os.Getenv("CNI_PATH"), ":") + paths := filepath.SplitList(os.Getenv("CNI_PATH")) pluginPath, err := FindInPath(delegatePlugin, paths) if err != nil {