remove uses of golang.org/x/sys/execabs

the "golang.org/x/sys/execabs" package was introduced to address a security
issue on Windows, and changing the default behavior of os/exec was considered
a breaking change. go1.19 applied the behavior that was previously implemented
in the execabs package;

from the release notes: https://go.dev/doc/go1.19#os-exec-path

> Command and LookPath no longer allow results from a PATH search to be found
> relative to the current directory. This removes a common source of security
> problems but may also break existing programs that depend on using, say,
> exec.Command("prog") to run a binary named prog (or, on Windows, prog.exe)
> in the current directory. See the os/exec package documentation for information
> about how best to update such programs.
>
> On Windows, Command and LookPath now respect the NoDefaultCurrentDirectoryInExePath
> environment variable, making it possible to disable the default implicit search
> of “.” in PATH lookups on Windows systems.

With those changes, we no longer need to use the execabs package, and we can
switch back to os/exec.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2023-05-26 02:03:45 +02:00
parent 5be21394cb
commit 4cf04988ae
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
5 changed files with 5 additions and 9 deletions

View File

@ -1,8 +1,6 @@
package manager package manager
import ( import "os/exec"
exec "golang.org/x/sys/execabs"
)
// Candidate represents a possible plugin candidate, for mocking purposes // Candidate represents a possible plugin candidate, for mocking purposes
type Candidate interface { type Candidate interface {

View File

@ -3,6 +3,7 @@ package manager
import ( import (
"context" "context"
"os" "os"
"os/exec"
"path/filepath" "path/filepath"
"sort" "sort"
"strings" "strings"
@ -13,7 +14,6 @@ import (
"github.com/fvbommel/sortorder" "github.com/fvbommel/sortorder"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"golang.org/x/sync/errgroup" "golang.org/x/sync/errgroup"
exec "golang.org/x/sys/execabs"
) )
// ReexecEnvvar is the name of an ennvar which is set to the command // ReexecEnvvar is the name of an ennvar which is set to the command

View File

@ -8,6 +8,7 @@ import (
"io" "io"
"net/http" "net/http"
"os" "os"
"os/exec"
"path/filepath" "path/filepath"
"runtime" "runtime"
"strings" "strings"
@ -22,7 +23,6 @@ import (
"github.com/docker/docker/pkg/stringid" "github.com/docker/docker/pkg/stringid"
"github.com/moby/patternmatcher" "github.com/moby/patternmatcher"
"github.com/pkg/errors" "github.com/pkg/errors"
exec "golang.org/x/sys/execabs"
) )
const ( const (

View File

@ -1,8 +1,6 @@
package credentials package credentials
import ( import "os/exec"
exec "golang.org/x/sys/execabs"
)
// DetectDefaultStore return the default credentials store for the platform if // DetectDefaultStore return the default credentials store for the platform if
// no user-defined store is passed, and the store executable is available. // no user-defined store is passed, and the store executable is available.

View File

@ -20,6 +20,7 @@ import (
"io" "io"
"net" "net"
"os" "os"
"os/exec"
"runtime" "runtime"
"strings" "strings"
"sync" "sync"
@ -28,7 +29,6 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
exec "golang.org/x/sys/execabs"
) )
// New returns net.Conn // New returns net.Conn