summaryrefslogtreecommitdiff
path: root/libpod/volume.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-06-30 12:01:40 -0400
committerGitHub <noreply@github.com>2020-06-30 12:01:40 -0400
commitc2a0ccd39464a91b7ba5fdca3af3c2ed66f2cbca (patch)
treedd7389bb37563a5636f34b3cf41f1cb2e37f2122 /libpod/volume.go
parent83bde3bdaf7f7b24f9ad794154207a95e7747f28 (diff)
parentce74c20ebc07ea541b7cdccd272e34c0336ffbc3 (diff)
downloadpodman-c2a0ccd39464a91b7ba5fdca3af3c2ed66f2cbca.tar.gz
podman-c2a0ccd39464a91b7ba5fdca3af3c2ed66f2cbca.tar.bz2
podman-c2a0ccd39464a91b7ba5fdca3af3c2ed66f2cbca.zip
Merge pull request #6747 from giuseppe/fix-user-volumes
container: move volume chown after spec generation
Diffstat (limited to 'libpod/volume.go')
-rw-r--r--libpod/volume.go36
1 files changed, 32 insertions, 4 deletions
diff --git a/libpod/volume.go b/libpod/volume.go
index b29ac7ddf..58d1f81a6 100644
--- a/libpod/volume.go
+++ b/libpod/volume.go
@@ -64,6 +64,14 @@ type VolumeState struct {
// create time, then cleared after the copy up is done and never set
// again.
NeedsCopyUp bool `json:"notYetMounted,omitempty"`
+ // NeedsChown indicates that the next time the volume is mounted into
+ // a container, the container will chown the volume to the container process
+ // UID/GID.
+ NeedsChown bool `json:"notYetChowned,omitempty"`
+ // UIDChowned is the UID the volume was chowned to.
+ UIDChowned int `json:"uidChowned,omitempty"`
+ // GIDChowned is the GID the volume was chowned to.
+ GIDChowned int `json:"gidChowned,omitempty"`
}
// Name retrieves the volume's name
@@ -113,13 +121,33 @@ func (v *Volume) Anonymous() bool {
}
// UID returns the UID the volume will be created as.
-func (v *Volume) UID() int {
- return v.config.UID
+func (v *Volume) UID() (int, error) {
+ v.lock.Lock()
+ defer v.lock.Unlock()
+
+ if !v.valid {
+ return -1, define.ErrVolumeRemoved
+ }
+
+ if v.state.UIDChowned > 0 {
+ return v.state.UIDChowned, nil
+ }
+ return v.config.UID, nil
}
// GID returns the GID the volume will be created as.
-func (v *Volume) GID() int {
- return v.config.GID
+func (v *Volume) GID() (int, error) {
+ v.lock.Lock()
+ defer v.lock.Unlock()
+
+ if !v.valid {
+ return -1, define.ErrVolumeRemoved
+ }
+
+ if v.state.GIDChowned > 0 {
+ return v.state.GIDChowned, nil
+ }
+ return v.config.GID, nil
}
// CreatedTime returns the time the volume was created at. It was not tracked