log: password prompt output fixed for unix - partially fixes #2220
This commit is contained in:
committed by
Nick Craig-Wood
parent
d7ac4ca44e
commit
ce109ed9c0
@@ -8,12 +8,19 @@ import (
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/ncw/rclone/fs/config"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
// redirectStderr to the file passed in
|
||||
func redirectStderr(f *os.File) {
|
||||
err := unix.Dup2(int(f.Fd()), int(os.Stderr.Fd()))
|
||||
passPromptFd, err := unix.Dup(int(os.Stderr.Fd()))
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to duplicate stderr: %v", err)
|
||||
}
|
||||
config.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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user