Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NO TESTS NEEDED] Fix rootless volume plugins #9808

Merged
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
9 changes: 0 additions & 9 deletions libpod/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -1577,8 +1577,6 @@ func WithVolumeLabels(labels map[string]string) VolumeCreateOption {
}

// WithVolumeOptions sets the options of the volume.
// If the "local" driver has been selected, options will be validated. There are
// currently 3 valid options for the "local" driver - o, type, and device.
func WithVolumeOptions(options map[string]string) VolumeCreateOption {
return func(volume *Volume) error {
if volume.valid {
Expand All @@ -1587,13 +1585,6 @@ func WithVolumeOptions(options map[string]string) VolumeCreateOption {

volume.config.Options = make(map[string]string)
for key, value := range options {
switch key {
case "type", "device", "o", "UID", "GID":
volume.config.Options[key] = value
default:
return errors.Wrapf(define.ErrInvalidArg, "unrecognized volume option %q is not supported with local driver", key)
}

volume.config.Options[key] = value
}

Expand Down
10 changes: 6 additions & 4 deletions libpod/volume_internal_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ func (v *Volume) mount() error {
return nil
}

// We cannot mount volumes as rootless.
if rootless.IsRootless() {
// We cannot mount 'local' volumes as rootless.
if !v.UsesVolumeDriver() && rootless.IsRootless() {
// This check should only be applied to 'local' driver
// so Volume Drivers must be excluded
return errors.Wrapf(define.ErrRootless, "cannot mount volumes without root privileges")
}

Expand Down Expand Up @@ -137,8 +139,8 @@ func (v *Volume) unmount(force bool) error {
return nil
}

// We cannot unmount volumes as rootless.
if rootless.IsRootless() {
// We cannot unmount 'local' volumes as rootless.
if !v.UsesVolumeDriver() && rootless.IsRootless() {
// If force is set, just clear the counter and bail without
// error, so we can remove volumes from the state if they are in
// an awkward configuration.
Expand Down