Skip to content

Commit c17c12d

Browse files
fix: bug in config (#122)
* fix: bug in config * fix: env vars bug in landjail * docs: document envs behavior
1 parent 9c9c878 commit c17c12d

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

cli/cli.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ func NewCommand() *serpent.Command {
4141
func BaseCommand() *serpent.Command {
4242
cliConfig := config.CliConfig{}
4343

44-
// Set default cliConfig path if file exists - serpent will load it automatically
44+
// Set default config path if file exists - serpent will load it automatically
4545
if home, err := os.UserHomeDir(); err == nil {
46-
defaultPath := filepath.Join(home, ".cliConfig", "coder_boundary", "cliConfig.yaml")
46+
defaultPath := filepath.Join(home, ".config", "coder_boundary", "config.yaml")
4747
if _, err := os.Stat(defaultPath); err == nil {
4848
cliConfig.Config = serpent.YAMLConfigPath(defaultPath)
4949
}
@@ -55,22 +55,22 @@ func BaseCommand() *serpent.Command {
5555
Long: `boundary creates an isolated network environment for target processes, intercepting HTTP/HTTPS traffic through a transparent proxy that enforces user-defined allow rules.`,
5656
Options: []serpent.Option{
5757
{
58-
Flag: "cliConfig",
58+
Flag: "config",
5959
Env: "BOUNDARY_CONFIG",
60-
Description: "Path to YAML cliConfig file.",
60+
Description: "Path to YAML config file.",
6161
Value: &cliConfig.Config,
6262
YAML: "",
6363
},
6464
{
6565
Flag: "allow",
6666
Env: "BOUNDARY_ALLOW",
67-
Description: "Allow rule (repeatable). These are merged with allowlist from cliConfig file. Format: \"pattern\" or \"METHOD[,METHOD] pattern\".",
67+
Description: "Allow rule (repeatable). These are merged with allowlist from config file. Format: \"pattern\" or \"METHOD[,METHOD] pattern\".",
6868
Value: &cliConfig.AllowStrings,
6969
YAML: "", // CLI only, not loaded from YAML
7070
},
7171
{
7272
Flag: "", // No CLI flag, YAML only
73-
Description: "Allowlist rules from cliConfig file (YAML only).",
73+
Description: "Allowlist rules from config file (YAML only).",
7474
Value: &cliConfig.AllowListStrings,
7575
YAML: "allowlist",
7676
},

landjail/child.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ func RunChild(logger *slog.Logger, config config.AppConfig) error {
5252

5353
// Build command
5454
cmd := exec.Command(config.TargetCMD[0], config.TargetCMD[1:]...)
55-
cmd.Env = getEnvsForTargetProcess(config.UserInfo.ConfigDir, config.UserInfo.CACertPath(), int(config.ProxyPort))
5655
cmd.Stdin = os.Stdin
5756
cmd.Stdout = os.Stdout
5857
cmd.Stderr = os.Stderr
@@ -77,6 +76,8 @@ func RunChild(logger *slog.Logger, config config.AppConfig) error {
7776
return nil
7877
}
7978

79+
// Returns environment variables intended to be set on the child process,
80+
// so they can later be inherited by the target process.
8081
func getEnvsForTargetProcess(configDir string, caCertPath string, httpProxyPort int) []string {
8182
e := os.Environ()
8283

landjail/manager.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ func (b *LandJail) RunChildProcess(command []string) error {
124124

125125
func (b *LandJail) getChildCommand(command []string) *exec.Cmd {
126126
cmd := exec.Command(command[0], command[1:]...)
127+
// Set env vars for the child process; they will be inherited by the target process.
128+
cmd.Env = getEnvsForTargetProcess(b.config.UserInfo.ConfigDir, b.config.UserInfo.CACertPath(), int(b.config.ProxyPort))
127129
cmd.Env = append(cmd.Env, "CHILD=true")
128130
cmd.Stderr = os.Stderr
129131
cmd.Stdout = os.Stdout

nsjail_manager/nsjail/env.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
"github.com/coder/boundary/util"
77
)
88

9+
// Returns environment variables intended to be set on the child process,
10+
// so they can later be inherited by the target process.
911
func getEnvsForTargetProcess(configDir string, caCertPath string) []string {
1012
e := os.Environ()
1113

nsjail_manager/nsjail/jail.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ func (l *LinuxJail) Command(command []string) *exec.Cmd {
6767
l.logger.Debug("Creating command with namespace")
6868

6969
cmd := exec.Command(command[0], command[1:]...)
70+
// Set env vars for the child process; they will be inherited by the target process.
7071
cmd.Env = getEnvsForTargetProcess(l.configDir, l.caCertPath)
7172
cmd.Env = append(cmd.Env, "CHILD=true")
7273
cmd.Env = append(cmd.Env, fmt.Sprintf("VETH_JAIL_NAME=%v", l.vethJailName))

0 commit comments

Comments
 (0)