lxd/template/chroot.go
func (l ChrootLoader) Get(path string) (io.Reader, error) {
	// Get the full path
	path, err := filepath.EvalSymlinks(path)
	if err != nil {
		return nil, err
	}

	basePath, err := filepath.EvalSymlinks(l.Path)
	if err != nil {
		return nil, err
	}

	// Validate that we're under the expected prefix
	if !strings.HasPrefix(path, basePath) {
		return nil, fmt.Errorf("Attempting to access a file outside the container")
	}

	// Open and read the file
	buf, err := ioutil.ReadFile(path)
	if err != nil {
		return nil, err
	}

	return bytes.NewReader(buf), nil
}
func (l ChrootLoader) Get(path string) (io.Reader, error) {
	// Get the full path
	path, err := filepath.EvalSymlinks(path)
	if err != nil {
		return nil, err
	}

	basePath, err := filepath.EvalSymlinks(l.Path)
	if err != nil {
		return nil, err
	}

	// Validate that we're under the expected prefix
	if !strings.HasPrefix(path, basePath) {
		return nil, fmt.Errorf("Attempting to access a file outside the container")
	}

	// Open and read the file
	buf, err := ioutil.ReadFile(path)
	if err != nil {
		return nil, err
	}

	return bytes.NewReader(buf), nil
}
func ( l ChrootLoader ) Get ( path string ) ( io . Reader , error ) { // Get the full path path , err := filepath . EvalSymlinks ( path ) if err != nil { return nil , err } basePath , err := filepath . EvalSymlinks ( l . Path ) if err != nil { return nil , err } // Validate that we're under the expected prefix if ! strings . HasPrefix ( path , basePath ) { return nil , fmt . Errorf ( " " ) } // Open and read the file buf , err := ioutil . ReadFile ( path ) if err != nil { return nil , err } return bytes . NewReader ( buf ) , nil }
// Get reads the path's content from your local filesystem.
Get reads the path s content from your local filesystem .