Skip to content

Commit

Permalink
Preserve mode when extracting runtime data
Browse files Browse the repository at this point in the history
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
  • Loading branch information
brandond committed May 24, 2023
1 parent c22c7d7 commit 36cf307
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/bootstrap/bootstrap.go
Expand Up @@ -93,6 +93,7 @@ func Stage(resolver *images.Resolver, nodeConfig *daemonconfig.Node, cfg cmds.Ag

refBinDir := binDirForDigest(cfg.DataDir, refDigest)
refChartsDir := chartsDirForDigest(cfg.DataDir, refDigest)
manifestsDir := manifestsDir(cfg.DataDir)
imagesDir := imagesDir(cfg.DataDir)

if dirExists(refBinDir) && dirExists(refChartsDir) {
Expand Down Expand Up @@ -130,12 +131,18 @@ func Stage(resolver *images.Resolver, nodeConfig *daemonconfig.Node, cfg cmds.Ag
}
}

// preserve manifests directory mode when extracting, if it already exists
extractOptions := []extract.Option{}
if fi, err := os.Stat(manifestsDir); err == nil {
extractOptions = append(extractOptions, extract.WithMode(fi.Mode))
}

// Extract binaries and charts
extractPaths := map[string]string{
"/bin": refBinDir,
"/charts": refChartsDir,
}
if err := extract.ExtractDirs(img, extractPaths); err != nil {
if err := extract.ExtractDirs(img, extractPaths, extractOptions...); err != nil {
return "", errors.Wrap(err, "failed to extract runtime image")
}
// Ensure correct permissions on bin dir
Expand Down

0 comments on commit 36cf307

Please sign in to comment.