Skip to content

Commit

Permalink
Made --chroot violation error message shorter
Browse files Browse the repository at this point in the history
  • Loading branch information
shyiko committed Apr 17, 2018
1 parent 444ece5 commit ad7a32d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions kubetpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,15 @@ func renderTemplate(templateFile string, config map[string]interface{}, format s
return "", nil, err
}
if templateChroot == "" || !strings.HasPrefix(file, templateChroot) {
return "", nil, fmt.Errorf(`%s: denied access to "%s"`+
" (use --allow-fs-access and/or -c/--chroot=<root dir> to allow)",
templateFile, file)
fileRel := file
if cwd, err := os.Getwd(); err == nil {
if p, err := filepath.Rel(cwd, file); err == nil {
fileRel = p
}
}
return "", nil, fmt.Errorf(`%s: access denied: %s`+
" (use --allow-fs-access and/or -c/--chroot=<root dir, e.g. '.'> to allow)",
templateFile, fileRel)
}
data, err := ioutil.ReadFile(file)
return filepath.Base(file), data, err
Expand Down

0 comments on commit ad7a32d

Please sign in to comment.