Revert "plugins: run plugin with new process group ID"

This reverts commit ef5e5fa03f.

Running new plugins under a new pgid isn't a viable solution due to
it causing issues with plugin processes attempting to read from the
TTY (see: https://github.com/moby/moby/issues/47073).

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
This commit is contained in:
Laura Brehm 2024-01-15 13:14:06 +00:00
parent 077d07c4f0
commit 26560ff93c
No known key found for this signature in database
GPG Key ID: CFBF847B4A313468
4 changed files with 1 additions and 25 deletions

View File

@ -233,7 +233,6 @@ func PluginRunCommand(dockerCli command.Cli, name string, rootcmd *cobra.Command
cmd.Stdin = os.Stdin cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr cmd.Stderr = os.Stderr
configureOSSpecificCommand(cmd)
cmd.Env = os.Environ() cmd.Env = os.Environ()
cmd.Env = append(cmd.Env, ReexecEnvvar+"="+os.Args[0]) cmd.Env = append(cmd.Env, ReexecEnvvar+"="+os.Args[0])

View File

@ -2,21 +2,7 @@
package manager package manager
import (
"os/exec"
"syscall"
)
var defaultSystemPluginDirs = []string{ var defaultSystemPluginDirs = []string{
"/usr/local/lib/docker/cli-plugins", "/usr/local/libexec/docker/cli-plugins", "/usr/local/lib/docker/cli-plugins", "/usr/local/libexec/docker/cli-plugins",
"/usr/lib/docker/cli-plugins", "/usr/libexec/docker/cli-plugins", "/usr/lib/docker/cli-plugins", "/usr/libexec/docker/cli-plugins",
} }
func configureOSSpecificCommand(cmd *exec.Cmd) {
// Spawn the plugin process in a new process group, so that signals are not forwarded by the OS.
// The foreground process group is e.g. sent a SIGINT when Ctrl-C is input to the TTY, but we
// implement our own job control for the plugin.
cmd.SysProcAttr = &syscall.SysProcAttr{
Setpgid: true,
}
}

View File

@ -2,7 +2,6 @@ package manager
import ( import (
"os" "os"
"os/exec"
"path/filepath" "path/filepath"
) )
@ -10,7 +9,3 @@ var defaultSystemPluginDirs = []string{
filepath.Join(os.Getenv("ProgramData"), "Docker", "cli-plugins"), filepath.Join(os.Getenv("ProgramData"), "Docker", "cli-plugins"),
filepath.Join(os.Getenv("ProgramFiles"), "Docker", "cli-plugins"), filepath.Join(os.Getenv("ProgramFiles"), "Docker", "cli-plugins"),
} }
func configureOSSpecificCommand(cmd *exec.Cmd) {
// no-op
}

View File

@ -240,16 +240,12 @@ func tryPluginRun(dockerCli command.Cli, cmd *cobra.Command, subcommand string,
// we send a SIGKILL to the plugin process and exit // we send a SIGKILL to the plugin process and exit
go func() { go func() {
retries := 0 retries := 0
for s := range signals { for range signals {
if conn != nil { if conn != nil {
if err := conn.Close(); err != nil { if err := conn.Close(); err != nil {
_, _ = fmt.Fprintf(dockerCli.Err(), "failed to signal plugin to close: %v\n", err) _, _ = fmt.Fprintf(dockerCli.Err(), "failed to signal plugin to close: %v\n", err)
} }
conn = nil conn = nil
} else {
// When the plugin is communicating via socket with the host CLI, we perform job control via the socket.
// However, if the plugin is an old version that is not socket-aware, we need to explicitly forward termination signals.
plugincmd.Process.Signal(s)
} }
retries++ retries++
if retries >= exitLimit { if retries >= exitLimit {