Skip to content

Commit fa8d9fe

Browse files
authored
fix(proxy-identity): use execve call on Linux to start the proxy (#14307)
A recent change (#14126) altered the semantics of running the proxy from the identity wrapper. This has introduced [regression in behavior on Linux systems](#14289). This PR reverts the logic on Unix to use `execve`. This way we use `os/exec` only on Windows systems. Further investigation into Windows behavior will be carried out but for now we aim to revert back to the behavior we had on Unix prior to #14126 Signed-off-by: Zahari Dichev <[email protected]>
1 parent aafa5eb commit fa8d9fe

File tree

3 files changed

+38
-19
lines changed

3 files changed

+38
-19
lines changed

proxy-identity/main.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ import (
88
"errors"
99
"fmt"
1010
"os"
11-
"os/exec"
1211
"path/filepath"
13-
"runtime"
1412

1513
"github.com/linkerd/linkerd2/pkg/tls"
1614
log "github.com/sirupsen/logrus"
@@ -143,20 +141,3 @@ func generateAndStoreCSR(p, id string, key *ecdsa.PrivateKey) ([]byte, error) {
143141

144142
return csrb, nil
145143
}
146-
147-
func runProxy() {
148-
path := "/usr/lib/linkerd/linkerd2-proxy"
149-
if runtime.GOOS == "windows" {
150-
path = "C:\\linkerd\\linkerd2-proxy.exe"
151-
}
152-
153-
cmd := exec.Command(path)
154-
cmd.Env = os.Environ()
155-
cmd.Stdin = os.Stdin
156-
cmd.Stdout = os.Stdout
157-
cmd.Stderr = os.Stderr
158-
err := cmd.Run()
159-
if err != nil {
160-
log.Fatalf("Failed to run proxy: %s", err)
161-
}
162-
}

proxy-identity/run_proxy_unix.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package main
2+
3+
import (
4+
"os"
5+
"syscall"
6+
7+
log "github.com/sirupsen/logrus"
8+
)
9+
10+
func runProxy() {
11+
// The input arguments are static.
12+
//nolint:gosec
13+
err := syscall.Exec("/usr/lib/linkerd/linkerd2-proxy", []string{}, os.Environ())
14+
if err != nil {
15+
log.Fatalf("Failed to run proxy: %s", err)
16+
}
17+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package main
2+
3+
import (
4+
"os"
5+
"os/exec"
6+
7+
log "github.com/sirupsen/logrus"
8+
)
9+
10+
func runProxy() {
11+
path := "C:\\linkerd\\linkerd2-proxy.exe"
12+
cmd := exec.Command(path)
13+
cmd.Env = os.Environ()
14+
cmd.Stdin = os.Stdin
15+
cmd.Stdout = os.Stdout
16+
cmd.Stderr = os.Stderr
17+
err := cmd.Run()
18+
if err != nil {
19+
log.Fatalf("Failed to run proxy: %s", err)
20+
}
21+
}

0 commit comments

Comments
 (0)