mirror of
https://github.com/containers/skopeo.git
synced 2026-02-21 22:56:38 +00:00
Always make sure the working directory exists
Always make sure the working directory exists before attempting to run anything inside of it, and before attempting to copy contents into it or one of its subdirectories. Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
This commit is contained in:
3
add.go
3
add.go
@@ -50,6 +50,9 @@ func (b *Builder) Add(destination string, extract bool, source ...string) error
|
||||
if destination != "" && filepath.IsAbs(destination) {
|
||||
dest = filepath.Join(dest, destination)
|
||||
} else {
|
||||
if err := os.MkdirAll(filepath.Join(dest, b.Workdir), 0755); err != nil {
|
||||
return fmt.Errorf("error ensuring directory %q exists: %v)", b.Workdir, err)
|
||||
}
|
||||
dest = filepath.Join(dest, b.Workdir, destination)
|
||||
}
|
||||
// Make sure the destination is usable.
|
||||
|
||||
3
run.go
3
run.go
@@ -108,6 +108,9 @@ func (b *Builder) Run(command []string, options RunOptions) error {
|
||||
if spec.Process.Cwd == "" {
|
||||
spec.Process.Cwd = DefaultWorkingDir
|
||||
}
|
||||
if err := os.MkdirAll(filepath.Join(mountPoint, b.Workdir), 0755); err != nil {
|
||||
return fmt.Errorf("error ensuring working directory %q exists: %v)", b.Workdir, err)
|
||||
}
|
||||
mounts := options.Mounts
|
||||
for _, specMount := range spec.Mounts {
|
||||
override := false
|
||||
|
||||
Reference in New Issue
Block a user