diff --git a/fs/config/crypt.go b/fs/config/crypt.go index 6792811dc..805eecf66 100644 --- a/fs/config/crypt.go +++ b/fs/config/crypt.go @@ -26,9 +26,6 @@ var ( // When nil, no encryption will be used for saving. configKey []byte - // PasswordPromptOutput is output of prompt for password - PasswordPromptOutput = os.Stderr - // PassConfigKeyForDaemonization if set to true, the configKey // is obscured with obscure.Obscure and saved to a temp file // when it is calculated from the password. The path of that diff --git a/fs/config/ui.go b/fs/config/ui.go index 60b5b3bc6..8e55c1ee4 100644 --- a/fs/config/ui.go +++ b/fs/config/ui.go @@ -716,9 +716,9 @@ func checkPassword(password string) (string, error) { // GetPassword asks the user for a password with the prompt given. func GetPassword(prompt string) string { - _, _ = fmt.Fprintln(PasswordPromptOutput, prompt) + _, _ = fmt.Fprintln(terminal.PasswordPromptOutput, prompt) for { - _, _ = fmt.Fprint(PasswordPromptOutput, "password:") + _, _ = fmt.Fprint(terminal.PasswordPromptOutput, "password:") password := ReadPassword() password, err := checkPassword(password) if err == nil { diff --git a/fs/log/redirect_stderr_unix.go b/fs/log/redirect_stderr_unix.go index e0b8e4eca..5e3b66cd6 100644 --- a/fs/log/redirect_stderr_unix.go +++ b/fs/log/redirect_stderr_unix.go @@ -9,7 +9,7 @@ import ( "log" "os" - "github.com/rclone/rclone/fs/config" + "github.com/rclone/rclone/lib/terminal" "golang.org/x/sys/unix" ) @@ -19,7 +19,7 @@ func redirectStderr(f *os.File) { if err != nil { log.Fatalf("Failed to duplicate stderr: %v", err) } - config.PasswordPromptOutput = os.NewFile(uintptr(passPromptFd), "passPrompt") + terminal.PasswordPromptOutput = os.NewFile(uintptr(passPromptFd), "passPrompt") err = unix.Dup2(int(f.Fd()), int(os.Stderr.Fd())) if err != nil { log.Fatalf("Failed to redirect stderr to file: %v", err) diff --git a/lib/terminal/terminal.go b/lib/terminal/terminal.go index f193eb767..09b05ec59 100644 --- a/lib/terminal/terminal.go +++ b/lib/terminal/terminal.go @@ -8,8 +8,6 @@ import ( "runtime" "sync" - "github.com/rclone/rclone/fs/config" - colorable "github.com/mattn/go-colorable" ) @@ -70,12 +68,15 @@ const ( var ( // make sure that start is only called once once sync.Once + + // PasswordPromptOutput is output of prompt for password + PasswordPromptOutput = os.Stderr ) // Start the terminal - must be called before use func Start() { once.Do(func() { - f := config.PasswordPromptOutput + f := PasswordPromptOutput if !IsTerminal(int(f.Fd())) { // If output is not a tty then remove escape codes Out = colorable.NewNonColorable(f)