Currently local volumes and other volumes that support SELinux do
not get labeled correctly. This patch will allow a user to specify
:Z or :z when mounting a volume and have it fix the label of the newly
created volume.
Signed-off-by: Dan Walsh <dwalsh@redhat.com>
(cherry picked from commit 0c791c8e9f462b0df2c1a76aff45b9033bd962cd)
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
| ... | ... |
@@ -124,7 +124,20 @@ type MountPoint struct {
|
| 124 | 124 |
|
| 125 | 125 |
// Setup sets up a mount point by either mounting the volume if it is |
| 126 | 126 |
// configured, or creating the source directory if supplied. |
| 127 |
-func (m *MountPoint) Setup(mountLabel string, rootUID, rootGID int) (string, error) {
|
|
| 127 |
+func (m *MountPoint) Setup(mountLabel string, rootUID, rootGID int) (path string, err error) {
|
|
| 128 |
+ defer func() {
|
|
| 129 |
+ if err == nil {
|
|
| 130 |
+ if label.RelabelNeeded(m.Mode) {
|
|
| 131 |
+ if err = label.Relabel(m.Source, mountLabel, label.IsShared(m.Mode)); err != nil {
|
|
| 132 |
+ path = "" |
|
| 133 |
+ err = errors.Wrapf(err, "error setting label on mount source '%s'", m.Source) |
|
| 134 |
+ return |
|
| 135 |
+ } |
|
| 136 |
+ } |
|
| 137 |
+ } |
|
| 138 |
+ return |
|
| 139 |
+ }() |
|
| 140 |
+ |
|
| 128 | 141 |
if m.Volume != nil {
|
| 129 | 142 |
id := m.ID |
| 130 | 143 |
if id == "" {
|
| ... | ... |
@@ -152,11 +165,6 @@ func (m *MountPoint) Setup(mountLabel string, rootUID, rootGID int) (string, err |
| 152 | 152 |
} |
| 153 | 153 |
} |
| 154 | 154 |
} |
| 155 |
- if label.RelabelNeeded(m.Mode) {
|
|
| 156 |
- if err := label.Relabel(m.Source, mountLabel, label.IsShared(m.Mode)); err != nil {
|
|
| 157 |
- return "", errors.Wrapf(err, "error setting label on mount source '%s'", m.Source) |
|
| 158 |
- } |
|
| 159 |
- } |
|
| 160 | 155 |
return m.Source, nil |
| 161 | 156 |
} |
| 162 | 157 |
|