Skip to content

Commit 2af6db6

Browse files
committed
switch back from golang.org/x/sys/execabs to os/exec (go1.19)
This is effectively a revert of 2ac9968, which switched from os/exec to the golang.org/x/sys/execabs package to mitigate security issues (mainly on Windows) with lookups resolving to binaries in the current directory. from the go1.19 release notes https://go.dev/doc/go1.19#os-exec-path > ## PATH lookups > > 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. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 6cd0e8e commit 2af6db6

36 files changed

Lines changed: 41 additions & 48 deletions

archive/compression/compression.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ import (
2525
"fmt"
2626
"io"
2727
"os"
28+
"os/exec"
2829
"strconv"
2930
"sync"
3031

3132
"github.com/containerd/log"
3233
"github.com/klauspost/compress/zstd"
33-
exec "golang.org/x/sys/execabs"
3434
)
3535

3636
type (

archive/compression/compression_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,11 @@ import (
2323
"crypto/rand"
2424
"io"
2525
"os"
26+
"os/exec"
2627
"path/filepath"
2728
"runtime"
2829
"strings"
2930
"testing"
30-
31-
exec "golang.org/x/sys/execabs"
3231
)
3332

3433
func TestMain(m *testing.M) {

archive/tar_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"fmt"
2828
"io"
2929
"os"
30+
"os/exec"
3031
"path/filepath"
3132
"runtime"
3233
"testing"
@@ -38,7 +39,6 @@ import (
3839
"github.com/containerd/continuity/fs/fstest"
3940
"github.com/opencontainers/go-digest"
4041
"github.com/stretchr/testify/require"
41-
exec "golang.org/x/sys/execabs"
4242
)
4343

4444
const tarCmd = "tar"

cmd/containerd/command/service_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ import (
2020
"fmt"
2121
"log"
2222
"os"
23+
"os/exec"
2324
"path/filepath"
2425
"time"
2526

2627
"github.com/containerd/containerd/v2/errdefs"
2728
"github.com/containerd/containerd/v2/services/server"
2829
"github.com/sirupsen/logrus"
2930
"github.com/urfave/cli"
30-
exec "golang.org/x/sys/execabs"
3131
"golang.org/x/sys/windows"
3232
"golang.org/x/sys/windows/svc"
3333
"golang.org/x/sys/windows/svc/debug"

cmd/ctr/commands/content/content.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"fmt"
2222
"io"
2323
"os"
24+
"os/exec"
2425
"sort"
2526
"strings"
2627
"text/tabwriter"
@@ -35,7 +36,6 @@ import (
3536
digest "github.com/opencontainers/go-digest"
3637
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
3738
"github.com/urfave/cli"
38-
exec "golang.org/x/sys/execabs"
3939
)
4040

4141
var (

contrib/apparmor/template.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@ import (
2525
"fmt"
2626
"io"
2727
"os"
28+
"os/exec"
2829
"path"
2930
"strings"
3031
"text/template"
31-
32-
exec "golang.org/x/sys/execabs"
3332
)
3433

3534
// NOTE: This code is copied from <github.com/docker/docker/profiles/apparmor>.

contrib/nvidia/nvidia.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ import (
2020
"context"
2121
"fmt"
2222
"os"
23+
"os/exec"
2324
"strconv"
2425
"strings"
2526

2627
"github.com/containerd/containerd/v2/containers"
2728
"github.com/containerd/containerd/v2/oci"
2829
specs "github.com/opencontainers/runtime-spec/specs-go"
29-
exec "golang.org/x/sys/execabs"
3030
)
3131

3232
// NvidiaCLI is the path to the Nvidia helper binary

diff/stream_unix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ import (
2525
"fmt"
2626
"io"
2727
"os"
28+
"os/exec"
2829
"sync"
2930

3031
"github.com/containerd/containerd/v2/protobuf"
3132
"github.com/containerd/containerd/v2/protobuf/proto"
3233
"github.com/containerd/typeurl/v2"
33-
exec "golang.org/x/sys/execabs"
3434
)
3535

3636
// NewBinaryProcessor returns a binary processor for use with processing content streams

diff/stream_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ import (
2323
"fmt"
2424
"io"
2525
"os"
26+
"os/exec"
2627
"path/filepath"
2728
"sync"
2829

2930
"github.com/Microsoft/go-winio"
30-
exec "golang.org/x/sys/execabs"
3131

3232
"github.com/containerd/containerd/v2/protobuf"
3333
"github.com/containerd/containerd/v2/protobuf/proto"

integration/client/client_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ import (
2323
"fmt"
2424
"io"
2525
"os"
26+
"os/exec"
2627
"testing"
2728
"time"
2829

2930
"github.com/opencontainers/go-digest"
3031
"github.com/opencontainers/image-spec/identity"
3132
"github.com/stretchr/testify/require"
3233
"go.opentelemetry.io/otel"
33-
exec "golang.org/x/sys/execabs"
3434

3535
. "github.com/containerd/containerd/v2/client"
3636
"github.com/containerd/containerd/v2/defaults"

0 commit comments

Comments
 (0)