Signed-off-by: John Howard <jhoward@microsoft.com>
| ... | ... |
@@ -77,6 +77,7 @@ func TestParseMountSpec(t *testing.T) {
|
| 77 | 77 |
`lpt7:d:`: `cannot be a reserved word for Windows filenames`, |
| 78 | 78 |
`lpt8:d:`: `cannot be a reserved word for Windows filenames`, |
| 79 | 79 |
`lpt9:d:`: `cannot be a reserved word for Windows filenames`, |
| 80 |
+ `c:\windows\system32\ntdll.dll`: `Only directories can be mapped on this platform`, |
|
| 80 | 81 |
} |
| 81 | 82 |
|
| 82 | 83 |
} else {
|
| ... | ... |
@@ -177,6 +177,24 @@ func ParseMountSpec(spec string, volumeDriver string) (*MountPoint, error) {
|
| 177 | 177 |
} |
| 178 | 178 |
} |
| 179 | 179 |
|
| 180 |
+ // Fix #26329. If the destination appears to be a file, and the source is null, |
|
| 181 |
+ // it may be because we've fallen through the possible naming regex and hit a |
|
| 182 |
+ // situation where the user intention was to map a file into a container through |
|
| 183 |
+ // a local volume, but this is not supported by the platform. |
|
| 184 |
+ if len(mp.Source) == 0 && len(mp.Destination) > 0 {
|
|
| 185 |
+ var fi os.FileInfo |
|
| 186 |
+ var err error |
|
| 187 |
+ if fi, err = os.Stat(mp.Destination); err == nil {
|
|
| 188 |
+ validName, err := IsVolumeNameValid(mp.Destination) |
|
| 189 |
+ if err != nil {
|
|
| 190 |
+ return nil, err |
|
| 191 |
+ } |
|
| 192 |
+ if !validName && !fi.IsDir() {
|
|
| 193 |
+ return nil, fmt.Errorf("file '%s' cannot be mapped. Only directories can be mapped on this platform", mp.Destination)
|
|
| 194 |
+ } |
|
| 195 |
+ } |
|
| 196 |
+ } |
|
| 197 |
+ |
|
| 180 | 198 |
logrus.Debugf("MP: Source '%s', Dest '%s', RW %t, Name '%s', Driver '%s'", mp.Source, mp.Destination, mp.RW, mp.Name, mp.Driver)
|
| 181 | 199 |
return mp, nil |
| 182 | 200 |
} |