Close the stdin/tty on server start to avoid shortname prompts
This avoids prompting for shortname expansion if CRI-O runs inside of a
terminal.
@@ -32,6 +32,7 @@ import (
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/sirupsen/logrus"
+ "golang.org/x/sys/unix"
)
const (
@@ -365,6 +366,17 @@ func New(
return nil, err
}
+ // Close stdin, so shortnames will not prompt
+ devNullFile, err := os.Open(os.DevNull)
+ if err != nil {
+ return nil, errors.Wrap(err, "open devnull file")
+ }
+
+ defer devNullFile.Close()
+ if err := unix.Dup2(int(devNullFile.Fd()), int(os.Stdin.Fd())); err != nil {
+ return nil, errors.Wrap(err, "close stdin")
+ }
+
s.restore(ctx)
s.cleanupSandboxesOnShutdown(ctx)
