Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
virtcontainers/store: make VCStoreUUIDPath rootless
Browse files Browse the repository at this point in the history
The uuid file shouldn't be created at `/var` if running rootless.
Modify `VMUUIDStoragePath` to get a path accessible for non-root users
if running rootless.

fixes #2133

Signed-off-by: Julio Montes <julio.montes@intel.com>
  • Loading branch information
Julio Montes authored and amshinde committed Dec 2, 2019
1 parent 09118fa commit 9204973
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion virtcontainers/store/filesystem_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,14 @@ var RunVMStoragePath = func() string {

// VMUUIDStoragePath is the uuid directory.
// It will contain all uuid info used by guest vm.
var VMUUIDStoragePath = filepath.Join("/var/lib", StoragePathSuffix, UUIDPathSuffix)
var VMUUIDStoragePath = func() string {
path := filepath.Join("/var/lib", StoragePathSuffix, UUIDPathSuffix)
if rootless.IsRootless() {
return filepath.Join(rootless.GetRootlessDir(), path)
}
return path

}

func itemToFile(item Item) (string, error) {
switch item {
Expand Down
2 changes: 1 addition & 1 deletion virtcontainers/store/vc.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ func SandboxConfigurationItemPath(id string, item Item) (string, error) {

// VCStoreUUIDPath returns a virtcontainers runtime uuid URL.
func VCStoreUUIDPath() string {
return filesystemScheme + "://" + filepath.Join(VCStorePrefix, VMUUIDStoragePath)
return filesystemScheme + "://" + filepath.Join(VCStorePrefix, VMUUIDStoragePath())
}

// SandboxRuntimeRoot returns a virtcontainers sandbox runtime root URL.
Expand Down

0 comments on commit 9204973

Please sign in to comment.