mirror of
https://github.com/restic/restic.git
synced 2025-11-16 06:53:22 +00:00
sftp: Prompt for password, don't terminate on SIGINT
This is a follow-up on fb9729fdb9, which
runs the `ssh` in its own process group and selects that process group
as the foreground group. After the sftp connection is established,
restic switches back to the previous foreground process group.
This allows `ssh` to prompt for the password, but it won't receive
the interrupt signal (SIGINT, ^C) later on, because it is not in the
foreground process group any more, allowing a clean tear down.
This commit is contained in:
@@ -69,8 +69,8 @@ func startClient(preExec, postExec func(), program string, args ...string) (*SFT
|
||||
preExec()
|
||||
}
|
||||
|
||||
// start the process
|
||||
if err := cmd.Start(); err != nil {
|
||||
bg, err := startForeground(cmd)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "cmd.Start")
|
||||
}
|
||||
|
||||
@@ -92,6 +92,11 @@ func startClient(preExec, postExec func(), program string, args ...string) (*SFT
|
||||
return nil, errors.Errorf("unable to start the sftp session, error: %v", err)
|
||||
}
|
||||
|
||||
err = bg()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "bg")
|
||||
}
|
||||
|
||||
return &SFTP{c: client, cmd: cmd, result: ch}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user