mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #34792 from runcom/fix-relabel-symlinks
volume: evaluate symlinks before relabeling mount source
This commit is contained in:
commit
f60e7aac62
1 changed files with 10 additions and 2 deletions
|
@ -3,6 +3,7 @@ package volume
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -155,13 +156,20 @@ func (m *MountPoint) Setup(mountLabel string, rootIDs idtools.IDPair, checkFun f
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = label.Relabel(m.Source, mountLabel, label.IsShared(m.Mode))
|
var sourcePath string
|
||||||
|
sourcePath, err = filepath.EvalSymlinks(m.Source)
|
||||||
|
if err != nil {
|
||||||
|
path = ""
|
||||||
|
err = errors.Wrapf(err, "error evaluating symlinks from mount source %q", m.Source)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = label.Relabel(sourcePath, mountLabel, label.IsShared(m.Mode))
|
||||||
if err == syscall.ENOTSUP {
|
if err == syscall.ENOTSUP {
|
||||||
err = nil
|
err = nil
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
path = ""
|
path = ""
|
||||||
err = errors.Wrapf(err, "error setting label on mount source '%s'", m.Source)
|
err = errors.Wrapf(err, "error setting label on mount source '%s'", sourcePath)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue