depot/third_party/nixpkgs/pkgs/by-name/po/pomerium/0001-envoy-allow-specification-of-external-binary.patch
Default email 472aeafc57 Project import generated by Copybara.
GitOrigin-RevId: c31898adf5a8ed202ce5bea9f347b1c6871f32d1
2024-10-04 18:56:33 +02:00

63 lines
1.7 KiB
Diff

From e82f2949b86d127aec908d90d872dfd6feb509e5 Mon Sep 17 00:00:00 2001
From: Morgan Helton <mhelton@gmail.com>
Date: Sun, 26 May 2024 12:17:01 -0500
Subject: [PATCH] envoy: allow specification of external binary
---
pkg/envoy/envoy.go | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/pkg/envoy/envoy.go b/pkg/envoy/envoy.go
index 6639d4bd..c6ca198f 100644
--- a/pkg/envoy/envoy.go
+++ b/pkg/envoy/envoy.go
@@ -8,9 +8,9 @@ import (
"errors"
"fmt"
"io"
+ "io/fs"
"os"
"os/exec"
- "path"
"path/filepath"
"regexp"
"strconv"
@@ -34,8 +34,12 @@ import (
const (
configFileName = "envoy-config.yaml"
+ workingDirectoryName = ".pomerium-envoy"
+ embeddedEnvoyPermissions fs.FileMode = 0o700
)
+var OverrideEnvoyPath = ""
+
type serverOptions struct {
services string
logLevel config.LogLevel
@@ -59,17 +63,16 @@ type Server struct {
// NewServer creates a new server with traffic routed by envoy.
func NewServer(ctx context.Context, src config.Source, builder *envoyconfig.Builder) (*Server, error) {
- if err := preserveRlimitNofile(); err != nil {
- log.Debug(ctx).Err(err).Msg("couldn't preserve RLIMIT_NOFILE before starting Envoy")
- }
+ envoyPath := OverrideEnvoyPath
+ wd := filepath.Join(os.TempDir(), workingDirectoryName)
- envoyPath, err := Extract()
+ err := os.MkdirAll(wd, embeddedEnvoyPermissions)
if err != nil {
- return nil, fmt.Errorf("extracting envoy: %w", err)
+ return nil, fmt.Errorf("error creating temporary working directory for envoy: %w", err)
}
srv := &Server{
- wd: path.Dir(envoyPath),
+ wd: wd,
builder: builder,
grpcPort: src.GetConfig().GRPCPort,
httpPort: src.GetConfig().HTTPPort,
--
2.46.0