When storeLayer.Parent returns the parent layer, it needs to use the same logic as Get where it wraps in a describablyStoreLayer if the layer is describable. Otherwise, on Windows, this can result in pushing the foreign layers, which is not supposed to be allowed.
This fixes https://github.com/docker/docker/issues/30080.
Signed-off-by: Stefan J. Wernli <swernli@microsoft.com>
| ... | ... |
@@ -198,10 +198,18 @@ func (l *storeLayer) Parent() PushLayer {
|
| 198 | 198 |
if p == nil {
|
| 199 | 199 |
return nil |
| 200 | 200 |
} |
| 201 |
- return &storeLayer{
|
|
| 201 |
+ sl := storeLayer{
|
|
| 202 | 202 |
Layer: p, |
| 203 | 203 |
ls: l.ls, |
| 204 | 204 |
} |
| 205 |
+ if d, ok := p.(distribution.Describable); ok {
|
|
| 206 |
+ return &describableStoreLayer{
|
|
| 207 |
+ storeLayer: sl, |
|
| 208 |
+ describable: d, |
|
| 209 |
+ } |
|
| 210 |
+ } |
|
| 211 |
+ |
|
| 212 |
+ return &sl |
|
| 205 | 213 |
} |
| 206 | 214 |
|
| 207 | 215 |
func (l *storeLayer) Open() (io.ReadCloser, error) {
|