]> Cypherpunks repositories - gostls13.git/commitdiff
all: use os/exec instead of internal/execabs
authorRuss Cox <rsc@golang.org>
Thu, 27 Jan 2022 18:10:48 +0000 (13:10 -0500)
committerGopher Robot <gobot@golang.org>
Mon, 2 May 2022 17:49:12 +0000 (17:49 +0000)
We added internal/execabs back in January 2021 in order to fix
a security problem caused by os/exec's handling of the current
directory. Now that os/exec has that code, internal/execabs is
superfluous and can be deleted.

This commit rewrites all the imports back to os/exec and
deletes internal/execabs.

For #43724.

Change-Id: Ib9736baf978be2afd42a1225e2ab3fd5d33d19df
Reviewed-on: https://go-review.googlesource.com/c/go/+/381375
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
39 files changed:
src/cmd/api/goapi.go
src/cmd/api/run.go
src/cmd/cgo/out.go
src/cmd/cgo/util.go
src/cmd/compile/internal/ssa/html.go
src/cmd/cover/func.go
src/cmd/cover/testdata/toolexec.go
src/cmd/dist/buildtool.go
src/cmd/doc/dirs.go
src/cmd/fix/typecheck.go
src/cmd/go/internal/base/base.go
src/cmd/go/internal/bug/bug.go
src/cmd/go/internal/generate/generate.go
src/cmd/go/internal/modfetch/codehost/codehost.go
src/cmd/go/internal/modfetch/codehost/git.go
src/cmd/go/internal/test/genflags.go
src/cmd/go/internal/test/internal/genflags/vetflag.go
src/cmd/go/internal/test/test.go
src/cmd/go/internal/tool/tool.go
src/cmd/go/internal/vcs/vcs.go
src/cmd/go/internal/vet/vetflag.go
src/cmd/go/internal/work/build.go
src/cmd/go/internal/work/buildid.go
src/cmd/go/internal/work/exec.go
src/cmd/go/internal/work/gccgo.go
src/cmd/go/testdata/addmod.go
src/cmd/internal/browser/browser.go
src/cmd/internal/dwarf/dwarf.go
src/cmd/internal/pkgpath/pkgpath.go
src/cmd/link/internal/ld/execarchive.go
src/cmd/link/internal/ld/lib.go
src/cmd/test2json/main.go
src/cmd/trace/pprof.go
src/go/build/build.go
src/go/build/deps_test.go
src/go/internal/gccgoimporter/gccgoinstallation.go
src/go/internal/srcimporter/srcimporter.go
src/internal/execabs/execabs.go [deleted file]
src/internal/goroot/gc.go

