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
This commit is contained in:
Onur
2017-01-28 13:30:00 -08:00
committed by Onur Filiz
parent 06b397912b
commit 46e17b26ff

View File

@ -17,7 +17,7 @@ package invoke
import ( import (
"fmt" "fmt"
"os" "os"
"strings" "path/filepath"
"github.com/containernetworking/cni/pkg/types" "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") 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) pluginPath, err := FindInPath(delegatePlugin, paths)
if err != nil { if err != nil {
@ -42,7 +42,7 @@ func DelegateDel(delegatePlugin string, netconf []byte) error {
return fmt.Errorf("CNI_COMMAND is not DEL") 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) pluginPath, err := FindInPath(delegatePlugin, paths)
if err != nil { if err != nil {