Skip to content

Commit d6a13bd

Browse files
author
Mrunal Patel
authored
Merge pull request #233 from liangchenye/master
check if Root.Path is Abs
2 parents f7a9a97 + a1ce2b1 commit d6a13bd

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

cmd/oci-runtime-tool/validate.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"fmt"
88
"io/ioutil"
99
"os"
10-
"path"
1110
"path/filepath"
1211
"reflect"
1312
"strings"
@@ -78,7 +77,7 @@ var bundleValidateCommand = cli.Command{
7877
return err
7978
}
8079

81-
configPath := path.Join(inputPath, "config.json")
80+
configPath := filepath.Join(inputPath, "config.json")
8281
content, err := ioutil.ReadFile(configPath)
8382
if err != nil {
8483
return err
@@ -91,7 +90,12 @@ var bundleValidateCommand = cli.Command{
9190
return err
9291
}
9392

94-
rootfsPath := path.Join(inputPath, spec.Root.Path)
93+
var rootfsPath string
94+
if filepath.IsAbs(spec.Root.Path) {
95+
rootfsPath = spec.Root.Path
96+
} else {
97+
rootfsPath = filepath.Join(inputPath, spec.Root.Path)
98+
}
9599
if fi, err := os.Stat(rootfsPath); err != nil {
96100
return fmt.Errorf("Cannot find the root path %q", rootfsPath)
97101
} else if !fi.IsDir() {
@@ -213,7 +217,7 @@ func checkProcess(spec rspec.Spec, rootfs string, hostCheck bool) (msgs []string
213217
logrus.Debugf("check process")
214218

215219
process := spec.Process
216-
if !path.IsAbs(process.Cwd) {
220+
if !filepath.IsAbs(process.Cwd) {
217221
msgs = append(msgs, fmt.Sprintf("cwd %q is not an absolute path", process.Cwd))
218222
}
219223

@@ -240,7 +244,7 @@ func checkProcess(spec rspec.Spec, rootfs string, hostCheck bool) (msgs []string
240244
}
241245

242246
if len(process.ApparmorProfile) > 0 {
243-
profilePath := path.Join(rootfs, "/etc/apparmor.d", process.ApparmorProfile)
247+
profilePath := filepath.Join(rootfs, "/etc/apparmor.d", process.ApparmorProfile)
244248
_, err := os.Stat(profilePath)
245249
if err != nil {
246250
msgs = append(msgs, err.Error())

0 commit comments

Comments
 (0)