index b2a023a9b74336563774dfead2d1906e59b2cfc7..e6bf62df1fb5cb29d200dfc2a5a9d0b3288ecbfc 100644 (file)
@@ -16,10 +16,10 @@ import (
        "go/parser"
        "go/token"
        "go/types"
-       exec "internal/execabs"
        "io"
        "log"
        "os"
+       "os/exec"
        "path/filepath"
        "regexp"
        "runtime"
index 3ceaae6b8945ed63cb72ad82c86b595d92305c13..1ae629a032230498910ecaa877a59078d482a94b 100644 (file)
@@ -11,11 +11,11 @@ package main
 import (
        "errors"
        "fmt"
-       exec "internal/execabs"
        "internal/goversion"
        "io/fs"
        "log"
        "os"
+       "os/exec"
        "path/filepath"
        "runtime"
        "strconv"
index adbb761e3887117062861e31ac5a7b91bf95efa6..a27007ed1d63c3a1de8be2b4131b47ed71cf794b 100644 (file)
@@ -14,10 +14,10 @@ import (
        "go/ast"
        "go/printer"
        "go/token"
-       exec "internal/execabs"
        "internal/xcoff"
        "io"
        "os"
+       "os/exec"
        "path/filepath"
        "regexp"
        "sort"
index 00d931b98a0c1e8416d5bb14334946dbd9a56304..779f7be2259b3750166b6edce318adb779e7a3a6 100644 (file)
@@ -8,9 +8,9 @@ import (
        "bytes"
        "fmt"
        "go/token"
-       exec "internal/execabs"
        "io/ioutil"
        "os"
+       "os/exec"
 )
 
 // run runs the command argv, feeding in stdin on standard input.
index d9a78b396243beb32e912549f89a83ef72c692a5..1e6060ab32248e872206da29eb92786a64ef501f 100644 (file)
@@ -9,9 +9,9 @@ import (
        "cmd/internal/src"
        "fmt"
        "html"
-       exec "internal/execabs"
        "io"
        "os"
+       "os/exec"
        "path/filepath"
        "strconv"
        "strings"
index 76a16b3fc4a11ef75c9ba4aabde154189ddf151d..dffd3c1a0553ac2e907028abdee5d046f3d746da 100644 (file)
@@ -15,9 +15,9 @@ import (
        "go/ast"
        "go/parser"
        "go/token"
-       exec "internal/execabs"
        "io"
        "os"
+       "os/exec"
        "path"
        "path/filepath"
        "runtime"
index 458adaeaaa53696e09b04686c0515b419aaa1fff..1769efedbeb678674045a9d6b9bbc08fb4e5ed30 100644 (file)
@@ -15,8 +15,8 @@
 package main
 
 import (
-       exec "internal/execabs"
        "os"
+       "os/exec"
        "strings"
 )
 
index 6450601476737cc5e22aa10ca8805351d2f70347..8afa7f7867e80e48d16e4fb6cde189eaede3e488 100644 (file)
@@ -310,8 +310,6 @@ func bootstrapFixImports(srcFile string) string {
                if strings.HasPrefix(line, `import "`) || strings.HasPrefix(line, `import . "`) ||
                        inBlock && (strings.HasPrefix(line, "\t\"") || strings.HasPrefix(line, "\t. \"") || strings.HasPrefix(line, "\texec \"")) {
                        line = strings.Replace(line, `"cmd/`, `"bootstrap/cmd/`, -1)
-                       // During bootstrap, must use plain os/exec.
-                       line = strings.Replace(line, `exec "internal/execabs"`, `"os/exec"`, -1)
                        for _, dir := range bootstrapDirs {
                                if strings.HasPrefix(dir, "cmd/") {
                                        continue
index 489f49088993718edc09bfc80ce5b161d4c43e43..60ad6d30e6a99b89307db38f902abee15408d19c 100644 (file)
@@ -7,9 +7,9 @@ package main
 import (
        "bytes"
        "fmt"
-       exec "internal/execabs"
        "log"
        "os"
+       "os/exec"
        "path/filepath"
        "regexp"
        "strings"
index 8a18d61bf2748e5c080cb4811a2782b01de428c4..015a0eef2f8611397a5012ae6b0fa51e0f3cb3d9 100644 (file)
@@ -9,8 +9,8 @@ import (
        "go/ast"
        "go/parser"
        "go/token"
-       exec "internal/execabs"
        "os"
+       "os/exec"
        "path/filepath"
        "reflect"
        "runtime"
index c2d4e6b258887118b8d0822f6a3c246951b7bb77..d4af4dbc4b0ff3879df1b48a59e826b39723ab0b 100644 (file)
@@ -10,9 +10,9 @@ import (
        "context"
        "flag"
        "fmt"
-       exec "internal/execabs"
        "log"
        "os"
+       "os/exec"
        "strings"
        "sync"
 
index b4181b1e44adc86cf221f852b805adf090c2d667..9c9e9dd68adbd009d3be4a7f3b641015dc20a317 100644 (file)
@@ -9,10 +9,10 @@ import (
        "bytes"
        "context"
        "fmt"
-       exec "internal/execabs"
        "io"
        urlpkg "net/url"
        "os"
+       "os/exec"
        "path/filepath"
        "regexp"
        "runtime"
index a46f4f8908c44bd6976e831f172a5fad8bef9cf4..fe1e3d46c0cc9159be988d30793c220ad24dd62a 100644 (file)
@@ -12,10 +12,10 @@ import (
        "fmt"
        "go/parser"
        "go/token"
-       exec "internal/execabs"
        "io"
        "log"
        "os"
+       "os/exec"
        "path/filepath"
        "regexp"
        "strconv"
index d8d4392baaa39bf8df7ec35c5716ebfac100f3ac..31dc811752b83e5fc24d5c41464435cfba3d1962 100644 (file)
@@ -10,10 +10,10 @@ import (
        "bytes"
        "crypto/sha256"
        "fmt"
-       exec "internal/execabs"
        "io"
        "io/fs"
        "os"
+       "os/exec"
        "path/filepath"
        "strings"
        "sync"
index 34f453c855ef8d6b3dd7f6edbab34f30430b7c08..9c8fd42833cc7e96122987a1836a073d9c8ccaec 100644 (file)
@@ -8,11 +8,11 @@ import (
        "bytes"
        "errors"
        "fmt"
-       exec "internal/execabs"
        "io"
        "io/fs"
        "net/url"
        "os"
+       "os/exec"
        "path/filepath"
        "sort"
        "strconv"
index 10f290090c7cf8e92420c8f61dae4ca559d926d0..f50ae5c1e932404897502e345630a72fe7005ed7 100644 (file)
@@ -9,9 +9,9 @@ package main
 import (
        "bytes"
        "flag"
-       exec "internal/execabs"
        "log"
        "os"
+       "os/exec"
        "strings"
        "testing"
        "text/template"
index 2195cc34479f31bc611860fa9cdfecbbcc5744f3..1448811af053e4ab7f2270c6d3e9ee13f9bb2f0f 100644 (file)
@@ -9,7 +9,7 @@ import (
        "cmd/go/internal/base"
        "encoding/json"
        "fmt"
-       exec "internal/execabs"
+       "os/exec"
        "regexp"
        "sort"
 )
index 50e6d5201b0d6e04cc59a3289d30fa8b4e1cb2b0..4adf3acbe6ef6efa308055c2b06039c7b5919f3f 100644 (file)
@@ -11,10 +11,10 @@ import (
        "errors"
        "fmt"
        "go/build"
-       exec "internal/execabs"
        "io"
        "io/fs"
        "os"
+       "os/exec"
        "path"
        "path/filepath"
        "regexp"
index e8b55092d83e8e226768e70d04d1227cbc28479e..d61b524863efbe0998d0c3c0c55d64cf2222f76c 100644 (file)
@@ -8,8 +8,8 @@ package tool
 import (
        "context"
        "fmt"
-       exec "internal/execabs"
        "os"
+       "os/exec"
        "os/signal"
        "sort"
        "strings"
index 7dbcfb7cc48083c2ebc660b157fa75b61386b750..4f16bef90ce2fad21912198330b318c826badf3f 100644 (file)
@@ -8,13 +8,13 @@ import (
        "bytes"
        "errors"
        "fmt"
-       exec "internal/execabs"
        "internal/lazyregexp"
        "internal/singleflight"
        "io/fs"
        "log"
        urlpkg "net/url"
        "os"
+       "os/exec"
        "path/filepath"
        "regexp"
        "strconv"
index 8a55e9cca0c2dcc1ef762e8e66e0d3a13f42d8cd..eb7af6508d00be6debf34945e1188c9babd63ead 100644 (file)
@@ -10,9 +10,9 @@ import (
        "errors"
        "flag"
        "fmt"
-       exec "internal/execabs"
        "log"
        "os"
+       "os/exec"
        "path/filepath"
        "strings"
 
index e9a8ee6cb3a5cc0b7299c22f36fe5abb65ae6aee..2f3c8c7554c12a971a94a35a9c7422f4f568b460 100644 (file)
@@ -9,8 +9,8 @@ import (
        "errors"
        "fmt"
        "go/build"
-       exec "internal/execabs"
        "os"
+       "os/exec"
        "path/filepath"
        "runtime"
        "strconv"
index ac98aa344c8bfc2647f3c479864318c04d0597e9..846e2c8b775d8e3454fb75d19a5f9331a046b51e 100644 (file)
@@ -7,8 +7,8 @@ package work
 import (
        "bytes"
        "fmt"
-       exec "internal/execabs"
        "os"
+       "os/exec"
        "strings"
 
        "cmd/go/internal/base"
index 7c71d7e6e4a16dd4c2022c2a61ec911a9e46b1af..7f5fb774ea049fb860aa6a9d497c6271d893b853 100644 (file)
@@ -12,13 +12,13 @@ import (
        "encoding/json"
        "errors"
        "fmt"
-       exec "internal/execabs"
        "internal/lazyregexp"
        "io"
        "io/fs"
        "log"
        "math/rand"
        "os"
+       "os/exec"
        "path/filepath"
        "regexp"
        "runtime"
index 1499536932d2cf94fef56715aec3b08c39be0022..cfd9bcc0c2fa43eaac9dc5653f3393db215bf984 100644 (file)
@@ -6,8 +6,8 @@ package work
 
 import (
        "fmt"
-       exec "internal/execabs"
        "os"
+       "os/exec"
        "path/filepath"
        "strings"
        "sync"
index 41997a52fff4912f174cd8d7bf5ad6747eaa02f8..e378d7f31a159791610756b08e06fe761d5d78f7 100644 (file)
@@ -23,11 +23,11 @@ import (
        "bytes"
        "flag"
        "fmt"
-       exec "internal/execabs"
        "internal/txtar"
        "io/fs"
        "log"
        "os"
+       "os/exec"
        "path/filepath"
        "strings"
 )
index 577d31789f19afcb768e847cd69d2714e4d48b06..6867c85d2320406bb4c80b8960f5b958c6a2f196 100644 (file)
@@ -6,8 +6,8 @@
 package browser
 
 import (
-       exec "internal/execabs"
        "os"
+       "os/exec"
        "runtime"
        "time"
 )
index be3764170694684e2b61f21fb2750c84289fc1c3..8ba57371e61b3ac3f6a875521c58ff233e27342b 100644 (file)
@@ -12,7 +12,7 @@ import (
        "errors"
        "fmt"
        "internal/buildcfg"
-       exec "internal/execabs"
+       "os/exec"
        "sort"
        "strconv"
        "strings"
index 72e3bdb6311611c4ce645e21c642f45efc847a76..40a040a81af6acb54eb272d7bf388b8f79289d99 100644 (file)
@@ -10,9 +10,9 @@ import (
        "bytes"
        "errors"
        "fmt"
-       exec "internal/execabs"
        "io/ioutil"
        "os"
+       "os/exec"
        "strings"
 )
 
index 918b86cdc5bbaf7a293bdb33dc1c02c99d2a6bb7..a9376e96a4b3d1f62bfc98582126f32ac4f2dbc5 100644 (file)
@@ -8,8 +8,8 @@
 package ld
 
 import (
-       exec "internal/execabs"
        "os"
+       "os/exec"
        "path/filepath"
        "syscall"
 )
index d995f7676bc75dc3369f198d46036b56e0524e87..4aefa9991dfc2a738341006fdd9e93f0d152eab8 100644 (file)
@@ -49,11 +49,11 @@ import (
        "encoding/binary"
        "fmt"
        "internal/buildcfg"
-       exec "internal/execabs"
        "io"
        "io/ioutil"
        "log"
        "os"
+       "os/exec"
        "path/filepath"
        "runtime"
        "strings"
index b1c2d0696d2302658fc15b4d5e6d55fe07e4447c..5e17e0dec3cd4f9b0da8d5f52eb6beb609eabbeb 100644 (file)
@@ -85,9 +85,9 @@ package main
 import (
        "flag"
        "fmt"
-       exec "internal/execabs"
        "io"
        "os"
+       "os/exec"
 
        "cmd/internal/test2json"
 )
index c4d37428209ab61d7cc74f44725bc93a421a7dcf..a73ff5336afab0ced026cb58775a40c4184eeeaf 100644 (file)
@@ -9,11 +9,11 @@ package main
 import (
        "bufio"
        "fmt"
-       exec "internal/execabs"
        "internal/trace"
        "io"
        "net/http"
        "os"
+       "os/exec"
        "path/filepath"
        "runtime"
        "sort"
index bfa9cd60fb1840403669a61464e4d74a4d5a5b81..cf8886c7871e0e2fe36d359282b5bce5d8caf0b1 100644 (file)
@@ -13,13 +13,13 @@ import (
        "go/doc"
        "go/token"
        "internal/buildcfg"
-       exec "internal/execabs"
        "internal/goroot"
        "internal/goversion"
        "io"
        "io/fs"
        "io/ioutil"
        "os"
+       "os/exec"
        pathpkg "path"
        "path/filepath"
        "runtime"
index 330973567d71fe8372839a8647fe4b8b2e920b72..8e24ca937b43ab3ee21117b4163645209942b4f0 100644 (file)
@@ -203,15 +203,10 @@ var depsRules = `
 
        log !< FMT;
 
-       OS, FMT
-       < internal/execabs;
-
-       OS, internal/execabs
-       < internal/goroot;
-
        # Misc packages needing only FMT.
        FMT
        < html,
+         internal/goroot,
          mime/quotedprintable,
          net/internal/socktest,
          net/url,
index e90a3cc0b0a343e601bc2fe6389e43a160c713b9..8fc7ce3232190c93bb74f445bf55be1929e4c786 100644 (file)
@@ -7,8 +7,8 @@ package gccgoimporter
 import (
        "bufio"
        "go/types"
-       exec "internal/execabs"
        "os"
+       "os/exec"
        "path/filepath"
        "strings"
 )
index ea6f01280a73b58f9f2447ac88916902e29501ac..caf76a24deed276440996bcd94ae126bf28dacb8 100644 (file)
@@ -13,9 +13,9 @@ import (
        "go/parser"
        "go/token"
        "go/types"
-       exec "internal/execabs"
        "io"
        "os"
+       "os/exec"
        "path/filepath"
        "strings"
        "sync"
diff --git a/src/internal/execabs/execabs.go b/src/internal/execabs/execabs.go
deleted file mode 100644 (file)
index 5f60fbb..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2021 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Package execabs is a drop-in replacement for os/exec
-// that requires PATH lookups to find absolute paths.
-// That is, execabs.Command("cmd") runs the same PATH lookup
-// as exec.Command("cmd"), but if the result is a path
-// which is relative, the Run and Start methods will report
-// an error instead of running the executable.
-package execabs
-
-import (
-       "context"
-       "os/exec"
-)
-
-var ErrNotFound = exec.ErrNotFound
-
-type (
-       Cmd       = exec.Cmd
-       Error     = exec.Error
-       ExitError = exec.ExitError
-)
-
-func LookPath(file string) (string, error) {
-       return exec.LookPath(file)
-}
-
-func CommandContext(ctx context.Context, name string, arg ...string) *exec.Cmd {
-       return exec.CommandContext(ctx, name, arg...)
-}
-
-func Command(name string, arg ...string) *exec.Cmd {
-       return exec.Command(name, arg...)
-}
index 8c66cd13a81c2540cc9bae1a2a399d1eba6699ea..79403d29fc02e55c30a929be3eee2478f02e6062 100644 (file)
@@ -7,8 +7,8 @@
 package goroot
 
 import (
-       exec "internal/execabs"
        "os"
+       "os/exec"
        "path/filepath"
        "strings"
        "sync"