Skip to content

Commit

Permalink
remove uses of golang.org/x/sys/execabs
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
thaJeztah committed May 26, 2023
1 parent 5be2139 commit 4cf0498
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 9 deletions.
4 changes: 1 addition & 3 deletions cli-plugins/manager/candidate.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package manager

import (
exec "golang.org/x/sys/execabs"
)
import "os/exec"

// Candidate represents a possible plugin candidate, for mocking purposes
type Candidate interface {
Expand Down
2 changes: 1 addition & 1 deletion cli-plugins/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package manager
import (
"context"
"os"
"os/exec"
"path/filepath"
"sort"
"strings"
Expand All @@ -13,7 +14,6 @@ import (
"github.com/fvbommel/sortorder"
"github.com/spf13/cobra"
"golang.org/x/sync/errgroup"
exec "golang.org/x/sys/execabs"
)

// ReexecEnvvar is the name of an ennvar which is set to the command
Expand Down
2 changes: 1 addition & 1 deletion cli/command/image/build/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"io"
"net/http"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
Expand All @@ -22,7 +23,6 @@ import (
"github.com/docker/docker/pkg/stringid"
"github.com/moby/patternmatcher"
"github.com/pkg/errors"
exec "golang.org/x/sys/execabs"
)

const (
Expand Down
4 changes: 1 addition & 3 deletions cli/config/credentials/default_store.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package credentials

import (
exec "golang.org/x/sys/execabs"
)
import "os/exec"

// DetectDefaultStore return the default credentials store for the platform if
// no user-defined store is passed, and the store executable is available.
Expand Down
2 changes: 1 addition & 1 deletion cli/connhelper/commandconn/commandconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"io"
"net"
"os"
"os/exec"
"runtime"
"strings"
"sync"
Expand All @@ -28,7 +29,6 @@ import (

"github.com/pkg/errors"
"github.com/sirupsen/logrus"
exec "golang.org/x/sys/execabs"
)

// New returns net.Conn
Expand Down

0 comments on commit 4cf0498

Please sign in to comment.