Skip to content
This repository has been archived by the owner on Dec 9, 2022. It is now read-only.

serve the status of image acquiring #82

Merged
merged 5 commits into from
Jan 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ var (

// InspectorMetadata is the metadata type with information about image-inspector's operation
type InspectorMetadata struct {
ImageAcquireError string // error from aquiring the image

docker.Image // Metadata about the inspected image

// OpenSCAP describes the state of the OpenSCAP scan
Expand Down
25 changes: 14 additions & 11 deletions pkg/imageserver/webdav.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,21 @@ func (s *webdavImageServer) GetHandler(meta *iiapi.InspectorMetadata,
) (http.Handler, error) {
mux := http.NewServeMux()
servePath := ImageServeURL
if s.opts.Chroot {
if err := syscall.Chroot(ImageServeURL); err != nil {
return nil, fmt.Errorf("Unable to chroot into %s: %v\n", ImageServeURL, err)
}
if err := syscall.Chdir("/"); err != nil {
return nil, fmt.Errorf("Unable to change directory into new root: %v\n", err)

if len(servePath) > 0 && len(meta.ImageAcquireError) == 0 {
if s.opts.Chroot {
if err := syscall.Chroot(ImageServeURL); err != nil {
return nil, fmt.Errorf("unable to chroot into %s: %v\n", ImageServeURL, err)
}
if err := syscall.Chdir("/"); err != nil {
return nil, fmt.Errorf("unable to change directory into new root: %v\n", err)
}
servePath = chrootServePath
} else {
log.Printf("!!!WARNING!!! It is insecure to serve the image content without changing")
log.Printf("root (--chroot). Absolute-path symlinks in the image can lead to disclose")
log.Printf("information of the hosting system.")
}
servePath = chrootServePath
} else {
log.Printf("!!!WARNING!!! It is insecure to serve the image content without changing")
log.Printf("root (--chroot). Absolute-path symlinks in the image can lead to disclose")
log.Printf("information of the hosting system.")
}

mux.HandleFunc(s.opts.HealthzURL, func(w http.ResponseWriter, r *http.Request) {
Expand Down
Loading