Skip to content

Commit

Permalink
Only open save output file with WRONLY
Browse files Browse the repository at this point in the history
The previous code fails on a MAC when opening /dev/stdout

Fixes: containers#12402

[NO NEW TESTS NEEDED] No easy way to test this.

Signed-off-by: Daniel J Walsh <[email protected]>
  • Loading branch information
rhatdan authored and mheon committed Dec 6, 2021
1 parent e2d6948 commit e1cf9d4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/domain/infra/tunnel/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,10 @@ func (ir *ImageEngine) Save(ctx context.Context, nameOrID string, tags []string,
defer func() { _ = os.Remove(f.Name()) }()
}
default:
f, err = os.Create(opts.Output)
// This code was added to allow for opening stdout replacing
// os.Create(opts.Output) which was attempting to open the file
// for read/write which fails on Darwin platforms
f, err = os.OpenFile(opts.Output, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
}
if err != nil {
return err
Expand Down

0 comments on commit e1cf9d4

Please sign in to comment.