A desk's prompt is answered over the desk machine's bus, on a subject that machine's runtime answers; on a desk machine agents run as the operator, who holds that credential, so an agent could answer first with a bot token of its own sealed to the call's key. The secret of a module running as an account of its own (the Telegram bot's token) is now refused at the desk, before anybody is asked, naming the line to type at the controller's terminal; there it is announced on every channel, the old one among them, before it is kept, and not kept when that announcement fails. What is typed at the terminal is not echoed. Tests: the refusal with nobody asked, and only the desk machine's launcher may answer its prompt (MaySubscribe).
27 lines
637 B
Go
27 lines
637 B
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
// hideTyping turns a terminal's echo off while a secret is typed at it, and gives back what restores it. On
|
|
// anything that is not a terminal (a pipe, a file) it does nothing.
|
|
func hideTyping(f *os.File) func() {
|
|
fd := int(f.Fd())
|
|
before, err := unix.IoctlGetTermios(fd, unix.TCGETS)
|
|
if err != nil {
|
|
return func() {}
|
|
}
|
|
hidden := *before
|
|
hidden.Lflag &^= unix.ECHO
|
|
if err := unix.IoctlSetTermios(fd, unix.TCSETS, &hidden); err != nil {
|
|
return func() {}
|
|
}
|
|
return func() {
|
|
_ = unix.IoctlSetTermios(fd, unix.TCSETS, before)
|
|
_, _ = os.Stderr.WriteString("\n")
|
|
}
|
|
}
|