From d427434e05dbe514ea1707867a502c61298a9643 Mon Sep 17 00:00:00 2001 From: Chris Kyrouac Date: Mon, 8 Jul 2024 12:05:39 -0400 Subject: [PATCH] disk: Pass /dev/null to containers.attach stdin When using os.Stdin, the initial ssh connection pipe is broken. Signed-off-by: Chris Kyrouac --- pkg/bootc/bootc_disk.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/bootc/bootc_disk.go b/pkg/bootc/bootc_disk.go index d8f27c71..ccbab6cc 100644 --- a/pkg/bootc/bootc_disk.go +++ b/pkg/bootc/bootc_disk.go @@ -340,9 +340,15 @@ func (p *BootcDisk) runInstallContainer(quiet bool, config DiskImageConfig) (err attachCancelCtx, cancelAttach := context.WithCancel(p.Ctx) defer cancelAttach() var exitCode int32 + + nilFile, err := os.Open(os.DevNull) + if err != nil { + return fmt.Errorf("unable to open /dev/null: %w", err) + } + if !quiet { attachOpts := new(containers.AttachOptions).WithStream(true) - if err := containers.Attach(attachCancelCtx, p.bootcInstallContainerId, os.Stdin, os.Stdout, os.Stderr, nil, attachOpts); err != nil { + if err := containers.Attach(attachCancelCtx, p.bootcInstallContainerId, nilFile, os.Stdout, os.Stderr, nil, attachOpts); err != nil { return fmt.Errorf("attaching: %w", err) } }