Skip to content

Commit

Permalink
Merge pull request #881 from rhatdan/selinux
Browse files Browse the repository at this point in the history
Allow users to tag images in read/only image stores
  • Loading branch information
rhatdan authored Apr 28, 2021
2 parents 1ced4ef + 9668bf7 commit 86fe378
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
31 changes: 31 additions & 0 deletions store.go
Original file line number Diff line number Diff line change
Expand Up @@ -2115,6 +2115,37 @@ func (s *store) SetNames(id string, names []string) error {
return ristore.SetNames(id, deduped)
}

// Check is id refers to a RO Store
ristores, err := s.ROImageStores()
if err != nil {
return err
}
for _, s := range ristores {
store := s
store.RLock()
defer store.Unlock()
if modified, err := store.Modified(); modified || err != nil {
if err = store.Load(); err != nil {
return err
}
}
if i, err := store.Get(id); err == nil {
// Unlock R/O lock and lock with R/W lock
// Previous defer.Unlock() will free the new lock.
ristore.Unlock()
ristore.Lock()
if len(deduped) > 1 {
// Do not want to create image name in R/W storage
deduped = deduped[1:]
}
_, err := ristore.Create(id, deduped, i.TopLayer, i.Metadata, i.Created, i.Digest)
if err == nil {
return ristore.Save()
}
return err
}
}

rcstore, err := s.ContainerStore()
if err != nil {
return err
Expand Down
5 changes: 5 additions & 0 deletions tests/stores.bats
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ load helpers
[ "$status" -eq 0 ]
[ "$output" != "" ]

run storage --storage-opt ${STORAGE_DRIVER}.imagestore=${TESTDIR}/ro-root add-names -n newimage $lowerimage
[ "$status" -eq 0 ]
run storage --storage-opt ${STORAGE_DRIVER}.imagestore=${TESTDIR}/ro-root delete-image newimage
[ "$status" -eq 0 ]

# Create a container based on the lowerimage.
run storage --storage-opt ${STORAGE_DRIVER}.imagestore=${TESTDIR}/ro-root --debug=false create-container "$lowerimage"
[ "$status" -eq 0 ]
Expand Down

0 comments on commit 86fe378

Please sign in to comment.