diff options
Diffstat (limited to 'pkg/container/host_environment.go')
-rw-r--r-- | pkg/container/host_environment.go | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/pkg/container/host_environment.go b/pkg/container/host_environment.go index 7093c06..b12e69f 100644 --- a/pkg/container/host_environment.go +++ b/pkg/container/host_environment.go @@ -35,6 +35,7 @@ type HostEnvironment struct { Root string CleanUp func() StdOut io.Writer + LXC bool } func (e *HostEnvironment) Create(_, _ []string) common.Executor { @@ -302,17 +303,21 @@ func (e *HostEnvironment) exec(ctx context.Context, commandparam []string, cmdli } else { wd = e.Path } + if _, err := os.Stat(wd); err != nil { common.Logger(ctx).Debugf("Failed to stat working directory %s %v\n", wd, err.Error()) } command := make([]string, len(commandparam)) copy(command, commandparam) - if user == "root" { - command = append([]string{"/usr/bin/sudo"}, command...) - } else { - common.Logger(ctx).Debugf("lxc-attach --name %v %v", e.Name, command) - command = append([]string{"/usr/bin/sudo", "--preserve-env", "--preserve-env=PATH", "/usr/bin/lxc-attach", "--keep-env", "--name", e.Name, "--"}, command...) + + if e.GetLXC() { + if user == "root" { + command = append([]string{"/usr/bin/sudo"}, command...) + } else { + common.Logger(ctx).Debugf("lxc-attach --name %v %v", e.Name, command) + command = append([]string{"/usr/bin/sudo", "--preserve-env", "--preserve-env=PATH", "/usr/bin/lxc-attach", "--keep-env", "--name", e.Name, "--"}, command...) + } } f, err := lookupPathHost(command[0], env, e.StdOut) @@ -414,6 +419,10 @@ func (e *HostEnvironment) ToContainerPath(path string) string { return path } +func (e *HostEnvironment) GetLXC() bool { + return e.LXC +} + func (e *HostEnvironment) GetName() string { return e.Name } |