Files
privatae-bastion/client-go/pair_terminal_windows.go
T
Privatae 081763a675
ci / personal-data (push) Successful in 4s
ci / test (push) Successful in 4m30s
ci / fuzz (push) Successful in 3m25s
bastion 0.57.0
2026-10-28 20:35:45 +00:00

27 lines
773 B
Go

//go:build windows
package main
import (
"io"
"os"
)
// openControllingTerminal opens the console this process is attached to,
// CONIN$ for the answer and CONOUT$ for the question, whatever its standard
// input is: install.ps1 pipes the pairing code into `pair -`, and the person
// still answers in the PowerShell window. It fails with no console (a
// service, a scheduled task with no window).
func openControllingTerminal() (io.Reader, io.Writer, func(), error) {
in, err := os.OpenFile("CONIN$", os.O_RDWR, 0)
if err != nil {
return nil, nil, nil, errNoTerminal
}
out, err := os.OpenFile("CONOUT$", os.O_RDWR, 0)
if err != nil {
_ = in.Close()
return nil, nil, nil, errNoTerminal
}
return in, out, func() { _ = in.Close(); _ = out.Close() }, nil
}