From efc1122343bb5e474c92d6353964d138626f243d Mon Sep 17 00:00:00 2001 From: Konstantin Mikhailov Date: Sat, 3 Sep 2022 03:55:19 +1000 Subject: [PATCH] Fix execute shell command to take into account edge cases --- pkg/gui/containers_panel.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/gui/containers_panel.go b/pkg/gui/containers_panel.go index 4f6bb941..118f4833 100644 --- a/pkg/gui/containers_panel.go +++ b/pkg/gui/containers_panel.go @@ -533,7 +533,7 @@ func (gui *Gui) containerExecShell(container *commands.Container) error { }) // TODO: use SDK - resolvedCommand := utils.ApplyTemplate("docker exec -it {{ .Container.ID }} /bin/sh -c 'eval $(grep ^$(id -un): /etc/passwd | cut -d : -f 7-)'", commandObject) + resolvedCommand := utils.ApplyTemplate("docker exec -it {{ .Container.ID }} /bin/sh -c 'eval $( (grep ^[^:]*:[^:]*:$(id -u): /etc/passwd || echo \"::::::/bin/sh\") | cut -d : -f 7-) || eval $(echo \"/bin/sh\")'", commandObject) // attach and return the subprocess error cmd := gui.OSCommand.ExecutableFromString(resolvedCommand) return gui.runSubprocess(cmd)