mirror of
https://github.com/restic/restic.git
synced 2026-07-10 09:15:09 +00:00
Merge pull request #1270 from restic/sftp-allow-password-prompt
sftp: Allow password entry
This commit is contained in:
+15
-5
@@ -12,17 +12,27 @@ import (
|
||||
|
||||
var cleanupHandlers struct {
|
||||
sync.Mutex
|
||||
list []func() error
|
||||
done bool
|
||||
list []func() error
|
||||
done bool
|
||||
sigintCh chan os.Signal
|
||||
}
|
||||
|
||||
var stderr = os.Stderr
|
||||
|
||||
func init() {
|
||||
c := make(chan os.Signal)
|
||||
signal.Notify(c, syscall.SIGINT)
|
||||
cleanupHandlers.sigintCh = make(chan os.Signal)
|
||||
go CleanupHandler(cleanupHandlers.sigintCh)
|
||||
InstallSignalHandler()
|
||||
}
|
||||
|
||||
go CleanupHandler(c)
|
||||
// InstallSignalHandler listens for SIGINT and triggers the cleanup handlers.
|
||||
func InstallSignalHandler() {
|
||||
signal.Notify(cleanupHandlers.sigintCh, syscall.SIGINT)
|
||||
}
|
||||
|
||||
// SuspendSignalHandler removes the signal handler for SIGINT.
|
||||
func SuspendSignalHandler() {
|
||||
signal.Reset(syscall.SIGINT)
|
||||
}
|
||||
|
||||
// AddCleanupHandler adds the function f to the list of cleanup handlers so
|
||||
|
||||
@@ -470,7 +470,7 @@ func open(s string, opts options.Options) (restic.Backend, error) {
|
||||
case "local":
|
||||
be, err = local.Open(cfg.(local.Config))
|
||||
case "sftp":
|
||||
be, err = sftp.Open(cfg.(sftp.Config))
|
||||
be, err = sftp.Open(cfg.(sftp.Config), SuspendSignalHandler, InstallSignalHandler)
|
||||
case "s3":
|
||||
be, err = s3.Open(cfg.(s3.Config))
|
||||
case "gs":
|
||||
@@ -522,7 +522,7 @@ func create(s string, opts options.Options) (restic.Backend, error) {
|
||||
case "local":
|
||||
return local.Create(cfg.(local.Config))
|
||||
case "sftp":
|
||||
return sftp.Create(cfg.(sftp.Config))
|
||||
return sftp.Create(cfg.(sftp.Config), SuspendSignalHandler, InstallSignalHandler)
|
||||
case "s3":
|
||||
return s3.Create(cfg.(s3.Config))
|
||||
case "gs":
|
||||
|
||||
Reference in New Issue
Block a user