From 1b0b6bf7a87c1050f1211f7cfb72a218bf8776d9 Mon Sep 17 00:00:00 2001 From: Devin Carr Date: Fri, 14 Jul 2023 16:41:52 -0700 Subject: [PATCH] TUN-7589: Remove legacy golang.org/x/crypto/ssh/terminal package usage Package has been moved to golang.org/x/term --- cmd/cloudflared/tunnel/configuration.go | 4 +- cmd/cloudflared/updater/update.go | 4 +- .../x/crypto/ssh/terminal/terminal.go | 76 ------------------- vendor/modules.txt | 1 - 4 files changed, 4 insertions(+), 81 deletions(-) delete mode 100644 vendor/golang.org/x/crypto/ssh/terminal/terminal.go diff --git a/cmd/cloudflared/tunnel/configuration.go b/cmd/cloudflared/tunnel/configuration.go index 8d1fe209..b905bdd8 100644 --- a/cmd/cloudflared/tunnel/configuration.go +++ b/cmd/cloudflared/tunnel/configuration.go @@ -15,7 +15,7 @@ import ( "github.com/rs/zerolog" "github.com/urfave/cli/v2" "github.com/urfave/cli/v2/altsrc" - "golang.org/x/crypto/ssh/terminal" + "golang.org/x/term" "github.com/cloudflare/cloudflared/cmd/cloudflared/cliutil" "github.com/cloudflare/cloudflared/config" @@ -277,7 +277,7 @@ func gracePeriod(c *cli.Context) (time.Duration, error) { } func isRunningFromTerminal() bool { - return terminal.IsTerminal(int(os.Stdout.Fd())) + return term.IsTerminal(int(os.Stdout.Fd())) } // Remove any duplicates from the slice diff --git a/cmd/cloudflared/updater/update.go b/cmd/cloudflared/updater/update.go index 31be284f..07b382f5 100644 --- a/cmd/cloudflared/updater/update.go +++ b/cmd/cloudflared/updater/update.go @@ -12,7 +12,7 @@ import ( "github.com/facebookgo/grace/gracenet" "github.com/rs/zerolog" "github.com/urfave/cli/v2" - "golang.org/x/crypto/ssh/terminal" + "golang.org/x/term" "github.com/cloudflare/cloudflared/config" "github.com/cloudflare/cloudflared/logger" @@ -304,7 +304,7 @@ func wasInstalledFromPackageManager() bool { } func isRunningFromTerminal() bool { - return terminal.IsTerminal(int(os.Stdout.Fd())) + return term.IsTerminal(int(os.Stdout.Fd())) } func IsSysV() bool { diff --git a/vendor/golang.org/x/crypto/ssh/terminal/terminal.go b/vendor/golang.org/x/crypto/ssh/terminal/terminal.go deleted file mode 100644 index a4d1919a..00000000 --- a/vendor/golang.org/x/crypto/ssh/terminal/terminal.go +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package terminal provides support functions for dealing with terminals, as -// commonly found on UNIX systems. -// -// Deprecated: this package moved to golang.org/x/term. -package terminal - -import ( - "io" - - "golang.org/x/term" -) - -// EscapeCodes contains escape sequences that can be written to the terminal in -// order to achieve different styles of text. -type EscapeCodes = term.EscapeCodes - -// Terminal contains the state for running a VT100 terminal that is capable of -// reading lines of input. -type Terminal = term.Terminal - -// NewTerminal runs a VT100 terminal on the given ReadWriter. If the ReadWriter is -// a local terminal, that terminal must first have been put into raw mode. -// prompt is a string that is written at the start of each input line (i.e. -// "> "). -func NewTerminal(c io.ReadWriter, prompt string) *Terminal { - return term.NewTerminal(c, prompt) -} - -// ErrPasteIndicator may be returned from ReadLine as the error, in addition -// to valid line data. It indicates that bracketed paste mode is enabled and -// that the returned line consists only of pasted data. Programs may wish to -// interpret pasted data more literally than typed data. -var ErrPasteIndicator = term.ErrPasteIndicator - -// State contains the state of a terminal. -type State = term.State - -// IsTerminal returns whether the given file descriptor is a terminal. -func IsTerminal(fd int) bool { - return term.IsTerminal(fd) -} - -// ReadPassword reads a line of input from a terminal without local echo. This -// is commonly used for inputting passwords and other sensitive data. The slice -// returned does not include the \n. -func ReadPassword(fd int) ([]byte, error) { - return term.ReadPassword(fd) -} - -// MakeRaw puts the terminal connected to the given file descriptor into raw -// mode and returns the previous state of the terminal so that it can be -// restored. -func MakeRaw(fd int) (*State, error) { - return term.MakeRaw(fd) -} - -// Restore restores the terminal connected to the given file descriptor to a -// previous state. -func Restore(fd int, oldState *State) error { - return term.Restore(fd, oldState) -} - -// GetState returns the current state of a terminal which may be useful to -// restore the terminal after a signal. -func GetState(fd int) (*State, error) { - return term.GetState(fd) -} - -// GetSize returns the dimensions of the given terminal. -func GetSize(fd int) (width, height int, err error) { - return term.GetSize(fd) -} diff --git a/vendor/modules.txt b/vendor/modules.txt index d3faecae..a2388a2b 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -363,7 +363,6 @@ golang.org/x/crypto/pbkdf2 golang.org/x/crypto/salsa20/salsa golang.org/x/crypto/ssh golang.org/x/crypto/ssh/internal/bcrypt_pbkdf -golang.org/x/crypto/ssh/terminal # golang.org/x/exp v0.0.0-20221205204356-47842c84f3db ## explicit; go 1.18 golang.org/x/exp/constraints